mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1435692 - patch 1 - Add support in gfx for automatic application of the optical size axis in variation fonts that support it. r=jwatt
This commit is contained in:
parent
583ca26396
commit
d405368c27
@ -56,6 +56,7 @@ nsFont::CalcDifference(const nsFont& aOther) const
|
||||
(sizeAdjust != aOther.sizeAdjust) ||
|
||||
(fontlist != aOther.fontlist) ||
|
||||
(kerning != aOther.kerning) ||
|
||||
(opticalSizing != aOther.opticalSizing) ||
|
||||
(synthesis != aOther.synthesis) ||
|
||||
(fontFeatureSettings != aOther.fontFeatureSettings) ||
|
||||
(fontVariationSettings != aOther.fontVariationSettings) ||
|
||||
@ -292,7 +293,26 @@ void nsFont::AddFontFeaturesToStyle(gfxFontStyle *aStyle,
|
||||
void nsFont::AddFontVariationsToStyle(gfxFontStyle *aStyle) const
|
||||
{
|
||||
// TODO: add variation settings from specific CSS properties
|
||||
// such as weight, width, optical-size
|
||||
// such as weight, width, stretch
|
||||
|
||||
// If auto optical sizing is enabled, and if there's no 'opsz' axis in
|
||||
// fontVariationSettings, then set the automatic value on the style.
|
||||
class VariationTagComparator {
|
||||
public:
|
||||
bool Equals(const gfxFontVariation& aVariation, uint32_t aTag) const {
|
||||
return aVariation.mTag == aTag;
|
||||
}
|
||||
};
|
||||
const uint32_t kTagOpsz = TRUETYPE_TAG('o','p','s','z');
|
||||
if (opticalSizing == NS_FONT_OPTICAL_SIZING_AUTO &&
|
||||
!fontVariationSettings.Contains(kTagOpsz, VariationTagComparator())) {
|
||||
gfxFontVariation opsz = {
|
||||
kTagOpsz,
|
||||
// size is in app units, but we want a floating-point px size
|
||||
float(size) / float(AppUnitsPerCSSPixel())
|
||||
};
|
||||
aStyle->variationSettings.AppendElement(opsz);
|
||||
}
|
||||
|
||||
// Add in arbitrary values from font-variation-settings
|
||||
aStyle->variationSettings.AppendElements(fontVariationSettings);
|
||||
|
@ -88,6 +88,10 @@ struct nsFont {
|
||||
// Kerning
|
||||
uint8_t kerning = NS_FONT_KERNING_AUTO;
|
||||
|
||||
// Whether automatic optical sizing should be applied to variation fonts
|
||||
// that include an 'opsz' axis
|
||||
uint8_t opticalSizing = NS_FONT_OPTICAL_SIZING_AUTO;
|
||||
|
||||
// Synthesis setting, controls use of fake bolding/italics
|
||||
uint8_t synthesis = NS_FONT_SYNTHESIS_WEIGHT | NS_FONT_SYNTHESIS_STYLE;
|
||||
|
||||
|
@ -47,6 +47,9 @@
|
||||
#define NS_FONT_DISPLAY_FALLBACK 3
|
||||
#define NS_FONT_DISPLAY_OPTIONAL 4
|
||||
|
||||
#define NS_FONT_OPTICAL_SIZING_AUTO 0
|
||||
#define NS_FONT_OPTICAL_SIZING_NONE 1
|
||||
|
||||
#define NS_FONT_VARIANT_ALTERNATES_NORMAL 0
|
||||
// alternates - simple enumerated values
|
||||
#define NS_FONT_VARIANT_ALTERNATES_HISTORICAL (1 << 0)
|
||||
|
Loading…
Reference in New Issue
Block a user