1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
11 #include "gfxFontConstants.h" // for NS_FONT_KERNING_AUTO, etc
12 #include "gfxFontVariations.h"
13 #include "mozilla/ServoStyleConsts.h"
14 #include "mozilla/StyleColorInlines.h" // for StyleAbsoluteColor
15 #include "nsTArray.h" // for nsTArray
17 struct gfxFontFeature
;
22 typedef mozilla::FontStretch FontStretch
;
23 typedef mozilla::FontSlantStyle FontSlantStyle
;
24 typedef mozilla::FontWeight FontWeight
;
26 // List of font families, either named or generic.
27 mozilla::StyleFontFamily family
;
29 // Font features from CSS font-feature-settings
30 CopyableTArray
<gfxFontFeature
> fontFeatureSettings
;
32 // Font variations from CSS font-variation-settings
33 CopyableTArray
<gfxFontVariation
> fontVariationSettings
;
35 // The logical size of the font, in CSS Pixels
36 mozilla::NonNegativeLength size
{0};
38 // The aspect-value (ie., the ratio actualsize:actualxheight) that any
39 // actual physical font created from this font structure must have when
40 // rendering or measuring a string. The value must be nonnegative.
41 mozilla::StyleFontSizeAdjust sizeAdjust
=
42 mozilla::StyleFontSizeAdjust::None();
44 // Language system tag, to override document language;
45 // this is an OpenType "language system" tag represented as a 32-bit integer
46 // (see http://www.microsoft.com/typography/otspec/languagetags.htm).
47 mozilla::StyleFontLanguageOverride languageOverride
{0};
49 // Font-selection/rendering properties corresponding to CSS font-style,
50 // font-weight, font-stretch. These are all 16-bit types.
51 FontSlantStyle style
= FontSlantStyle::NORMAL
;
52 FontWeight weight
= FontWeight::NORMAL
;
53 FontStretch stretch
= FontStretch::NORMAL
;
55 // Some font-variant-alternates property values require
56 // font-specific settings defined via @font-feature-values rules.
57 // These are resolved *after* font matching occurs.
58 mozilla::StyleFontVariantAlternates variantAlternates
;
60 // Variant subproperties
61 mozilla::StyleFontVariantLigatures variantLigatures
=
62 mozilla::StyleFontVariantLigatures::NORMAL
;
63 mozilla::StyleFontVariantEastAsian variantEastAsian
=
64 mozilla::StyleFontVariantEastAsian::NORMAL
;
66 uint8_t variantCaps
= NS_FONT_VARIANT_CAPS_NORMAL
;
67 mozilla::StyleFontVariantNumeric variantNumeric
=
68 mozilla::StyleFontVariantNumeric::NORMAL
;
69 uint8_t variantPosition
= NS_FONT_VARIANT_POSITION_NORMAL
;
70 uint8_t variantWidth
= NS_FONT_VARIANT_WIDTH_NORMAL
;
71 StyleFontVariantEmoji variantEmoji
= StyleFontVariantEmoji::Normal
;
73 // Smoothing - controls subpixel-antialiasing (currently OSX only)
74 uint8_t smoothing
= NS_FONT_SMOOTHING_AUTO
;
77 uint8_t kerning
= NS_FONT_KERNING_AUTO
;
79 // Whether automatic optical sizing should be applied to variation fonts
80 // that include an 'opsz' axis
81 uint8_t opticalSizing
= NS_FONT_OPTICAL_SIZING_AUTO
;
83 // Synthesis setting, controls use of fake bolding/italics/small-caps
84 mozilla::StyleFontSynthesis synthesisWeight
=
85 mozilla::StyleFontSynthesis::Auto
;
86 mozilla::StyleFontSynthesis synthesisStyle
=
87 mozilla::StyleFontSynthesis::Auto
;
88 mozilla::StyleFontSynthesis synthesisSmallCaps
=
89 mozilla::StyleFontSynthesis::Auto
;
90 mozilla::StyleFontSynthesis synthesisPosition
=
91 mozilla::StyleFontSynthesis::Auto
;
93 // initialize the font with a fontlist
94 nsFont(const mozilla::StyleFontFamily
&, mozilla::Length aSize
);
96 // initialize the font with a single generic
97 nsFont(mozilla::StyleGenericFontFamily
, mozilla::Length aSize
);
99 // Make a copy of the given font
100 nsFont(const nsFont
& aFont
);
102 // leave members uninitialized
106 bool operator==(const nsFont
& aOther
) const { return Equals(aOther
); }
108 bool operator!=(const nsFont
& aOther
) const { return !Equals(aOther
); }
110 bool Equals(const nsFont
& aOther
) const;
112 nsFont
& operator=(const nsFont
& aOther
);
114 enum class MaxDifference
: uint8_t { eNone
, eVisual
, eLayoutAffecting
};
116 MaxDifference
CalcDifference(const nsFont
& aOther
) const;
118 // Add featureSettings into style
119 void AddFontFeaturesToStyle(gfxFontStyle
* aStyle
, bool aVertical
) const;
121 void AddFontVariationsToStyle(gfxFontStyle
* aStyle
) const;
124 #define NS_FONT_VARIANT_NORMAL 0
125 #define NS_FONT_VARIANT_SMALL_CAPS 1
127 #endif /* nsFont_h___ */