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

Unified Diff: src/ports/SkFontMgr_win_dw.cpp

Issue 1873923002: Begin switch to SkFontStyle for legacy calls. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Dont update bzl file now. 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') | 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/SkFontMgr_win_dw.cpp
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp
index 11afec3b53623205dad6612ab7cc0057c958181e..788bb5edd3f8ae962cb63072e59580ab71bb0141 100644
--- a/src/ports/SkFontMgr_win_dw.cpp
+++ b/src/ports/SkFontMgr_win_dw.cpp
@@ -284,18 +284,21 @@ protected:
void onGetFamilyName(int index, SkString* familyName) const override;
SkFontStyleSet* onCreateStyleSet(int index) const override;
SkFontStyleSet* onMatchFamily(const char familyName[]) const override;
- virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
- const SkFontStyle& fontstyle) const override;
- virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&,
- const char* bcp47[], int bcp47Count,
- SkUnichar character) const override;
- virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
- const SkFontStyle& fontstyle) const override;
+ SkTypeface* onMatchFamilyStyle(const char familyName[],
+ const SkFontStyle& fontstyle) const override;
+ SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&,
+ const char* bcp47[], int bcp47Count,
+ SkUnichar character) const override;
+ SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
+ const SkFontStyle& fontstyle) const override;
SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const override;
SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override;
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override;
- virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
- unsigned styleBits) const override;
+#ifdef SK_VERY_LEGACY_CREATE_TYPEFACE
+ SkTypeface* onLegacyCreateTypeface(const char familyName[], unsigned styleBits) const override;
+#else
+ SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle) const override;
+#endif
private:
HRESULT getByFamilyName(const WCHAR familyName[], IDWriteFontFamily** fontFamily) const;
@@ -950,8 +953,14 @@ HRESULT SkFontMgr_DirectWrite::getDefaultFontFamily(IDWriteFontFamily** fontFami
return S_OK;
}
+#ifdef SK_VERY_LEGACY_CREATE_TYPEFACE
SkTypeface* SkFontMgr_DirectWrite::onLegacyCreateTypeface(const char familyName[],
unsigned styleBits) const {
+ SkFontStyle style = SkFontStyle::FromOldStyle(styleBits);
+#else
+SkTypeface* SkFontMgr_DirectWrite::onLegacyCreateTypeface(const char familyName[],
+ SkFontStyle style) const {
+#endif
SkTScopedComPtr<IDWriteFontFamily> fontFamily;
if (familyName) {
SkSMallocWCHAR wideFamilyName;
@@ -972,13 +981,10 @@ SkTypeface* SkFontMgr_DirectWrite::onLegacyCreateTypeface(const char familyName[
}
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_NORMAL;
- DWRITE_FONT_STYLE italic = (styleBits & SkTypeface::kItalic)
- ? DWRITE_FONT_STYLE_ITALIC
- : DWRITE_FONT_STYLE_NORMAL;
+ 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),
"Could not get matching font.");
« no previous file with comments | « src/ports/SkFontMgr_fontconfig.cpp ('k') | tools/sk_tool_utils_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698