| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void FontDescription::setVariantLigatures(const VariantLigatures& ligatures) | 154 void FontDescription::setVariantLigatures(const VariantLigatures& ligatures) |
| 155 { | 155 { |
| 156 m_fields.m_commonLigaturesState = ligatures.common; | 156 m_fields.m_commonLigaturesState = ligatures.common; |
| 157 m_fields.m_discretionaryLigaturesState = ligatures.discretionary; | 157 m_fields.m_discretionaryLigaturesState = ligatures.discretionary; |
| 158 m_fields.m_historicalLigaturesState = ligatures.historical; | 158 m_fields.m_historicalLigaturesState = ligatures.historical; |
| 159 m_fields.m_contextualLigaturesState = ligatures.contextual; | 159 m_fields.m_contextualLigaturesState = ligatures.contextual; |
| 160 | 160 |
| 161 updateTypesettingFeatures(); | 161 updateTypesettingFeatures(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void FontDescription::setVariantNumeric(const FontVariantNumeric& variantNumeric
) |
| 165 { |
| 166 m_fields.m_variantNumeric = variantNumeric.m_fieldsAsUnsigned; |
| 167 |
| 168 updateTypesettingFeatures(); |
| 169 } |
| 170 |
| 164 float FontDescription::effectiveFontSize() const | 171 float FontDescription::effectiveFontSize() const |
| 165 { | 172 { |
| 166 // Ensure that the effective precision matches the font-cache precision. | 173 // Ensure that the effective precision matches the font-cache precision. |
| 167 // This guarantees that the same precision is used regardless of cache statu
s. | 174 // This guarantees that the same precision is used regardless of cache statu
s. |
| 168 float computedOrAdjustedSize = hasSizeAdjust() ? adjustedSize() : computedSi
ze(); | 175 float computedOrAdjustedSize = hasSizeAdjust() ? adjustedSize() : computedSi
ze(); |
| 169 return floorf(computedOrAdjustedSize * FontCacheKey::precisionMultiplier())
/ FontCacheKey::precisionMultiplier(); | 176 return floorf(computedOrAdjustedSize * FontCacheKey::precisionMultiplier())
/ FontCacheKey::precisionMultiplier(); |
| 170 } | 177 } |
| 171 | 178 |
| 172 FontCacheKey FontDescription::cacheKey(const FontFaceCreationParams& creationPar
ams, FontTraits desiredTraits) const | 179 FontCacheKey FontDescription::cacheKey(const FontFaceCreationParams& creationPar
ams, FontTraits desiredTraits) const |
| 173 { | 180 { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 for (unsigned i = 0; i < m_locale.length(); i++) | 281 for (unsigned i = 0; i < m_locale.length(); i++) |
| 275 stringHasher.addCharacter(m_locale[i]); | 282 stringHasher.addCharacter(m_locale[i]); |
| 276 addToHash(hash, stringHasher.hash()); | 283 addToHash(hash, stringHasher.hash()); |
| 277 | 284 |
| 278 addFloatToHash(hash, m_specifiedSize); | 285 addFloatToHash(hash, m_specifiedSize); |
| 279 addFloatToHash(hash, m_computedSize); | 286 addFloatToHash(hash, m_computedSize); |
| 280 addFloatToHash(hash, m_adjustedSize); | 287 addFloatToHash(hash, m_adjustedSize); |
| 281 addFloatToHash(hash, m_sizeAdjust); | 288 addFloatToHash(hash, m_sizeAdjust); |
| 282 addFloatToHash(hash, m_letterSpacing); | 289 addFloatToHash(hash, m_letterSpacing); |
| 283 addFloatToHash(hash, m_wordSpacing); | 290 addFloatToHash(hash, m_wordSpacing); |
| 284 addToHash(hash, m_fieldsAsUnsigned[0]); | 291 addToHash(hash, m_fieldsAsUnsigned.parts[0]); |
| 285 addToHash(hash, m_fieldsAsUnsigned[1]); | 292 addToHash(hash, m_fieldsAsUnsigned.parts[1]); |
| 286 | 293 |
| 287 return hash; | 294 return hash; |
| 288 } | 295 } |
| 289 | 296 |
| 290 SkFontStyle FontDescription::skiaFontStyle() const | 297 SkFontStyle FontDescription::skiaFontStyle() const |
| 291 { | 298 { |
| 292 int width = static_cast<int>(stretch()); | 299 int width = static_cast<int>(stretch()); |
| 293 SkFontStyle::Slant slant = SkFontStyle::kUpright_Slant; | 300 SkFontStyle::Slant slant = SkFontStyle::kUpright_Slant; |
| 294 switch (style()) { | 301 switch (style()) { |
| 295 case FontStyleNormal: slant = SkFontStyle::kUpright_Slant; break; | 302 case FontStyleNormal: slant = SkFontStyle::kUpright_Slant; break; |
| 296 case FontStyleItalic: slant = SkFontStyle::kItalic_Slant; break; | 303 case FontStyleItalic: slant = SkFontStyle::kItalic_Slant; break; |
| 297 case FontStyleOblique: slant = SkFontStyle::kOblique_Slant; break; | 304 case FontStyleOblique: slant = SkFontStyle::kOblique_Slant; break; |
| 298 default: NOTREACHED(); break; | 305 default: NOTREACHED(); break; |
| 299 } | 306 } |
| 300 return SkFontStyle(numericFontWeight(weight()), width, slant); | 307 return SkFontStyle(numericFontWeight(weight()), width, slant); |
| 301 static_assert( | 308 static_assert( |
| 302 static_cast<int>(FontStretchUltraCondensed) == static_cast<int>(SkFontSt
yle::kUltraCondensed_Width), | 309 static_cast<int>(FontStretchUltraCondensed) == static_cast<int>(SkFontSt
yle::kUltraCondensed_Width), |
| 303 "FontStretchUltraCondensed should map to kUltraCondensed_Width"); | 310 "FontStretchUltraCondensed should map to kUltraCondensed_Width"); |
| 304 static_assert( | 311 static_assert( |
| 305 static_cast<int>(FontStretchNormal) == static_cast<int>(SkFontStyle::kNo
rmal_Width), | 312 static_cast<int>(FontStretchNormal) == static_cast<int>(SkFontStyle::kNo
rmal_Width), |
| 306 "FontStretchNormal should map to kNormal_Width"); | 313 "FontStretchNormal should map to kNormal_Width"); |
| 307 static_assert( | 314 static_assert( |
| 308 static_cast<int>(FontStretchUltraExpanded) == static_cast<int>(SkFontSty
le::kUltaExpanded_Width), | 315 static_cast<int>(FontStretchUltraExpanded) == static_cast<int>(SkFontSty
le::kUltaExpanded_Width), |
| 309 "FontStretchUltraExpanded should map to kUltaExpanded_Width"); | 316 "FontStretchUltraExpanded should map to kUltaExpanded_Width"); |
| 310 } | 317 } |
| 311 | 318 |
| 312 } // namespace blink | 319 } // namespace blink |
| OLD | NEW |