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

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

Issue 476943003: Implement support for CSS font-stretch on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « LayoutTests/fast/text/font-stretch.html ('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, 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 #endif 161 #endif
162 162
163 ASSERT(fontPlatformData); 163 ASSERT(fontPlatformData);
164 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain); 164 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain);
165 } 165 }
166 166
167 #if OS(WIN) 167 #if OS(WIN)
168 static inline SkFontStyle fontStyle(const FontDescription& fontDescription) 168 static inline SkFontStyle fontStyle(const FontDescription& fontDescription)
169 { 169 {
170 int width = SkFontStyle::kNormal_Width; 170 int width = static_cast<int>(fontDescription.stretch());
171 int weight = (fontDescription.weight() - FontWeight100 + 1) * 100; 171 int weight = (fontDescription.weight() - FontWeight100 + 1) * 100;
172 SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic 172 SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic
173 ? SkFontStyle::kItalic_Slant 173 ? SkFontStyle::kItalic_Slant
174 : SkFontStyle::kUpright_Slant; 174 : SkFontStyle::kUpright_Slant;
175 return SkFontStyle(weight, width, slant); 175 return SkFontStyle(weight, width, slant);
176 } 176 }
177
178 COMPILE_ASSERT(FontStretchUltraCondensed == SkFontStyle::kUltraCondensed_Width,
179 FontStretchUltraCondensedMapsTokUltraCondensed_Width);
180 COMPILE_ASSERT(FontStretchNormal == SkFontStyle::kNormal_Width,
181 FontStretchNormalMapsTokNormal_Width);
182 COMPILE_ASSERT(FontStretchUltraExpanded == SkFontStyle::kUltaExpanded_Width,
183 FontStretchUltraExpandedMapsTokUltaExpanded_Width);
177 #endif 184 #endif
178 185
179 PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc ription, const FontFaceCreationParams& creationParams, CString& name) 186 PassRefPtr<SkTypeface> FontCache::createTypeface(const FontDescription& fontDesc ription, const FontFaceCreationParams& creationParams, CString& name)
180 { 187 {
181 #if !OS(WIN) && !OS(ANDROID) 188 #if !OS(WIN) && !OS(ANDROID)
182 if (creationParams.creationType() == CreateFontByFciIdAndTtcIndex) { 189 if (creationParams.creationType() == CreateFontByFciIdAndTtcIndex) {
183 // TODO(dro): crbug.com/381620 Use creationParams.ttcIndex() after 190 // TODO(dro): crbug.com/381620 Use creationParams.ttcIndex() after
184 // https://code.google.com/p/skia/issues/detail?id=1186 gets fixed. 191 // https://code.google.com/p/skia/issues/detail?id=1186 gets fixed.
185 SkTypeface* typeface = nullptr; 192 SkTypeface* typeface = nullptr;
186 if (Platform::current()->sandboxSupport()) 193 if (Platform::current()->sandboxSupport())
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 fontSize, 252 fontSize,
246 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(), 253 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(),
247 (fontDescription.style() && !tf->isItalic()) || fontDescription.isSynthe ticItalic(), 254 (fontDescription.style() && !tf->isItalic()) || fontDescription.isSynthe ticItalic(),
248 fontDescription.orientation(), 255 fontDescription.orientation(),
249 fontDescription.useSubpixelPositioning()); 256 fontDescription.useSubpixelPositioning());
250 return result; 257 return result;
251 } 258 }
252 #endif // !OS(WIN) 259 #endif // !OS(WIN)
253 260
254 } // namespace blink 261 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/font-stretch.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698