1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsFont_h___
#define nsFont_h___
#include <cstdint>
#include "gfxFontConstants.h" // for NS_FONT_KERNING_AUTO, etc
#include "gfxFontVariations.h"
#include "mozilla/ServoStyleConsts.h"
#include "mozilla/StyleColorInlines.h" // for StyleAbsoluteColor
#include "nsTArray.h" // for nsTArray
struct gfxFontFeature;
struct gfxFontStyle;
// Font structure.
struct nsFont final {
typedef mozilla::FontStretch FontStretch;
typedef mozilla::FontSlantStyle FontSlantStyle;
typedef mozilla::FontWeight FontWeight;
// List of font families, either named or generic.
mozilla::StyleFontFamily family;
// Font features from CSS font-feature-settings
CopyableTArray<gfxFontFeature> fontFeatureSettings;
// Font variations from CSS font-variation-settings
CopyableTArray<gfxFontVariation> fontVariationSettings;
// The logical size of the font, in CSS Pixels
mozilla::NonNegativeLength size{0};
// The aspect-value (ie., the ratio actualsize:actualxheight) that any
// actual physical font created from this font structure must have when
// rendering or measuring a string. The value must be nonnegative.
mozilla::StyleFontSizeAdjust sizeAdjust =
mozilla::StyleFontSizeAdjust::None();
// The estimated background color behind the text. Enables a special
// rendering mode when the alpha component > 0. Only used for text in the
// chrome.
mozilla::StyleAbsoluteColor fontSmoothingBackgroundColor =
mozilla::StyleAbsoluteColor::Transparent();
// Language system tag, to override document language;
// this is an OpenType "language system" tag represented as a 32-bit integer
// (see http://www.microsoft.com/typography/otspec/languagetags.htm).
uint32_t languageOverride = 0;
// Font-selection/rendering properties corresponding to CSS font-style,
// font-weight, font-stretch. These are all 16-bit types.
FontSlantStyle style = FontSlantStyle::NORMAL;
FontWeight weight = FontWeight::NORMAL;
FontStretch stretch = FontStretch::NORMAL;
// Some font-variant-alternates property values require
// font-specific settings defined via @font-feature-values rules.
// These are resolved *after* font matching occurs.
mozilla::StyleFontVariantAlternates variantAlternates;
// Variant subproperties
uint16_t variantLigatures = NS_FONT_VARIANT_LIGATURES_NORMAL;
uint16_t variantEastAsian = NS_FONT_VARIANT_EAST_ASIAN_NORMAL;
uint8_t variantCaps = NS_FONT_VARIANT_CAPS_NORMAL;
uint8_t variantNumeric = NS_FONT_VARIANT_NUMERIC_NORMAL;
uint8_t variantPosition = NS_FONT_VARIANT_POSITION_NORMAL;
uint8_t variantWidth = NS_FONT_VARIANT_WIDTH_NORMAL;
StyleFontVariantEmoji variantEmoji = StyleFontVariantEmoji::Normal;
// Smoothing - controls subpixel-antialiasing (currently OSX only)
uint8_t smoothing = NS_FONT_SMOOTHING_AUTO;
// 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/small-caps
mozilla::StyleFontSynthesis synthesisWeight =
mozilla::StyleFontSynthesis::Auto;
mozilla::StyleFontSynthesis synthesisStyle =
mozilla::StyleFontSynthesis::Auto;
mozilla::StyleFontSynthesis synthesisSmallCaps =
mozilla::StyleFontSynthesis::Auto;
// initialize the font with a fontlist
nsFont(const mozilla::StyleFontFamily&, mozilla::Length aSize);
// initialize the font with a single generic
nsFont(mozilla::StyleGenericFontFamily, mozilla::Length aSize);
// Make a copy of the given font
nsFont(const nsFont& aFont);
// leave members uninitialized
nsFont() = default;
~nsFont();
bool operator==(const nsFont& aOther) const { return Equals(aOther); }
bool operator!=(const nsFont& aOther) const { return !Equals(aOther); }
bool Equals(const nsFont& aOther) const;
nsFont& operator=(const nsFont& aOther);
enum class MaxDifference : uint8_t { eNone, eVisual, eLayoutAffecting };
MaxDifference CalcDifference(const nsFont& aOther) const;
// Add featureSettings into style
void AddFontFeaturesToStyle(gfxFontStyle* aStyle, bool aVertical) const;
void AddFontVariationsToStyle(gfxFontStyle* aStyle) const;
};
#define NS_FONT_VARIANT_NORMAL 0
#define NS_FONT_VARIANT_SMALL_CAPS 1
#endif /* nsFont_h___ */
|