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

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

Issue 2737533002: Replace subpixel font size heuristics with using OpenType gasp table (Closed)
Patch Set: No subpixel without smoothing, not even for layout tests 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, 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // warrant an additional (real coverage) check with fontCotainsCharacter. 201 // warrant an additional (real coverage) check with fontCotainsCharacter.
202 int i; 202 int i;
203 for (i = 0; 203 for (i = 0;
204 (!data || !data->fontContainsCharacter(character)) && i < numFonts; 204 (!data || !data->fontContainsCharacter(character)) && i < numFonts;
205 ++i) { 205 ++i) {
206 family = panUniFonts[i]; 206 family = panUniFonts[i];
207 FontFaceCreationParams createByFamily(AtomicString(family, wcslen(family))); 207 FontFaceCreationParams createByFamily(AtomicString(family, wcslen(family)));
208 data = getFontPlatformData(fontDescription, createByFamily); 208 data = getFontPlatformData(fontDescription, createByFamily);
209 } 209 }
210 210
211 // For font fallback we want to match the subpixel behavior of the original
212 // font. Mixing subpixel and non-subpixel in the same text run looks really
213 // odd and causes problems with preferred width calculations.
214 if (data && originalFontData) {
215 const FontPlatformData& platformData = originalFontData->platformData();
216 data->setMinSizeForAntiAlias(platformData.minSizeForAntiAlias());
217 data->setMinSizeForSubpixel(platformData.minSizeForSubpixel());
218 }
219
220 // When i-th font (0-base) in |panUniFonts| contains a character and 211 // When i-th font (0-base) in |panUniFonts| contains a character and
221 // we get out of the loop, |i| will be |i + 1|. That is, if only the 212 // we get out of the loop, |i| will be |i + 1|. That is, if only the
222 // last font in the array covers the character, |i| will be numFonts. 213 // last font in the array covers the character, |i| will be numFonts.
223 // So, we have to use '<=" rather than '<' to see if we found a font 214 // So, we have to use '<=" rather than '<' to see if we found a font
224 // covering the character. 215 // covering the character.
225 if (i <= numFonts) 216 if (i <= numFonts)
226 return fontDataFromFontPlatformData(data, DoNotRetain); 217 return fontDataFromFontPlatformData(data, DoNotRetain);
227 218
228 return nullptr; 219 return nullptr;
229 } 220 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 WTF::wrapUnique(new FontPlatformData( 382 WTF::wrapUnique(new FontPlatformData(
392 tf, name.data(), fontSize, 383 tf, name.data(), fontSize,
393 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || 384 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) ||
394 fontDescription.isSyntheticBold(), 385 fontDescription.isSyntheticBold(),
395 ((fontDescription.style() == FontStyleItalic || 386 ((fontDescription.style() == FontStyleItalic ||
396 fontDescription.style() == FontStyleOblique) && 387 fontDescription.style() == FontStyleOblique) &&
397 !tf->isItalic()) || 388 !tf->isItalic()) ||
398 fontDescription.isSyntheticItalic(), 389 fontDescription.isSyntheticItalic(),
399 fontDescription.orientation())); 390 fontDescription.orientation()));
400 391
401 struct FamilyMinSize {
402 const wchar_t* family;
403 unsigned minSize;
404 };
405 const static FamilyMinSize minAntiAliasSizeForFont[] = {
406 {L"simsun", 11},
407 {L"dotum", 12},
408 {L"gulim", 12},
409 {L"pmingliu", 11},
410 {L"pmingliu-extb", 11}};
411 size_t numFonts = WTF_ARRAY_LENGTH(minAntiAliasSizeForFont);
412 for (size_t i = 0; i < numFonts; i++) {
413 FamilyMinSize entry = minAntiAliasSizeForFont[i];
414 if (typefacesMatchesFamily(tf.get(), entry.family)) {
415 result->setMinSizeForAntiAlias(entry.minSize);
416 break;
417 }
418 }
419
420 // List of fonts that look bad with subpixel text rendering at smaller font
421 // sizes. This includes all fonts in the Microsoft Core fonts for the Web
422 // collection.
423 const static wchar_t* noSubpixelForSmallSizeFont[] = {
424 L"andale mono", L"arial", L"comic sans", L"courier new",
425 L"dotum", L"georgia", L"impact", L"lucida console",
426 L"tahoma", L"times new roman", L"trebuchet ms", L"verdana",
427 L"webdings"};
428 const static float minSizeForSubpixelForFont = 16.0f;
429 numFonts = WTF_ARRAY_LENGTH(noSubpixelForSmallSizeFont);
430 for (size_t i = 0; i < numFonts; i++) {
431 const wchar_t* family = noSubpixelForSmallSizeFont[i];
432 if (typefacesMatchesFamily(tf.get(), family)) {
433 result->setMinSizeForSubpixel(minSizeForSubpixelForFont);
434 break;
435 }
436 }
437
438 return result; 392 return result;
439 } 393 }
440 394
441 } // namespace blink 395 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698