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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 VariantLigatures ligatures; | 116 VariantLigatures ligatures; |
117 | 117 |
118 ligatures.common = commonLigaturesState(); | 118 ligatures.common = commonLigaturesState(); |
119 ligatures.discretionary = discretionaryLigaturesState(); | 119 ligatures.discretionary = discretionaryLigaturesState(); |
120 ligatures.historical = historicalLigaturesState(); | 120 ligatures.historical = historicalLigaturesState(); |
121 ligatures.contextual = contextualLigaturesState(); | 121 ligatures.contextual = contextualLigaturesState(); |
122 | 122 |
123 return ligatures; | 123 return ligatures; |
124 } | 124 } |
125 | 125 |
126 static const AtomicString& defaultLocale() | |
127 { | |
128 DEFINE_STATIC_LOCAL(AtomicString, locale, ()); | |
129 if (locale.isNull()) { | |
130 AtomicString defaultLocale = defaultLanguage(); | |
131 if (!defaultLocale.isEmpty()) | |
132 locale = defaultLocale; | |
133 else | |
134 locale = AtomicString("en"); | |
135 } | |
136 return locale; | |
137 } | |
138 | |
139 const AtomicString& FontDescription::locale(bool includeDefault) const | |
140 { | |
141 if (m_locale.isNull() && includeDefault) | |
142 return defaultLocale(); | |
143 return m_locale; | |
144 } | |
145 | |
146 void FontDescription::setTraits(FontTraits traits) | 126 void FontDescription::setTraits(FontTraits traits) |
147 { | 127 { |
148 setStyle(traits.style()); | 128 setStyle(traits.style()); |
149 setWeight(traits.weight()); | 129 setWeight(traits.weight()); |
150 setStretch(traits.stretch()); | 130 setStretch(traits.stretch()); |
151 } | 131 } |
152 | 132 |
153 void FontDescription::setVariantCaps(FontVariantCaps variantCaps) | 133 void FontDescription::setVariantCaps(FontVariantCaps variantCaps) |
154 { | 134 { |
155 m_fields.m_variantCaps = variantCaps; | 135 m_fields.m_variantCaps = variantCaps; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 const FontFeatureSettings* settings = featureSettings(); | 257 const FontFeatureSettings* settings = featureSettings(); |
278 if (settings) { | 258 if (settings) { |
279 unsigned numFeatures = settings->size(); | 259 unsigned numFeatures = settings->size(); |
280 for (unsigned i = 0; i < numFeatures; ++i) { | 260 for (unsigned i = 0; i < numFeatures; ++i) { |
281 const AtomicString& tag = settings->at(i).tag(); | 261 const AtomicString& tag = settings->at(i).tag(); |
282 for (unsigned j = 0; j < tag.length(); j++) | 262 for (unsigned j = 0; j < tag.length(); j++) |
283 stringHasher.addCharacter(tag[j]); | 263 stringHasher.addCharacter(tag[j]); |
284 addToHash(hash, settings->at(i).value()); | 264 addToHash(hash, settings->at(i).value()); |
285 } | 265 } |
286 } | 266 } |
287 for (unsigned i = 0; i < m_locale.length(); i++) | 267 if (m_locale) { |
288 stringHasher.addCharacter(m_locale[i]); | 268 const AtomicString& locale = m_locale->localeString(); |
| 269 for (unsigned i = 0; i < locale.length(); i++) |
| 270 stringHasher.addCharacter(locale[i]); |
| 271 } |
289 addToHash(hash, stringHasher.hash()); | 272 addToHash(hash, stringHasher.hash()); |
290 | 273 |
291 addFloatToHash(hash, m_specifiedSize); | 274 addFloatToHash(hash, m_specifiedSize); |
292 addFloatToHash(hash, m_computedSize); | 275 addFloatToHash(hash, m_computedSize); |
293 addFloatToHash(hash, m_adjustedSize); | 276 addFloatToHash(hash, m_adjustedSize); |
294 addFloatToHash(hash, m_sizeAdjust); | 277 addFloatToHash(hash, m_sizeAdjust); |
295 addFloatToHash(hash, m_letterSpacing); | 278 addFloatToHash(hash, m_letterSpacing); |
296 addFloatToHash(hash, m_wordSpacing); | 279 addFloatToHash(hash, m_wordSpacing); |
297 addToHash(hash, m_fieldsAsUnsigned.parts[0]); | 280 addToHash(hash, m_fieldsAsUnsigned.parts[0]); |
298 addToHash(hash, m_fieldsAsUnsigned.parts[1]); | 281 addToHash(hash, m_fieldsAsUnsigned.parts[1]); |
(...skipping 17 matching lines...) Expand all Loading... |
316 "FontStretchUltraCondensed should map to kUltraCondensed_Width"); | 299 "FontStretchUltraCondensed should map to kUltraCondensed_Width"); |
317 static_assert( | 300 static_assert( |
318 static_cast<int>(FontStretchNormal) == static_cast<int>(SkFontStyle::kNo
rmal_Width), | 301 static_cast<int>(FontStretchNormal) == static_cast<int>(SkFontStyle::kNo
rmal_Width), |
319 "FontStretchNormal should map to kNormal_Width"); | 302 "FontStretchNormal should map to kNormal_Width"); |
320 static_assert( | 303 static_assert( |
321 static_cast<int>(FontStretchUltraExpanded) == static_cast<int>(SkFontSty
le::kUltaExpanded_Width), | 304 static_cast<int>(FontStretchUltraExpanded) == static_cast<int>(SkFontSty
le::kUltaExpanded_Width), |
322 "FontStretchUltraExpanded should map to kUltaExpanded_Width"); | 305 "FontStretchUltraExpanded should map to kUltaExpanded_Width"); |
323 } | 306 } |
324 | 307 |
325 } // namespace blink | 308 } // namespace blink |
OLD | NEW |