Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/FontDescription.cpp

Issue 2581083003: Initial OpenType Font Variations Support (Closed)
Patch Set: Fix hash collision tests, adjust test expectations Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 FontTraits fontTraits = desiredTraits.bitfield() ? desiredTraits : traits(); 217 FontTraits fontTraits = desiredTraits.bitfield() ? desiredTraits : traits();
218 218
219 unsigned options = 219 unsigned options =
220 static_cast<unsigned>(m_fields.m_syntheticItalic) << 6 | // bit 7 220 static_cast<unsigned>(m_fields.m_syntheticItalic) << 6 | // bit 7
221 static_cast<unsigned>(m_fields.m_syntheticBold) << 5 | // bit 6 221 static_cast<unsigned>(m_fields.m_syntheticBold) << 5 | // bit 6
222 static_cast<unsigned>(m_fields.m_textRendering) << 3 | // bits 4-5 222 static_cast<unsigned>(m_fields.m_textRendering) << 3 | // bits 4-5
223 static_cast<unsigned>(m_fields.m_orientation) << 1 | // bit 2-3 223 static_cast<unsigned>(m_fields.m_orientation) << 1 | // bit 2-3
224 static_cast<unsigned>(m_fields.m_subpixelTextPosition); // bit 1 224 static_cast<unsigned>(m_fields.m_subpixelTextPosition); // bit 1
225 225
226 return FontCacheKey(creationParams, effectiveFontSize(), 226 return FontCacheKey(creationParams, effectiveFontSize(),
227 options | fontTraits.bitfield() << 8); 227 options | fontTraits.bitfield() << 8,
228 m_variationSettings);
228 } 229 }
229 230
230 void FontDescription::setDefaultTypesettingFeatures( 231 void FontDescription::setDefaultTypesettingFeatures(
231 TypesettingFeatures typesettingFeatures) { 232 TypesettingFeatures typesettingFeatures) {
232 s_defaultTypesettingFeatures = typesettingFeatures; 233 s_defaultTypesettingFeatures = typesettingFeatures;
233 } 234 }
234 235
235 TypesettingFeatures FontDescription::defaultTypesettingFeatures() { 236 TypesettingFeatures FontDescription::defaultTypesettingFeatures() {
236 return s_defaultTypesettingFeatures; 237 return s_defaultTypesettingFeatures;
237 } 238 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 const FontFeatureSettings* settings = featureSettings(); 305 const FontFeatureSettings* settings = featureSettings();
305 if (settings) { 306 if (settings) {
306 unsigned numFeatures = settings->size(); 307 unsigned numFeatures = settings->size();
307 for (unsigned i = 0; i < numFeatures; ++i) { 308 for (unsigned i = 0; i < numFeatures; ++i) {
308 const AtomicString& tag = settings->at(i).tag(); 309 const AtomicString& tag = settings->at(i).tag();
309 for (unsigned j = 0; j < tag.length(); j++) 310 for (unsigned j = 0; j < tag.length(); j++)
310 stringHasher.addCharacter(tag[j]); 311 stringHasher.addCharacter(tag[j]);
311 addToHash(hash, settings->at(i).value()); 312 addToHash(hash, settings->at(i).value());
312 } 313 }
313 } 314 }
314 const FontVariationSettings* varSettings = variationSettings(); 315
315 if (varSettings) { 316 if (variationSettings())
316 unsigned numFeatures = varSettings->size(); 317 addToHash(hash, variationSettings()->hash());
317 for (unsigned i = 0; i < numFeatures; ++i) {
318 const AtomicString& tag = varSettings->at(i).tag();
319 for (unsigned j = 0; j < tag.length(); j++)
320 stringHasher.addCharacter(tag[j]);
321 addToHash(hash, varSettings->at(i).value());
322 }
323 }
324 318
325 if (m_locale) { 319 if (m_locale) {
326 const AtomicString& locale = m_locale->localeString(); 320 const AtomicString& locale = m_locale->localeString();
327 for (unsigned i = 0; i < locale.length(); i++) 321 for (unsigned i = 0; i < locale.length(); i++)
328 stringHasher.addCharacter(locale[i]); 322 stringHasher.addCharacter(locale[i]);
329 } 323 }
330 addToHash(hash, stringHasher.hash()); 324 addToHash(hash, stringHasher.hash());
331 325
332 addFloatToHash(hash, m_specifiedSize); 326 addFloatToHash(hash, m_specifiedSize);
333 addFloatToHash(hash, m_computedSize); 327 addFloatToHash(hash, m_computedSize);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 "FontStretchUltraCondensed should map to kUltraCondensed_Width"); 359 "FontStretchUltraCondensed should map to kUltraCondensed_Width");
366 static_assert(static_cast<int>(FontStretchNormal) == 360 static_assert(static_cast<int>(FontStretchNormal) ==
367 static_cast<int>(SkFontStyle::kNormal_Width), 361 static_cast<int>(SkFontStyle::kNormal_Width),
368 "FontStretchNormal should map to kNormal_Width"); 362 "FontStretchNormal should map to kNormal_Width");
369 static_assert(static_cast<int>(FontStretchUltraExpanded) == 363 static_assert(static_cast<int>(FontStretchUltraExpanded) ==
370 static_cast<int>(SkFontStyle::kUltraExpanded_Width), 364 static_cast<int>(SkFontStyle::kUltraExpanded_Width),
371 "FontStretchUltraExpanded should map to kUltraExpanded_Width"); 365 "FontStretchUltraExpanded should map to kUltraExpanded_Width");
372 } 366 }
373 367
374 } // namespace blink 368 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698