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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.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
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/FontCache.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Computer, Inc. 2 * Copyright (C) 2006, 2007 Apple Computer, Inc.
3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. 3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google 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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 CString name; 340 CString name;
341 sk_sp<SkTypeface> tf = createTypeface(fontDescription, creationParams, name); 341 sk_sp<SkTypeface> tf = createTypeface(fontDescription, creationParams, name);
342 // Windows will always give us a valid pointer here, even if the face name 342 // Windows will always give us a valid pointer here, even if the face name
343 // is non-existent. We have to double-check and see if the family name was 343 // is non-existent. We have to double-check and see if the family name was
344 // really used. 344 // really used.
345 if (!tf || !typefacesMatchesFamily(tf.get(), creationParams.family())) { 345 if (!tf || !typefacesMatchesFamily(tf.get(), creationParams.family())) {
346 AtomicString adjustedName; 346 AtomicString adjustedName;
347 FontWeight variantWeight; 347 FontWeight variantWeight;
348 FontStretch variantStretch; 348 FontStretch variantStretch;
349 349
350 // TODO: crbug.com/627143 LocalFontFaceSource.cpp, which implements
351 // retrieving src: local() font data uses getFontData, which in turn comes
352 // here, to retrieve fonts from the cache and specifies the argument to
353 // local() as family name. So we do not match by full font name or
354 // postscript name as the spec says:
355 // https://drafts.csswg.org/css-fonts-3/#src-desc
356
357 // Prevent one side effect of the suffix translation below where when
358 // matching local("Roboto Regular") it tries to find the closest match even
359 // though that can be a bold font in case of Roboto Bold.
360 if (alternateFontName == AlternateFontName::LocalUniqueFace) {
361 return nullptr;
362 }
363
350 if (alternateFontName == AlternateFontName::LastResort) { 364 if (alternateFontName == AlternateFontName::LastResort) {
351 if (!tf) 365 if (!tf)
352 return nullptr; 366 return nullptr;
353 } else if (typefacesHasWeightSuffix(creationParams.family(), adjustedName, 367 } else if (typefacesHasWeightSuffix(creationParams.family(), adjustedName,
354 variantWeight)) { 368 variantWeight)) {
355 FontFaceCreationParams adjustedParams(adjustedName); 369 FontFaceCreationParams adjustedParams(adjustedName);
356 FontDescription adjustedFontDescription = fontDescription; 370 FontDescription adjustedFontDescription = fontDescription;
357 adjustedFontDescription.setWeight(variantWeight); 371 adjustedFontDescription.setWeight(variantWeight);
358 tf = createTypeface(adjustedFontDescription, adjustedParams, name); 372 tf = createTypeface(adjustedFontDescription, adjustedParams, name);
359 if (!tf || !typefacesMatchesFamily(tf.get(), adjustedName)) 373 if (!tf || !typefacesMatchesFamily(tf.get(), adjustedName))
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if (typefacesMatchesFamily(tf.get(), family)) { 432 if (typefacesMatchesFamily(tf.get(), family)) {
419 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); 433 result->setMinSizeForSubpixel(minSizeForSubpixelForFont);
420 break; 434 break;
421 } 435 }
422 } 436 }
423 437
424 return result; 438 return result;
425 } 439 }
426 440
427 } // namespace blink 441 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/FontCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698