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

Unified Diff: src/ports/SkTypeface_win_dw.h

Issue 488143002: Replace SkTypeface::Style with SkFontStyle. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add expectations, remove whitespace. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkFontMgr_win_dw.cpp ('k') | tools/sk_tool_utils_font.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkTypeface_win_dw.h
diff --git a/src/ports/SkTypeface_win_dw.h b/src/ports/SkTypeface_win_dw.h
index 531dc51a1179b907acbbd098bf04e31bcdb0e55c..7d72dfd4d649233490214a23d5929d99100b6929 100644
--- a/src/ports/SkTypeface_win_dw.h
+++ b/src/ports/SkTypeface_win_dw.h
@@ -24,22 +24,19 @@
class SkFontDescriptor;
struct SkScalerContextRec;
-static SkTypeface::Style get_style(IDWriteFont* font) {
- int style = SkTypeface::kNormal;
- DWRITE_FONT_WEIGHT weight = font->GetWeight();
- if (DWRITE_FONT_WEIGHT_DEMI_BOLD <= weight) {
- style |= SkTypeface::kBold;
- }
- DWRITE_FONT_STYLE angle = font->GetStyle();
- if (DWRITE_FONT_STYLE_OBLIQUE == angle || DWRITE_FONT_STYLE_ITALIC == angle) {
- style |= SkTypeface::kItalic;
- }
- return static_cast<SkTypeface::Style>(style);
+static SkFontStyle get_style(IDWriteFont* font) {
+ DWRITE_FONT_STYLE dwStyle = font->GetStyle();
+ return SkFontStyle(font->GetWeight(),
+ font->GetStretch(),
+ (DWRITE_FONT_STYLE_OBLIQUE == dwStyle ||
+ DWRITE_FONT_STYLE_ITALIC == dwStyle)
+ ? SkFontStyle::kItalic_Slant
+ : SkFontStyle::kUpright_Slant);
}
class DWriteFontTypeface : public SkTypeface {
private:
- DWriteFontTypeface(SkTypeface::Style style, SkFontID fontID,
+ DWriteFontTypeface(const SkFontStyle& style, SkFontID fontID,
IDWriteFactory* factory,
IDWriteFontFace* fontFace,
IDWriteFont* font,
@@ -80,9 +77,8 @@ public:
IDWriteFontFamily* fontFamily,
IDWriteFontFileLoader* fontFileLoader = NULL,
IDWriteFontCollectionLoader* fontCollectionLoader = NULL) {
- SkTypeface::Style style = get_style(font);
SkFontID fontID = SkTypefaceCache::NewFontID();
- return SkNEW_ARGS(DWriteFontTypeface, (style, fontID,
+ return SkNEW_ARGS(DWriteFontTypeface, (get_style(font), fontID,
factory, fontFace, font, fontFamily,
fontFileLoader, fontCollectionLoader));
}
« no previous file with comments | « src/ports/SkFontMgr_win_dw.cpp ('k') | tools/sk_tool_utils_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698