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

Unified Diff: src/ports/SkFontHost_win_dw.cpp

Issue 76763002: De-generalize create_typeface on Windows. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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/SkFontHost_win.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_win_dw.cpp
===================================================================
--- src/ports/SkFontHost_win_dw.cpp (revision 12308)
+++ src/ports/SkFontHost_win_dw.cpp (working copy)
@@ -1724,43 +1724,6 @@
return info;
}
-static SkTypeface* create_typeface(const SkTypeface* familyFace,
- const char familyName[],
- unsigned style,
- SkFontMgr_DirectWrite* fontMgr) {
- HRESULT hr;
- SkTScopedComPtr<IDWriteFontFamily> fontFamily;
- if (familyFace) {
- const DWriteFontTypeface* face = static_cast<const DWriteFontTypeface*>(familyFace);
- *(&fontFamily) = SkRefComPtr(face->fDWriteFontFamily.get());
-
- } else if (familyName) {
- hr = get_by_family_name(familyName, &fontFamily);
- }
-
- if (NULL == fontFamily.get()) {
- //No good family found, go with default.
- SkTScopedComPtr<IDWriteFont> font;
- hr = get_default_font(&font);
- hr = font->GetFontFamily(&fontFamily);
- }
-
- SkTScopedComPtr<IDWriteFont> font;
- DWRITE_FONT_WEIGHT weight = (style & SkTypeface::kBold)
- ? DWRITE_FONT_WEIGHT_BOLD
- : DWRITE_FONT_WEIGHT_NORMAL;
- DWRITE_FONT_STRETCH stretch = DWRITE_FONT_STRETCH_UNDEFINED;
- DWRITE_FONT_STYLE italic = (style & SkTypeface::kItalic)
- ? DWRITE_FONT_STYLE_ITALIC
- : DWRITE_FONT_STYLE_NORMAL;
- hr = fontFamily->GetFirstMatchingFont(weight, stretch, italic, &font);
-
- SkTScopedComPtr<IDWriteFontFace> fontFace;
- hr = font->CreateFontFace(&fontFace);
-
- return fontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), fontFamily.get());
-}
-
///////////////////////////////////////////////////////////////////////////////
static void get_locale_string(IDWriteLocalizedStrings* names, const WCHAR* preferedLocale,
@@ -1869,7 +1832,33 @@
SkTypeface* SkFontMgr_DirectWrite::onLegacyCreateTypeface(const char familyName[],
unsigned styleBits) {
- return create_typeface(NULL, familyName, styleBits, this);
+ SkTScopedComPtr<IDWriteFontFamily> fontFamily;
+ if (familyName) {
+ get_by_family_name(familyName, &fontFamily);
+ }
+
+ if (NULL == fontFamily.get()) {
+ //No good family found, go with default.
+ SkTScopedComPtr<IDWriteFont> defaultFont;
+ HRNM(get_default_font(&defaultFont), "Could not get default font.");
+ HRNM(defaultFont->GetFontFamily(&fontFamily), "Could not get default font family.");
+ }
+
+ SkTScopedComPtr<IDWriteFont> font;
+ DWRITE_FONT_WEIGHT weight = (styleBits & SkTypeface::kBold)
+ ? DWRITE_FONT_WEIGHT_BOLD
+ : DWRITE_FONT_WEIGHT_NORMAL;
+ DWRITE_FONT_STRETCH stretch = DWRITE_FONT_STRETCH_UNDEFINED;
+ DWRITE_FONT_STYLE italic = (styleBits & SkTypeface::kItalic)
+ ? DWRITE_FONT_STYLE_ITALIC
+ : DWRITE_FONT_STYLE_NORMAL;
+ HRNM(fontFamily->GetFirstMatchingFont(weight, stretch, italic, &font),
+ "Could not get matching font.");
+
+ SkTScopedComPtr<IDWriteFontFace> fontFace;
+ HRNM(font->CreateFontFace(&fontFace), "Could not create font face.");
+
+ return this->createTypefaceFromDWriteFont(fontFace.get(), font.get(), fontFamily.get());
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/ports/SkFontHost_win.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698