Index: third_party/WebKit/Source/platform/fonts/FontDescription.cpp |
diff --git a/third_party/WebKit/Source/platform/fonts/FontDescription.cpp b/third_party/WebKit/Source/platform/fonts/FontDescription.cpp |
index 2008681e0ccd0973e5bae08faa3d38b697a41d62..0b221694ef79984a4ac34d938a60b6a846d30be9 100644 |
--- a/third_party/WebKit/Source/platform/fonts/FontDescription.cpp |
+++ b/third_party/WebKit/Source/platform/fonts/FontDescription.cpp |
@@ -278,4 +278,20 @@ unsigned FontDescription::styleHashWithoutFamilyList() const |
return hash; |
} |
+SkFontStyle FontDescription::skiaFontStyle() const |
+{ |
+ int width = static_cast<int>(stretch()); |
+ int fontWeight = (weight() - FontWeight100 + 1) * 100; |
eae
2016/02/29 23:11:26
We might want to add a helper for this. numericFon
Ilya Kulshin
2016/03/01 03:31:14
Done. Added a helper, although perhaps the actual
|
+ SkFontStyle::Slant slant = style() == FontStyleItalic |
+ ? SkFontStyle::kItalic_Slant |
+ : SkFontStyle::kUpright_Slant; |
+ return SkFontStyle(fontWeight, width, slant); |
+ static_assert(static_cast<int>(FontStretchUltraCondensed) == static_cast<int>(SkFontStyle::kUltraCondensed_Width), |
+ "FontStretchUltraCondensed should map to kUltraCondensed_Width"); |
+ static_assert(static_cast<int>(FontStretchNormal) == static_cast<int>(SkFontStyle::kNormal_Width), |
+ "FontStretchNormal should map to kNormal_Width"); |
+ static_assert(static_cast<int>(FontStretchUltraExpanded) == static_cast<int>(SkFontStyle::kUltaExpanded_Width), |
+ "FontStretchUltraExpanded should map to kUltaExpanded_Width"); |
+} |
+ |
} // namespace blink |