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 12 matching lines...) Expand all Loading... | |
23 */ | 23 */ |
24 | 24 |
25 #ifndef FontDescription_h | 25 #ifndef FontDescription_h |
26 #define FontDescription_h | 26 #define FontDescription_h |
27 | 27 |
28 #include "SkFontStyle.h" | 28 #include "SkFontStyle.h" |
29 #include "platform/FontFamilyNames.h" | 29 #include "platform/FontFamilyNames.h" |
30 #include "platform/fonts/FontCacheKey.h" | 30 #include "platform/fonts/FontCacheKey.h" |
31 #include "platform/fonts/FontFamily.h" | 31 #include "platform/fonts/FontFamily.h" |
32 #include "platform/fonts/FontFeatureSettings.h" | 32 #include "platform/fonts/FontFeatureSettings.h" |
33 #include "platform/fonts/FontLocale.h" | |
33 #include "platform/fonts/FontOrientation.h" | 34 #include "platform/fonts/FontOrientation.h" |
34 #include "platform/fonts/FontSmoothingMode.h" | 35 #include "platform/fonts/FontSmoothingMode.h" |
35 #include "platform/fonts/FontTraits.h" | 36 #include "platform/fonts/FontTraits.h" |
36 #include "platform/fonts/FontVariantNumeric.h" | 37 #include "platform/fonts/FontVariantNumeric.h" |
37 #include "platform/fonts/FontWidthVariant.h" | 38 #include "platform/fonts/FontWidthVariant.h" |
38 #include "platform/fonts/TextRenderingMode.h" | 39 #include "platform/fonts/TextRenderingMode.h" |
39 #include "platform/fonts/TypesettingFeatures.h" | 40 #include "platform/fonts/TypesettingFeatures.h" |
40 #include "platform/text/LocaleToScriptMapping.h" | |
41 #include "wtf/Allocator.h" | 41 #include "wtf/Allocator.h" |
42 #include "wtf/MathExtras.h" | 42 #include "wtf/MathExtras.h" |
43 | 43 |
44 #include "wtf/RefPtr.h" | 44 #include "wtf/RefPtr.h" |
45 | 45 |
46 #include <unicode/uscript.h> | 46 #include <unicode/uscript.h> |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 | 49 |
50 const float FontSizeAdjustNone = -1; | 50 const float FontSizeAdjustNone = -1; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 m_fields.m_stretch = FontStretchNormal; | 83 m_fields.m_stretch = FontStretchNormal; |
84 m_fields.m_genericFamily = NoFamily; | 84 m_fields.m_genericFamily = NoFamily; |
85 m_fields.m_kerning = AutoKerning; | 85 m_fields.m_kerning = AutoKerning; |
86 m_fields.m_commonLigaturesState = NormalLigaturesState; | 86 m_fields.m_commonLigaturesState = NormalLigaturesState; |
87 m_fields.m_discretionaryLigaturesState = NormalLigaturesState; | 87 m_fields.m_discretionaryLigaturesState = NormalLigaturesState; |
88 m_fields.m_historicalLigaturesState = NormalLigaturesState; | 88 m_fields.m_historicalLigaturesState = NormalLigaturesState; |
89 m_fields.m_contextualLigaturesState = NormalLigaturesState; | 89 m_fields.m_contextualLigaturesState = NormalLigaturesState; |
90 m_fields.m_keywordSize = 0; | 90 m_fields.m_keywordSize = 0; |
91 m_fields.m_fontSmoothing = AutoSmoothing; | 91 m_fields.m_fontSmoothing = AutoSmoothing; |
92 m_fields.m_textRendering = AutoTextRendering; | 92 m_fields.m_textRendering = AutoTextRendering; |
93 m_fields.m_script = USCRIPT_COMMON; | |
94 m_fields.m_syntheticBold = false; | 93 m_fields.m_syntheticBold = false; |
95 m_fields.m_syntheticItalic = false; | 94 m_fields.m_syntheticItalic = false; |
96 m_fields.m_subpixelTextPosition = s_useSubpixelTextPositioning; | 95 m_fields.m_subpixelTextPosition = s_useSubpixelTextPositioning; |
97 m_fields.m_typesettingFeatures = s_defaultTypesettingFeatures; | 96 m_fields.m_typesettingFeatures = s_defaultTypesettingFeatures; |
98 m_fields.m_variantNumeric = FontVariantNumeric().m_fieldsAsUnsigned; | 97 m_fields.m_variantNumeric = FontVariantNumeric().m_fieldsAsUnsigned; |
99 } | 98 } |
100 | 99 |
101 bool operator==(const FontDescription&) const; | 100 bool operator==(const FontDescription&) const; |
102 bool operator!=(const FontDescription& other) const { return !(*this == othe r); } | 101 bool operator!=(const FontDescription& other) const { return !(*this == othe r); } |
103 | 102 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 Kerning getKerning() const { return static_cast<Kerning>(m_fields.m_kerning) ; } | 170 Kerning getKerning() const { return static_cast<Kerning>(m_fields.m_kerning) ; } |
172 VariantLigatures getVariantLigatures() const; | 171 VariantLigatures getVariantLigatures() const; |
173 FontVariantNumeric variantNumeric() const { return FontVariantNumeric::init ializeFromUnsigned(m_fields.m_variantNumeric); }; | 172 FontVariantNumeric variantNumeric() const { return FontVariantNumeric::init ializeFromUnsigned(m_fields.m_variantNumeric); }; |
174 LigaturesState commonLigaturesState() const { return static_cast<LigaturesSt ate>(m_fields.m_commonLigaturesState); } | 173 LigaturesState commonLigaturesState() const { return static_cast<LigaturesSt ate>(m_fields.m_commonLigaturesState); } |
175 LigaturesState discretionaryLigaturesState() const { return static_cast<Liga turesState>(m_fields.m_discretionaryLigaturesState); } | 174 LigaturesState discretionaryLigaturesState() const { return static_cast<Liga turesState>(m_fields.m_discretionaryLigaturesState); } |
176 LigaturesState historicalLigaturesState() const { return static_cast<Ligatur esState>(m_fields.m_historicalLigaturesState); } | 175 LigaturesState historicalLigaturesState() const { return static_cast<Ligatur esState>(m_fields.m_historicalLigaturesState); } |
177 LigaturesState contextualLigaturesState() const { return static_cast<Ligatur esState>(m_fields.m_contextualLigaturesState); } | 176 LigaturesState contextualLigaturesState() const { return static_cast<Ligatur esState>(m_fields.m_contextualLigaturesState); } |
178 unsigned keywordSize() const { return m_fields.m_keywordSize; } | 177 unsigned keywordSize() const { return m_fields.m_keywordSize; } |
179 FontSmoothingMode fontSmoothing() const { return static_cast<FontSmoothingMo de>(m_fields.m_fontSmoothing); } | 178 FontSmoothingMode fontSmoothing() const { return static_cast<FontSmoothingMo de>(m_fields.m_fontSmoothing); } |
180 TextRenderingMode textRendering() const { return static_cast<TextRenderingMo de>(m_fields.m_textRendering); } | 179 TextRenderingMode textRendering() const { return static_cast<TextRenderingMo de>(m_fields.m_textRendering); } |
181 UScriptCode script() const { return static_cast<UScriptCode>(m_fields.m_scri pt); } | 180 const FontLocale& localeOrDefault() const { return m_locale ? *m_locale : Fo ntLocale::getDefault(); } |
182 const AtomicString& locale(bool includeDefault = true) const; | 181 const FontLocale* locale() const { return m_locale.get(); } |
drott
2016/07/19 15:28:53
Perhaps we can reduce this to one method on FontDe
kojii
2016/07/20 06:01:53
Thanks, that's a good idea, added static methods a
drott
2016/07/21 09:23:49
Sounds good to me.
| |
182 const AtomicString& localeString() const { return m_locale ? m_locale->local eString() : nullAtom; } | |
183 UScriptCode script() const { return localeOrDefault().script(); } | |
183 bool isSyntheticBold() const { return m_fields.m_syntheticBold; } | 184 bool isSyntheticBold() const { return m_fields.m_syntheticBold; } |
184 bool isSyntheticItalic() const { return m_fields.m_syntheticItalic; } | 185 bool isSyntheticItalic() const { return m_fields.m_syntheticItalic; } |
185 bool useSubpixelPositioning() const { return m_fields.m_subpixelTextPosition ; } | 186 bool useSubpixelPositioning() const { return m_fields.m_subpixelTextPosition ; } |
186 | 187 |
187 FontTraits traits() const; | 188 FontTraits traits() const; |
188 float wordSpacing() const { return m_wordSpacing; } | 189 float wordSpacing() const { return m_wordSpacing; } |
189 float letterSpacing() const { return m_letterSpacing; } | 190 float letterSpacing() const { return m_letterSpacing; } |
190 FontOrientation orientation() const { return static_cast<FontOrientation>(m_ fields.m_orientation); } | 191 FontOrientation orientation() const { return static_cast<FontOrientation>(m_ fields.m_orientation); } |
191 bool isVerticalAnyUpright() const { return blink::isVerticalAnyUpright(orien tation()); } | 192 bool isVerticalAnyUpright() const { return blink::isVerticalAnyUpright(orien tation()); } |
192 bool isVerticalNonCJKUpright() const { return blink::isVerticalNonCJKUpright (orientation()); } | 193 bool isVerticalNonCJKUpright() const { return blink::isVerticalNonCJKUpright (orientation()); } |
(...skipping 17 matching lines...) Expand all Loading... | |
210 void setIsAbsoluteSize(bool s) { m_fields.m_isAbsoluteSize = s; } | 211 void setIsAbsoluteSize(bool s) { m_fields.m_isAbsoluteSize = s; } |
211 void setWeight(FontWeight w) { m_fields.m_weight = w; } | 212 void setWeight(FontWeight w) { m_fields.m_weight = w; } |
212 void setStretch(FontStretch s) { m_fields.m_stretch = s; } | 213 void setStretch(FontStretch s) { m_fields.m_stretch = s; } |
213 void setGenericFamily(GenericFamilyType genericFamily) { m_fields.m_genericF amily = genericFamily; } | 214 void setGenericFamily(GenericFamilyType genericFamily) { m_fields.m_genericF amily = genericFamily; } |
214 void setKerning(Kerning kerning) { m_fields.m_kerning = kerning; updateTypes ettingFeatures(); } | 215 void setKerning(Kerning kerning) { m_fields.m_kerning = kerning; updateTypes ettingFeatures(); } |
215 void setKeywordSize(unsigned s) { m_fields.m_keywordSize = s; } | 216 void setKeywordSize(unsigned s) { m_fields.m_keywordSize = s; } |
216 void setFontSmoothing(FontSmoothingMode smoothing) { m_fields.m_fontSmoothin g = smoothing; } | 217 void setFontSmoothing(FontSmoothingMode smoothing) { m_fields.m_fontSmoothin g = smoothing; } |
217 void setTextRendering(TextRenderingMode rendering) { m_fields.m_textRenderin g = rendering; updateTypesettingFeatures(); } | 218 void setTextRendering(TextRenderingMode rendering) { m_fields.m_textRenderin g = rendering; updateTypesettingFeatures(); } |
218 void setOrientation(FontOrientation orientation) { m_fields.m_orientation = static_cast<unsigned>(orientation); } | 219 void setOrientation(FontOrientation orientation) { m_fields.m_orientation = static_cast<unsigned>(orientation); } |
219 void setWidthVariant(FontWidthVariant widthVariant) { m_fields.m_widthVarian t = widthVariant; } | 220 void setWidthVariant(FontWidthVariant widthVariant) { m_fields.m_widthVarian t = widthVariant; } |
220 void setLocale(const AtomicString& locale) | 221 void setLocale(PassRefPtr<const FontLocale> locale) { m_locale = locale; } |
221 { | |
222 m_locale = locale; | |
223 m_fields.m_script = localeToScriptCodeForFontSelection(locale); | |
drott
2016/07/19 15:28:53
Good to see this going away.
| |
224 } | |
225 void setSyntheticBold(bool syntheticBold) { m_fields.m_syntheticBold = synth eticBold; } | 222 void setSyntheticBold(bool syntheticBold) { m_fields.m_syntheticBold = synth eticBold; } |
226 void setSyntheticItalic(bool syntheticItalic) { m_fields.m_syntheticItalic = syntheticItalic; } | 223 void setSyntheticItalic(bool syntheticItalic) { m_fields.m_syntheticItalic = syntheticItalic; } |
227 void setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) { m_featur eSettings = settings; } | 224 void setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) { m_featur eSettings = settings; } |
228 void setTraits(FontTraits); | 225 void setTraits(FontTraits); |
229 void setWordSpacing(float s) { m_wordSpacing = s; } | 226 void setWordSpacing(float s) { m_wordSpacing = s; } |
230 void setLetterSpacing(float s) { m_letterSpacing = s; updateTypesettingFeatu res(); } | 227 void setLetterSpacing(float s) { m_letterSpacing = s; updateTypesettingFeatu res(); } |
231 | 228 |
232 TypesettingFeatures getTypesettingFeatures() const { return static_cast<Type settingFeatures>(m_fields.m_typesettingFeatures); } | 229 TypesettingFeatures getTypesettingFeatures() const { return static_cast<Type settingFeatures>(m_fields.m_typesettingFeatures); } |
233 | 230 |
234 static void setSubpixelPositioning(bool b) { s_useSubpixelTextPositioning = b; } | 231 static void setSubpixelPositioning(bool b) { s_useSubpixelTextPositioning = b; } |
235 static bool subpixelPositioning() { return s_useSubpixelTextPositioning; } | 232 static bool subpixelPositioning() { return s_useSubpixelTextPositioning; } |
236 | 233 |
237 static void setDefaultTypesettingFeatures(TypesettingFeatures); | 234 static void setDefaultTypesettingFeatures(TypesettingFeatures); |
238 static TypesettingFeatures defaultTypesettingFeatures(); | 235 static TypesettingFeatures defaultTypesettingFeatures(); |
239 | 236 |
240 unsigned styleHashWithoutFamilyList() const; | 237 unsigned styleHashWithoutFamilyList() const; |
241 // TODO(drott): We should not expose internal structure here, but rather int roduce | 238 // TODO(drott): We should not expose internal structure here, but rather int roduce |
242 // a hash function here. | 239 // a hash function here. |
243 unsigned bitmapFields() const { return m_fieldsAsUnsigned.parts[0]; } | 240 unsigned bitmapFields() const { return m_fieldsAsUnsigned.parts[0]; } |
244 unsigned auxiliaryBitmapFields() const { return m_fieldsAsUnsigned.parts[1]; } | 241 unsigned auxiliaryBitmapFields() const { return m_fieldsAsUnsigned.parts[1]; } |
245 | 242 |
246 SkFontStyle skiaFontStyle() const; | 243 SkFontStyle skiaFontStyle() const; |
247 | 244 |
248 private: | 245 private: |
249 FontFamily m_familyList; // The list of font families to be used. | 246 FontFamily m_familyList; // The list of font families to be used. |
250 RefPtr<FontFeatureSettings> m_featureSettings; | 247 RefPtr<FontFeatureSettings> m_featureSettings; |
251 AtomicString m_locale; | 248 RefPtr<const FontLocale> m_locale; |
252 | 249 |
253 void updateTypesettingFeatures(); | 250 void updateTypesettingFeatures(); |
254 | 251 |
255 float m_specifiedSize; // Specified CSS value. Independent of rendering is sues such as integer | 252 float m_specifiedSize; // Specified CSS value. Independent of rendering is sues such as integer |
256 // rounding, minimum font sizes, and zooming. | 253 // rounding, minimum font sizes, and zooming. |
257 float m_computedSize; // Computed size adjusted for the minimum font size and the zoom factor. | 254 float m_computedSize; // Computed size adjusted for the minimum font size and the zoom factor. |
258 | 255 |
259 // (Given aspect value / aspect value of a font family) * specifiedSize. | 256 // (Given aspect value / aspect value of a font family) * specifiedSize. |
260 // This value is adjusted for the minimum font size and the zoom factor | 257 // This value is adjusted for the minimum font size and the zoom factor |
261 // as well as a computed size is. | 258 // as well as a computed size is. |
(...skipping 25 matching lines...) Expand all Loading... | |
287 unsigned m_discretionaryLigaturesState : 2; | 284 unsigned m_discretionaryLigaturesState : 2; |
288 unsigned m_historicalLigaturesState : 2; | 285 unsigned m_historicalLigaturesState : 2; |
289 unsigned m_contextualLigaturesState : 2; | 286 unsigned m_contextualLigaturesState : 2; |
290 | 287 |
291 unsigned m_keywordSize : 4; // We cache whether or not a font is current ly represented by a CSS keyword (e.g., medium). If so, | 288 unsigned m_keywordSize : 4; // We cache whether or not a font is current ly represented by a CSS keyword (e.g., medium). If so, |
292 // then we can accurately translate across different generic families to adjust for different preference settings | 289 // then we can accurately translate across different generic families to adjust for different preference settings |
293 // (e.g., 13px monospace vs. 16px everything else). Sizes are 1-8 (like the HTML size values for <font>). | 290 // (e.g., 13px monospace vs. 16px everything else). Sizes are 1-8 (like the HTML size values for <font>). |
294 | 291 |
295 unsigned m_fontSmoothing : 2; // FontSmoothingMode | 292 unsigned m_fontSmoothing : 2; // FontSmoothingMode |
296 unsigned m_textRendering : 2; // TextRenderingMode | 293 unsigned m_textRendering : 2; // TextRenderingMode |
297 unsigned m_script : 7; // Used to help choose an appropriate font for ge neric font families. | |
298 unsigned m_syntheticBold : 1; | 294 unsigned m_syntheticBold : 1; |
299 unsigned m_syntheticItalic : 1; | 295 unsigned m_syntheticItalic : 1; |
300 unsigned m_subpixelTextPosition : 1; | 296 unsigned m_subpixelTextPosition : 1; |
301 unsigned m_typesettingFeatures : 3; | 297 unsigned m_typesettingFeatures : 3; |
302 unsigned m_variantNumeric : 8; | 298 unsigned m_variantNumeric : 8; |
303 }; | 299 }; |
304 | 300 |
305 static_assert(sizeof(BitFields) == sizeof(FieldsAsUnsignedType), | 301 static_assert(sizeof(BitFields) == sizeof(FieldsAsUnsignedType), |
306 "Mapped bitfield datatypes must have identical size."); | 302 "Mapped bitfield datatypes must have identical size."); |
307 union { | 303 union { |
(...skipping 17 matching lines...) Expand all Loading... | |
325 && m_letterSpacing == other.m_letterSpacing | 321 && m_letterSpacing == other.m_letterSpacing |
326 && m_wordSpacing == other.m_wordSpacing | 322 && m_wordSpacing == other.m_wordSpacing |
327 && m_fieldsAsUnsigned.parts[0] == other.m_fieldsAsUnsigned.parts[0] | 323 && m_fieldsAsUnsigned.parts[0] == other.m_fieldsAsUnsigned.parts[0] |
328 && m_fieldsAsUnsigned.parts[1] == other.m_fieldsAsUnsigned.parts[1] | 324 && m_fieldsAsUnsigned.parts[1] == other.m_fieldsAsUnsigned.parts[1] |
329 && (m_featureSettings == other.m_featureSettings || (m_featureSettings & & other.m_featureSettings && *m_featureSettings == *other.m_featureSettings)); | 325 && (m_featureSettings == other.m_featureSettings || (m_featureSettings & & other.m_featureSettings && *m_featureSettings == *other.m_featureSettings)); |
330 } | 326 } |
331 | 327 |
332 } // namespace blink | 328 } // namespace blink |
333 | 329 |
334 #endif | 330 #endif |
OLD | NEW |