OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. |
6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 , m_genericFamily(NoFamily) | 88 , m_genericFamily(NoFamily) |
89 , m_usePrinterFont(false) | 89 , m_usePrinterFont(false) |
90 , m_kerning(AutoKerning) | 90 , m_kerning(AutoKerning) |
91 , m_commonLigaturesState(NormalLigaturesState) | 91 , m_commonLigaturesState(NormalLigaturesState) |
92 , m_discretionaryLigaturesState(NormalLigaturesState) | 92 , m_discretionaryLigaturesState(NormalLigaturesState) |
93 , m_historicalLigaturesState(NormalLigaturesState) | 93 , m_historicalLigaturesState(NormalLigaturesState) |
94 , m_keywordSize(0) | 94 , m_keywordSize(0) |
95 , m_fontSmoothing(AutoSmoothing) | 95 , m_fontSmoothing(AutoSmoothing) |
96 , m_textRendering(AutoTextRendering) | 96 , m_textRendering(AutoTextRendering) |
97 , m_isSpecifiedFont(false) | 97 , m_isSpecifiedFont(false) |
98 , m_script(USCRIPT_COMMON) | |
99 { | 98 { |
100 } | 99 } |
101 | 100 |
102 bool operator==(const FontDescription&) const; | 101 bool operator==(const FontDescription&) const; |
103 bool operator!=(const FontDescription& other) const { return !(*this == othe
r); } | 102 bool operator!=(const FontDescription& other) const { return !(*this == othe
r); } |
104 | 103 |
105 const FontFamily& family() const { return m_familyList; } | 104 const FontFamily& family() const { return m_familyList; } |
106 FontFamily& firstFamily() { return m_familyList; } | 105 FontFamily& firstFamily() { return m_familyList; } |
107 float specifiedSize() const { return m_specifiedSize; } | 106 float specifiedSize() const { return m_specifiedSize; } |
108 float computedSize() const { return m_computedSize; } | 107 float computedSize() const { return m_computedSize; } |
109 FontItalic italic() const { return static_cast<FontItalic>(m_italic); } | 108 FontItalic italic() const { return static_cast<FontItalic>(m_italic); } |
110 int computedPixelSize() const { return int(m_computedSize + 0.5f); } | 109 int computedPixelSize() const { return int(m_computedSize + 0.5f); } |
111 FontSmallCaps smallCaps() const { return static_cast<FontSmallCaps>(m_smallC
aps); } | 110 FontSmallCaps smallCaps() const { return static_cast<FontSmallCaps>(m_smallC
aps); } |
112 bool isAbsoluteSize() const { return m_isAbsoluteSize; } | 111 bool isAbsoluteSize() const { return m_isAbsoluteSize; } |
113 FontWeight weight() const { return static_cast<FontWeight>(m_weight); } | 112 FontWeight weight() const { return static_cast<FontWeight>(m_weight); } |
114 FontWeight lighterWeight() const; | 113 FontWeight lighterWeight() const; |
115 FontWeight bolderWeight() const; | 114 FontWeight bolderWeight() const; |
116 GenericFamilyType genericFamily() const { return static_cast<GenericFamilyTy
pe>(m_genericFamily); } | 115 GenericFamilyType genericFamily() const { return static_cast<GenericFamilyTy
pe>(m_genericFamily); } |
117 bool usePrinterFont() const { return m_usePrinterFont; } | 116 bool usePrinterFont() const { return m_usePrinterFont; } |
118 // only use fixed default size when there is only one font family, and that
family is "monospace" | 117 // only use fixed default size when there is only one font family, and that
family is "monospace" |
119 bool useFixedDefaultSize() const { return genericFamily() == MonospaceFamily
&& !family().next() && family().family() == monospaceFamily; } | 118 bool useFixedDefaultSize() const { return genericFamily() == MonospaceFamily
&& !family().next() && family().family() == monospaceFamily; } |
120 Kerning kerning() const { return static_cast<Kerning>(m_kerning); } | 119 Kerning kerning() const { return static_cast<Kerning>(m_kerning); } |
121 LigaturesState commonLigaturesState() const { return static_cast<LigaturesSt
ate>(m_commonLigaturesState); } | 120 LigaturesState commonLigaturesState() const { return static_cast<LigaturesSt
ate>(m_commonLigaturesState); } |
122 LigaturesState discretionaryLigaturesState() const { return static_cast<Liga
turesState>(m_discretionaryLigaturesState); } | 121 LigaturesState discretionaryLigaturesState() const { return static_cast<Liga
turesState>(m_discretionaryLigaturesState); } |
123 LigaturesState historicalLigaturesState() const { return static_cast<Ligatur
esState>(m_historicalLigaturesState); } | 122 LigaturesState historicalLigaturesState() const { return static_cast<Ligatur
esState>(m_historicalLigaturesState); } |
124 unsigned keywordSize() const { return m_keywordSize; } | 123 unsigned keywordSize() const { return m_keywordSize; } |
125 FontSmoothingMode fontSmoothing() const { return static_cast<FontSmoothingMo
de>(m_fontSmoothing); } | 124 FontSmoothingMode fontSmoothing() const { return static_cast<FontSmoothingMo
de>(m_fontSmoothing); } |
126 TextRenderingMode textRenderingMode() const { return static_cast<TextRenderi
ngMode>(m_textRendering); } | 125 TextRenderingMode textRenderingMode() const { return static_cast<TextRenderi
ngMode>(m_textRendering); } |
127 UScriptCode script() const { return static_cast<UScriptCode>(m_script); } | 126 AtomicString locale() const { return m_locale; } |
128 | 127 |
129 FontTraitsMask traitsMask() const; | 128 FontTraitsMask traitsMask() const; |
130 bool isSpecifiedFont() const { return m_isSpecifiedFont; } | 129 bool isSpecifiedFont() const { return m_isSpecifiedFont; } |
131 FontOrientation orientation() const { return static_cast<FontOrientation>(m_
orientation); } | 130 FontOrientation orientation() const { return static_cast<FontOrientation>(m_
orientation); } |
132 NonCJKGlyphOrientation nonCJKGlyphOrientation() const { return static_cast<N
onCJKGlyphOrientation>(m_nonCJKGlyphOrientation); } | 131 NonCJKGlyphOrientation nonCJKGlyphOrientation() const { return static_cast<N
onCJKGlyphOrientation>(m_nonCJKGlyphOrientation); } |
133 FontWidthVariant widthVariant() const { return static_cast<FontWidthVariant>
(m_widthVariant); } | 132 FontWidthVariant widthVariant() const { return static_cast<FontWidthVariant>
(m_widthVariant); } |
134 FontFeatureSettings* featureSettings() const { return m_featureSettings.get(
); } | 133 FontFeatureSettings* featureSettings() const { return m_featureSettings.get(
); } |
135 FontDescription makeNormalFeatureSettings() const; | 134 FontDescription makeNormalFeatureSettings() const; |
136 | 135 |
137 void setFamily(const FontFamily& family) { m_familyList = family; } | 136 void setFamily(const FontFamily& family) { m_familyList = family; } |
(...skipping 15 matching lines...) Expand all Loading... |
153 void setCommonLigaturesState(LigaturesState commonLigaturesState) { m_common
LigaturesState = commonLigaturesState; } | 152 void setCommonLigaturesState(LigaturesState commonLigaturesState) { m_common
LigaturesState = commonLigaturesState; } |
154 void setDiscretionaryLigaturesState(LigaturesState discretionaryLigaturesSta
te) { m_discretionaryLigaturesState = discretionaryLigaturesState; } | 153 void setDiscretionaryLigaturesState(LigaturesState discretionaryLigaturesSta
te) { m_discretionaryLigaturesState = discretionaryLigaturesState; } |
155 void setHistoricalLigaturesState(LigaturesState historicalLigaturesState) {
m_historicalLigaturesState = historicalLigaturesState; } | 154 void setHistoricalLigaturesState(LigaturesState historicalLigaturesState) {
m_historicalLigaturesState = historicalLigaturesState; } |
156 void setKeywordSize(unsigned s) { m_keywordSize = s; } | 155 void setKeywordSize(unsigned s) { m_keywordSize = s; } |
157 void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoot
hing; } | 156 void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoot
hing; } |
158 void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = r
endering; } | 157 void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = r
endering; } |
159 void setIsSpecifiedFont(bool isSpecifiedFont) { m_isSpecifiedFont = isSpecif
iedFont; } | 158 void setIsSpecifiedFont(bool isSpecifiedFont) { m_isSpecifiedFont = isSpecif
iedFont; } |
160 void setOrientation(FontOrientation orientation) { m_orientation = orientati
on; } | 159 void setOrientation(FontOrientation orientation) { m_orientation = orientati
on; } |
161 void setNonCJKGlyphOrientation(NonCJKGlyphOrientation orientation) { m_nonCJ
KGlyphOrientation = orientation; } | 160 void setNonCJKGlyphOrientation(NonCJKGlyphOrientation orientation) { m_nonCJ
KGlyphOrientation = orientation; } |
162 void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = width
Variant; } | 161 void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = width
Variant; } |
163 void setScript(UScriptCode s) { m_script = s; } | 162 void setLocale(const AtomicString& locale) { m_locale = locale; } |
164 void setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) { m_featur
eSettings = settings; } | 163 void setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) { m_featur
eSettings = settings; } |
165 | 164 |
166 private: | 165 private: |
167 FontFamily m_familyList; // The list of font families to be used. | 166 FontFamily m_familyList; // The list of font families to be used. |
168 RefPtr<FontFeatureSettings> m_featureSettings; | 167 RefPtr<FontFeatureSettings> m_featureSettings; |
169 | 168 |
| 169 AtomicString m_locale; // Used to help choose an appropriate font for font f
amilies based on the DOM locale. |
| 170 |
170 float m_specifiedSize; // Specified CSS value. Independent of rendering is
sues such as integer | 171 float m_specifiedSize; // Specified CSS value. Independent of rendering is
sues such as integer |
171 // rounding, minimum font sizes, and zooming. | 172 // rounding, minimum font sizes, and zooming. |
172 float m_computedSize; // Computed size adjusted for the minimum font size
and the zoom factor. | 173 float m_computedSize; // Computed size adjusted for the minimum font size
and the zoom factor. |
173 | 174 |
174 unsigned m_orientation : 1; // FontOrientation - Whether the font is renderi
ng on a horizontal line or a vertical line. | 175 unsigned m_orientation : 1; // FontOrientation - Whether the font is renderi
ng on a horizontal line or a vertical line. |
175 unsigned m_nonCJKGlyphOrientation : 1; // NonCJKGlyphOrientation - Only used
by vertical text. Determines the default orientation for non-ideograph glyphs. | 176 unsigned m_nonCJKGlyphOrientation : 1; // NonCJKGlyphOrientation - Only used
by vertical text. Determines the default orientation for non-ideograph glyphs. |
176 | 177 |
177 unsigned m_widthVariant : 2; // FontWidthVariant | 178 unsigned m_widthVariant : 2; // FontWidthVariant |
178 | 179 |
179 unsigned m_italic : 1; // FontItalic | 180 unsigned m_italic : 1; // FontItalic |
180 unsigned m_smallCaps : 1; // FontSmallCaps | 181 unsigned m_smallCaps : 1; // FontSmallCaps |
181 unsigned m_isAbsoluteSize : 1; // Whether or not CSS specified an explicit s
ize | 182 unsigned m_isAbsoluteSize : 1; // Whether or not CSS specified an explicit s
ize |
182 // (logical sizes like "medium" don't count). | 183 // (logical sizes like "medium" don't count). |
183 unsigned m_weight : 8; // FontWeight | 184 unsigned m_weight : 4; // FontWeight |
184 unsigned m_genericFamily : 3; // GenericFamilyType | 185 unsigned m_genericFamily : 3; // GenericFamilyType |
185 unsigned m_usePrinterFont : 1; | 186 unsigned m_usePrinterFont : 1; |
186 | 187 |
187 unsigned m_kerning : 2; // Kerning | 188 unsigned m_kerning : 2; // Kerning |
188 | 189 |
189 unsigned m_commonLigaturesState : 2; | 190 unsigned m_commonLigaturesState : 2; |
190 unsigned m_discretionaryLigaturesState : 2; | 191 unsigned m_discretionaryLigaturesState : 2; |
191 unsigned m_historicalLigaturesState : 2; | 192 unsigned m_historicalLigaturesState : 2; |
192 | 193 |
193 unsigned m_keywordSize : 4; // We cache whether or not a font is currently r
epresented by a CSS keyword (e.g., medium). If so, | 194 unsigned m_keywordSize : 4; // We cache whether or not a font is currently r
epresented by a CSS keyword (e.g., medium). If so, |
194 // then we can accurately translate across different
generic families to adjust for different preference settings | 195 // then we can accurately translate across different
generic families to adjust for different preference settings |
195 // (e.g., 13px monospace vs. 16px everything else).
Sizes are 1-8 (like the HTML size values for <font>). | 196 // (e.g., 13px monospace vs. 16px everything else).
Sizes are 1-8 (like the HTML size values for <font>). |
196 | 197 |
197 unsigned m_fontSmoothing : 2; // FontSmoothingMode | 198 unsigned m_fontSmoothing : 2; // FontSmoothingMode |
198 unsigned m_textRendering : 2; // TextRenderingMode | 199 unsigned m_textRendering : 2; // TextRenderingMode |
199 unsigned m_isSpecifiedFont : 1; // True if a web page specifies a non-generi
c font family as the first font family. | 200 unsigned m_isSpecifiedFont : 1; // True if a web page specifies a non-generi
c font family as the first font family. |
200 unsigned m_script : 7; // Used to help choose an appropriate font for generi
c font families. | |
201 }; | 201 }; |
202 | 202 |
203 inline bool FontDescription::operator==(const FontDescription& other) const | 203 inline bool FontDescription::operator==(const FontDescription& other) const |
204 { | 204 { |
205 return m_familyList == other.m_familyList | 205 return m_familyList == other.m_familyList |
206 && m_specifiedSize == other.m_specifiedSize | 206 && m_specifiedSize == other.m_specifiedSize |
207 && m_computedSize == other.m_computedSize | 207 && m_computedSize == other.m_computedSize |
208 && m_italic == other.m_italic | 208 && m_italic == other.m_italic |
209 && m_smallCaps == other.m_smallCaps | 209 && m_smallCaps == other.m_smallCaps |
210 && m_isAbsoluteSize == other.m_isAbsoluteSize | 210 && m_isAbsoluteSize == other.m_isAbsoluteSize |
211 && m_weight == other.m_weight | 211 && m_weight == other.m_weight |
212 && m_genericFamily == other.m_genericFamily | 212 && m_genericFamily == other.m_genericFamily |
213 && m_usePrinterFont == other.m_usePrinterFont | 213 && m_usePrinterFont == other.m_usePrinterFont |
214 && m_kerning == other.m_kerning | 214 && m_kerning == other.m_kerning |
215 && m_commonLigaturesState == other.m_commonLigaturesState | 215 && m_commonLigaturesState == other.m_commonLigaturesState |
216 && m_discretionaryLigaturesState == other.m_discretionaryLigaturesState | 216 && m_discretionaryLigaturesState == other.m_discretionaryLigaturesState |
217 && m_historicalLigaturesState == other.m_historicalLigaturesState | 217 && m_historicalLigaturesState == other.m_historicalLigaturesState |
218 && m_keywordSize == other.m_keywordSize | 218 && m_keywordSize == other.m_keywordSize |
219 && m_fontSmoothing == other.m_fontSmoothing | 219 && m_fontSmoothing == other.m_fontSmoothing |
220 && m_textRendering == other.m_textRendering | 220 && m_textRendering == other.m_textRendering |
221 && m_isSpecifiedFont == other.m_isSpecifiedFont | 221 && m_isSpecifiedFont == other.m_isSpecifiedFont |
222 && m_orientation == other.m_orientation | 222 && m_orientation == other.m_orientation |
223 && m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation | 223 && m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation |
224 && m_widthVariant == other.m_widthVariant | 224 && m_widthVariant == other.m_widthVariant |
225 && m_script == other.m_script | 225 && m_locale == other.m_locale |
226 && m_featureSettings == other.m_featureSettings; | 226 && m_featureSettings == other.m_featureSettings; |
227 } | 227 } |
228 | 228 |
229 } | 229 } |
230 | 230 |
231 #endif | 231 #endif |
OLD | NEW |