OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com> | 2 * Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com> |
3 * Copyright (C) 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "wtf/text/StringHash.h" | 35 #include "wtf/text/StringHash.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 struct SameSizeAsFontDescription { | 39 struct SameSizeAsFontDescription { |
40 DISALLOW_NEW(); | 40 DISALLOW_NEW(); |
41 FontFamily familyList; | 41 FontFamily familyList; |
42 RefPtr<FontFeatureSettings> m_featureSettings; | 42 RefPtr<FontFeatureSettings> m_featureSettings; |
43 AtomicString locale; | 43 AtomicString locale; |
44 float sizes[6]; | 44 float sizes[6]; |
45 uint32_t bitfields[2]; | 45 FieldsAsUnsignedType bitfields; |
46 }; | 46 }; |
47 | 47 |
48 static_assert(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), "Fon
tDescription should stay small"); | 48 static_assert(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), "Fon
tDescription should stay small"); |
49 | 49 |
50 TypesettingFeatures FontDescription::s_defaultTypesettingFeatures = 0; | 50 TypesettingFeatures FontDescription::s_defaultTypesettingFeatures = 0; |
51 | 51 |
52 bool FontDescription::s_useSubpixelTextPositioning = false; | 52 bool FontDescription::s_useSubpixelTextPositioning = false; |
53 | 53 |
54 FontWeight FontDescription::lighterWeight(FontWeight weight) | 54 FontWeight FontDescription::lighterWeight(FontWeight weight) |
55 { | 55 { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 void FontDescription::setVariantLigatures(const VariantLigatures& ligatures) | 147 void FontDescription::setVariantLigatures(const VariantLigatures& ligatures) |
148 { | 148 { |
149 m_fields.m_commonLigaturesState = ligatures.common; | 149 m_fields.m_commonLigaturesState = ligatures.common; |
150 m_fields.m_discretionaryLigaturesState = ligatures.discretionary; | 150 m_fields.m_discretionaryLigaturesState = ligatures.discretionary; |
151 m_fields.m_historicalLigaturesState = ligatures.historical; | 151 m_fields.m_historicalLigaturesState = ligatures.historical; |
152 m_fields.m_contextualLigaturesState = ligatures.contextual; | 152 m_fields.m_contextualLigaturesState = ligatures.contextual; |
153 | 153 |
154 updateTypesettingFeatures(); | 154 updateTypesettingFeatures(); |
155 } | 155 } |
156 | 156 |
| 157 void FontDescription::setVariantNumeric(const FontVariantNumeric& variantNumeric
) |
| 158 { |
| 159 m_fields.m_variantNumeric = variantNumeric.m_fieldsAsUnsigned; |
| 160 |
| 161 updateTypesettingFeatures(); |
| 162 } |
| 163 |
157 float FontDescription::effectiveFontSize() const | 164 float FontDescription::effectiveFontSize() const |
158 { | 165 { |
159 // Ensure that the effective precision matches the font-cache precision. | 166 // Ensure that the effective precision matches the font-cache precision. |
160 // This guarantees that the same precision is used regardless of cache statu
s. | 167 // This guarantees that the same precision is used regardless of cache statu
s. |
161 float computedOrAdjustedSize = hasSizeAdjust() ? adjustedSize() : computedSi
ze(); | 168 float computedOrAdjustedSize = hasSizeAdjust() ? adjustedSize() : computedSi
ze(); |
162 return floorf(computedOrAdjustedSize * FontCacheKey::precisionMultiplier())
/ FontCacheKey::precisionMultiplier(); | 169 return floorf(computedOrAdjustedSize * FontCacheKey::precisionMultiplier())
/ FontCacheKey::precisionMultiplier(); |
163 } | 170 } |
164 | 171 |
165 FontCacheKey FontDescription::cacheKey(const FontFaceCreationParams& creationPar
ams, FontTraits desiredTraits) const | 172 FontCacheKey FontDescription::cacheKey(const FontFaceCreationParams& creationPar
ams, FontTraits desiredTraits) const |
166 { | 173 { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 for (unsigned i = 0; i < m_locale.length(); i++) | 271 for (unsigned i = 0; i < m_locale.length(); i++) |
265 stringHasher.addCharacter(m_locale[i]); | 272 stringHasher.addCharacter(m_locale[i]); |
266 addToHash(hash, stringHasher.hash()); | 273 addToHash(hash, stringHasher.hash()); |
267 | 274 |
268 addFloatToHash(hash, m_specifiedSize); | 275 addFloatToHash(hash, m_specifiedSize); |
269 addFloatToHash(hash, m_computedSize); | 276 addFloatToHash(hash, m_computedSize); |
270 addFloatToHash(hash, m_adjustedSize); | 277 addFloatToHash(hash, m_adjustedSize); |
271 addFloatToHash(hash, m_sizeAdjust); | 278 addFloatToHash(hash, m_sizeAdjust); |
272 addFloatToHash(hash, m_letterSpacing); | 279 addFloatToHash(hash, m_letterSpacing); |
273 addFloatToHash(hash, m_wordSpacing); | 280 addFloatToHash(hash, m_wordSpacing); |
274 addToHash(hash, m_fieldsAsUnsigned[0]); | 281 addToHash(hash, m_fieldsAsUnsigned.f[0]); |
275 addToHash(hash, m_fieldsAsUnsigned[1]); | 282 addToHash(hash, m_fieldsAsUnsigned.f[1]); |
276 | 283 |
277 return hash; | 284 return hash; |
278 } | 285 } |
279 | 286 |
280 SkFontStyle FontDescription::skiaFontStyle() const | 287 SkFontStyle FontDescription::skiaFontStyle() const |
281 { | 288 { |
282 int width = static_cast<int>(stretch()); | 289 int width = static_cast<int>(stretch()); |
283 SkFontStyle::Slant slant = SkFontStyle::kUpright_Slant; | 290 SkFontStyle::Slant slant = SkFontStyle::kUpright_Slant; |
284 switch (style()) { | 291 switch (style()) { |
285 case FontStyleNormal: slant = SkFontStyle::kUpright_Slant; break; | 292 case FontStyleNormal: slant = SkFontStyle::kUpright_Slant; break; |
286 case FontStyleItalic: slant = SkFontStyle::kItalic_Slant; break; | 293 case FontStyleItalic: slant = SkFontStyle::kItalic_Slant; break; |
287 case FontStyleOblique: slant = SkFontStyle::kOblique_Slant; break; | 294 case FontStyleOblique: slant = SkFontStyle::kOblique_Slant; break; |
288 default: NOTREACHED(); break; | 295 default: NOTREACHED(); break; |
289 } | 296 } |
290 return SkFontStyle(numericFontWeight(weight()), width, slant); | 297 return SkFontStyle(numericFontWeight(weight()), width, slant); |
291 static_assert( | 298 static_assert( |
292 static_cast<int>(FontStretchUltraCondensed) == static_cast<int>(SkFontSt
yle::kUltraCondensed_Width), | 299 static_cast<int>(FontStretchUltraCondensed) == static_cast<int>(SkFontSt
yle::kUltraCondensed_Width), |
293 "FontStretchUltraCondensed should map to kUltraCondensed_Width"); | 300 "FontStretchUltraCondensed should map to kUltraCondensed_Width"); |
294 static_assert( | 301 static_assert( |
295 static_cast<int>(FontStretchNormal) == static_cast<int>(SkFontStyle::kNo
rmal_Width), | 302 static_cast<int>(FontStretchNormal) == static_cast<int>(SkFontStyle::kNo
rmal_Width), |
296 "FontStretchNormal should map to kNormal_Width"); | 303 "FontStretchNormal should map to kNormal_Width"); |
297 static_assert( | 304 static_assert( |
298 static_cast<int>(FontStretchUltraExpanded) == static_cast<int>(SkFontSty
le::kUltaExpanded_Width), | 305 static_cast<int>(FontStretchUltraExpanded) == static_cast<int>(SkFontSty
le::kUltaExpanded_Width), |
299 "FontStretchUltraExpanded should map to kUltaExpanded_Width"); | 306 "FontStretchUltraExpanded should map to kUltaExpanded_Width"); |
300 } | 307 } |
301 | 308 |
302 } // namespace blink | 309 } // namespace blink |
OLD | NEW |