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

Unified Diff: src/ports/SkFontMgr_win_dw.cpp

Issue 1921903002: Add oblique as a slant. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: static_assert what can be. Created 4 years, 8 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_fontconfig.cpp ('k') | src/ports/SkRemotableFontMgr_win_dw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontMgr_win_dw.cpp
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp
index fc86bad2cdf5d3ae149d3f8da08117b6e612dc72..e6e52d961ad9d62a5e318b941a5d52248a060971 100644
--- a/src/ports/SkFontMgr_win_dw.cpp
+++ b/src/ports/SkFontMgr_win_dw.cpp
@@ -984,11 +984,8 @@ SkTypeface* SkFontMgr_DirectWrite::onLegacyCreateTypeface(const char familyName[
}
SkTScopedComPtr<IDWriteFont> font;
- DWRITE_FONT_WEIGHT weight = (DWRITE_FONT_WEIGHT)style.weight();
- DWRITE_FONT_STRETCH stretch = (DWRITE_FONT_STRETCH)style.width();
- DWRITE_FONT_STYLE italic = style.isItalic() ? DWRITE_FONT_STYLE_ITALIC
- : DWRITE_FONT_STYLE_NORMAL;
- HRNM(fontFamily->GetFirstMatchingFont(weight, stretch, italic, &font),
+ DWriteStyle dwStyle(style);
+ HRNM(fontFamily->GetFirstMatchingFont(dwStyle.fWeight, dwStyle.fWidth, dwStyle.fSlant, &font),
"Could not get matching font.");
SkTScopedComPtr<IDWriteFontFace> fontFace;
@@ -1018,23 +1015,7 @@ void SkFontStyleSet_DirectWrite::getStyle(int index, SkFontStyle* fs, SkString*
HRVM(fFontFamily->GetFont(index, &font), "Could not get font.");
if (fs) {
- SkFontStyle::Slant slant;
- switch (font->GetStyle()) {
- case DWRITE_FONT_STYLE_NORMAL:
- slant = SkFontStyle::kUpright_Slant;
- break;
- case DWRITE_FONT_STYLE_OBLIQUE:
- case DWRITE_FONT_STYLE_ITALIC:
- slant = SkFontStyle::kItalic_Slant;
- break;
- default:
- SkASSERT(false);
- }
-
- int weight = font->GetWeight();
- int width = font->GetStretch();
-
- *fs = SkFontStyle(weight, width, slant);
+ *fs = get_style(font.get());
}
if (styleName) {
@@ -1046,24 +1027,10 @@ void SkFontStyleSet_DirectWrite::getStyle(int index, SkFontStyle* fs, SkString*
}
SkTypeface* SkFontStyleSet_DirectWrite::matchStyle(const SkFontStyle& pattern) {
- DWRITE_FONT_STYLE slant;
- switch (pattern.slant()) {
- case SkFontStyle::kUpright_Slant:
- slant = DWRITE_FONT_STYLE_NORMAL;
- break;
- case SkFontStyle::kItalic_Slant:
- slant = DWRITE_FONT_STYLE_ITALIC;
- break;
- default:
- SkASSERT(false);
- }
-
- DWRITE_FONT_WEIGHT weight = (DWRITE_FONT_WEIGHT)pattern.weight();
- DWRITE_FONT_STRETCH width = (DWRITE_FONT_STRETCH)pattern.width();
-
SkTScopedComPtr<IDWriteFont> font;
+ DWriteStyle dwStyle(pattern);
// TODO: perhaps use GetMatchingFonts and get the least simulated?
- HRNM(fFontFamily->GetFirstMatchingFont(weight, width, slant, &font),
+ HRNM(fFontFamily->GetFirstMatchingFont(dwStyle.fWeight, dwStyle.fWidth, dwStyle.fSlant, &font),
"Could not match font in family.");
SkTScopedComPtr<IDWriteFontFace> fontFace;
« no previous file with comments | « src/ports/SkFontMgr_fontconfig.cpp ('k') | src/ports/SkRemotableFontMgr_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698