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

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

Issue 2721613002: Fix matching Roboto Bold for src: local("Roboto Regular") (Closed)
Patch Set: Fix test case for Mac Created 3 years, 9 months 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) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } else if (anotherSize) { 165 } else if (anotherSize) {
166 *found = scaleFontPlatformData(*anotherSize, fontDescription, 166 *found = scaleFontPlatformData(*anotherSize, fontDescription,
167 creationParams, size); 167 creationParams, size);
168 } 168 }
169 } 169 }
170 170
171 result = found->get(); 171 result = found->get();
172 foundResult = result || !addResult.isNewEntry; 172 foundResult = result || !addResult.isNewEntry;
173 } 173 }
174 174
175 if (!foundResult && alternateFontName != AlternateFontName::NoAlternate && 175 if (!foundResult && alternateFontName == AlternateFontName::AllowAlternate &&
176 creationParams.creationType() == CreateFontByFamily) { 176 creationParams.creationType() == CreateFontByFamily) {
177 // We were unable to find a font. We have a small set of fonts that we alias 177 // We were unable to find a font. We have a small set of fonts that we alias
178 // to other names, e.g., Arial/Helvetica, Courier/Courier New, etc. Try 178 // to other names, e.g., Arial/Helvetica, Courier/Courier New, etc. Try
179 // looking up the font under the aliased name. 179 // looking up the font under the aliased name.
180 const AtomicString& alternateName = 180 const AtomicString& alternateName =
181 alternateFamilyName(creationParams.family()); 181 alternateFamilyName(creationParams.family());
182 if (!alternateName.isEmpty()) { 182 if (!alternateName.isEmpty()) {
183 FontFaceCreationParams createByAlternateFamily(alternateName); 183 FontFaceCreationParams createByAlternateFamily(alternateName);
184 result = getFontPlatformData(fontDescription, createByAlternateFamily, 184 result = getFontPlatformData(fontDescription, createByAlternateFamily,
185 AlternateFontName::NoAlternate); 185 AlternateFontName::NoAlternate);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 gFontDataCache = new FontDataCache; 289 gFontDataCache = new FontDataCache;
290 290
291 #if DCHECK_IS_ON() 291 #if DCHECK_IS_ON()
292 if (shouldRetain == DoNotRetain) 292 if (shouldRetain == DoNotRetain)
293 ASSERT(m_purgePreventCount); 293 ASSERT(m_purgePreventCount);
294 #endif 294 #endif
295 295
296 return gFontDataCache->get(platformData, shouldRetain, subpixelAscentDescent); 296 return gFontDataCache->get(platformData, shouldRetain, subpixelAscentDescent);
297 } 297 }
298 298
299 bool FontCache::isPlatformFontAvailable(const FontDescription& fontDescription, 299 bool FontCache::isPlatformFamilyMatchAvailable(
300 const AtomicString& family) { 300 const FontDescription& fontDescription,
301 const AtomicString& family) {
301 return getFontPlatformData( 302 return getFontPlatformData(
302 fontDescription, 303 fontDescription,
303 FontFaceCreationParams(adjustFamilyNameToAvoidUnsupportedFonts(family)), 304 FontFaceCreationParams(adjustFamilyNameToAvoidUnsupportedFonts(family)),
304 AlternateFontName::NoAlternate); 305 AlternateFontName::NoAlternate);
305 } 306 }
306 307
308 bool FontCache::isPlatformFontUniqueNameMatchAvailable(
309 const FontDescription& fontDescription,
310 const AtomicString& uniqueFontName) {
311 return getFontPlatformData(fontDescription,
312 FontFaceCreationParams(uniqueFontName),
313 AlternateFontName::LocalUniqueFace);
314 }
315
307 String FontCache::firstAvailableOrFirst(const String& families) { 316 String FontCache::firstAvailableOrFirst(const String& families) {
308 // The conversions involve at least two string copies, and more if non-ASCII. 317 // The conversions involve at least two string copies, and more if non-ASCII.
309 // For now we prefer shared code over the cost because a) inputs are 318 // For now we prefer shared code over the cost because a) inputs are
310 // only from grd/xtb and all ASCII, and b) at most only a few times per 319 // only from grd/xtb and all ASCII, and b) at most only a few times per
311 // setting change/script. 320 // setting change/script.
312 return String::fromUTF8( 321 return String::fromUTF8(
313 gfx::FontList::FirstAvailableOrFirst(families.utf8().data()).c_str()); 322 gfx::FontList::FirstAvailableOrFirst(families.utf8().data()).c_str());
314 } 323 }
315 324
316 SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont( 325 SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont(
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 for (iter = gFallbackListShaperCache->begin(); 502 for (iter = gFallbackListShaperCache->begin();
494 iter != gFallbackListShaperCache->end(); ++iter) { 503 iter != gFallbackListShaperCache->end(); ++iter) {
495 shapeResultCacheSize += iter->value->byteSize(); 504 shapeResultCacheSize += iter->value->byteSize();
496 } 505 }
497 dump->AddScalar("size", "bytes", shapeResultCacheSize); 506 dump->AddScalar("size", "bytes", shapeResultCacheSize);
498 memoryDump->AddSuballocation(dump->guid(), 507 memoryDump->AddSuballocation(dump->guid(),
499 WTF::Partitions::kAllocatedObjectPoolName); 508 WTF::Partitions::kAllocatedObjectPoolName);
500 } 509 }
501 510
502 } // namespace blink 511 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698