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

Side by Side Diff: Source/platform/fonts/skia/FontCacheSkia.cpp

Issue 1270723002: Improve CSS Style matching spec compliance (Closed) Base URL: git@github.com:drott/blink-crosswalk.git@reimplementMatching
Patch Set: Fix TestExpectations Created 5 years, 4 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, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 { 69 {
70 FontDescription substituteDescription(fontDescription); 70 FontDescription substituteDescription(fontDescription);
71 substituteDescription.setStyle(FontStyleNormal); 71 substituteDescription.setStyle(FontStyleNormal);
72 substituteDescription.setWeight(FontWeightNormal); 72 substituteDescription.setWeight(FontWeightNormal);
73 73
74 FontFaceCreationParams creationParams(substituteDescription.family().family( )); 74 FontFaceCreationParams creationParams(substituteDescription.family().family( ));
75 FontPlatformData* substitutePlatformData = getFontPlatformData(substituteDes cription, creationParams); 75 FontPlatformData* substitutePlatformData = getFontPlatformData(substituteDes cription, creationParams);
76 if (substitutePlatformData && substitutePlatformData->fontContainsCharacter( character)) { 76 if (substitutePlatformData && substitutePlatformData->fontContainsCharacter( character)) {
77 FontPlatformData platformData = FontPlatformData(*substitutePlatformData ); 77 FontPlatformData platformData = FontPlatformData(*substitutePlatformData );
78 platformData.setSyntheticBold(fontDescription.weight() >= FontWeight600) ; 78 platformData.setSyntheticBold(fontDescription.weight() >= FontWeight600) ;
79 platformData.setSyntheticItalic(fontDescription.style() == FontStyleItal ic); 79 platformData.setSyntheticItalic(fontDescription.style() == FontStyleItal ic || fontDescription.style() == FontStyleOblique);
80 return fontDataFromFontPlatformData(&platformData, DoNotRetain); 80 return fontDataFromFontPlatformData(&platformData, DoNotRetain);
81 } 81 }
82 82
83 return nullptr; 83 return nullptr;
84 } 84 }
85 85
86 #if !OS(WIN) && !OS(ANDROID) 86 #if !OS(WIN) && !OS(ANDROID)
87 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip tion& fontDescription, UChar32 c, const SimpleFontData*) 87 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip tion& fontDescription, UChar32 c, const SimpleFontData*)
88 { 88 {
89 // First try the specified font with standard style & weight. 89 // First try the specified font with standard style & weight.
(...skipping 20 matching lines...) Expand all
110 bool shouldSetSyntheticItalic = false; 110 bool shouldSetSyntheticItalic = false;
111 FontDescription description(fontDescription); 111 FontDescription description(fontDescription);
112 if (fallbackFont.isBold && description.weight() < FontWeightBold) 112 if (fallbackFont.isBold && description.weight() < FontWeightBold)
113 description.setWeight(FontWeightBold); 113 description.setWeight(FontWeightBold);
114 if (!fallbackFont.isBold && description.weight() >= FontWeightBold) { 114 if (!fallbackFont.isBold && description.weight() >= FontWeightBold) {
115 shouldSetSyntheticBold = true; 115 shouldSetSyntheticBold = true;
116 description.setWeight(FontWeightNormal); 116 description.setWeight(FontWeightNormal);
117 } 117 }
118 if (fallbackFont.isItalic && description.style() == FontStyleNormal) 118 if (fallbackFont.isItalic && description.style() == FontStyleNormal)
119 description.setStyle(FontStyleItalic); 119 description.setStyle(FontStyleItalic);
120 if (!fallbackFont.isItalic && description.style() == FontStyleItalic) { 120 if (!fallbackFont.isItalic && (description.style() == FontStyleItalic || des cription.style() == FontStyleOblique)) {
121 shouldSetSyntheticItalic = true; 121 shouldSetSyntheticItalic = true;
122 description.setStyle(FontStyleNormal); 122 description.setStyle(FontStyleNormal);
123 } 123 }
124 124
125 FontPlatformData* substitutePlatformData = getFontPlatformData(description, creationParams); 125 FontPlatformData* substitutePlatformData = getFontPlatformData(description, creationParams);
126 if (!substitutePlatformData) 126 if (!substitutePlatformData)
127 return nullptr; 127 return nullptr;
128 FontPlatformData platformData = FontPlatformData(*substitutePlatformData); 128 FontPlatformData platformData = FontPlatformData(*substitutePlatformData);
129 platformData.setSyntheticBold(shouldSetSyntheticBold); 129 platformData.setSyntheticBold(shouldSetSyntheticBold);
130 platformData.setSyntheticItalic(shouldSetSyntheticItalic); 130 platformData.setSyntheticItalic(shouldSetSyntheticItalic);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 { 241 {
242 CString name; 242 CString name;
243 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ; 243 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ;
244 if (!tf) 244 if (!tf)
245 return 0; 245 return 0;
246 246
247 FontPlatformData* result = new FontPlatformData(tf, 247 FontPlatformData* result = new FontPlatformData(tf,
248 name.data(), 248 name.data(),
249 fontSize, 249 fontSize,
250 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(), 250 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(),
251 (fontDescription.style() && !tf->isItalic()) || fontDescription.isSynthe ticItalic(), 251 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(),
252 fontDescription.orientation(), 252 fontDescription.orientation(),
253 fontDescription.useSubpixelPositioning()); 253 fontDescription.useSubpixelPositioning());
254 return result; 254 return result;
255 } 255 }
256 #endif // !OS(WIN) 256 #endif // !OS(WIN)
257 257
258 } // namespace blink 258 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698