diff options
author | bungeman <bungeman@google.com> | 2016-04-27 10:21:04 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-27 10:21:05 -0700 |
commit | b4bb7d825566042ed64697be49457dbac060e6c4 (patch) | |
tree | baad2b4f5125674cc06c06a7d2dd04f7100379c4 /src/ports/SkFontMgr_win_dw.cpp | |
parent | 12135f50bd8d7d8abbb2befb99a9784043cb90e5 (diff) |
Add oblique as a slant.
Some fonts have italic and oblique in the same family, see
http://lucidafonts.com/fonts/family/lucida-sans
http://www.gust.org.pl/projects/e-foundry/latin-modern
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1921903002
Chromium side change at https://crrev.com/1921503006/ .
Review-Url: https://codereview.chromium.org/1921903002
Diffstat (limited to 'src/ports/SkFontMgr_win_dw.cpp')
-rw-r--r-- | src/ports/SkFontMgr_win_dw.cpp | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp index fc86bad2cd..e6e52d961a 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; |