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

Unified Diff: src/core/SkTypeface.cpp

Issue 1818043002: SkTypeface::MakeFromName to take SkFontStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: CL rebased. Created 4 years, 7 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 | « include/core/SkTypeface.h ('k') | src/utils/SkWhitelistTypefaces.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTypeface.cpp
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 3c15878f737bc5c10a1d38b9d0377487300e8e38..0382057fdb20fe019e7c12ab2c1ecf43cafdecee 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -27,7 +27,11 @@ extern void WhitelistSerializeTypeface(const SkTypeface*, SkWStream* );
#define SK_TYPEFACE_DELEGATE nullptr
#endif
-sk_sp<SkTypeface> (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style ) = nullptr;
+#ifndef SK_DONT_USE_LEGACY_TYPEFACE_MAKE_FROM_NAME
+sk_sp<SkTypeface>(*gCreateTypefaceDelegate)(const char[], SkTypeface::Style style) = nullptr;
+#endif
+sk_sp<SkTypeface> (*gNewCreateTypefaceDelegate)(const char[], SkFontStyle) = nullptr;
bungeman-skia 2016/05/24 14:49:26 Only Skia uses this gCreateTypefaceDelegate, and o
Mikus 2016/05/24 15:22:26 Done. Seems to me that the 'new' version is not ne
+
void (*gSerializeTypefaceDelegate)(const SkTypeface*, SkWStream* ) = SK_TYPEFACE_DELEGATE;
sk_sp<SkTypeface> (*gDeserializeTypefaceDelegate)(SkStream* ) = nullptr;
@@ -115,6 +119,7 @@ bool SkTypeface::Equal(const SkTypeface* facea, const SkTypeface* faceb) {
///////////////////////////////////////////////////////////////////////////////
+#ifndef SK_DONT_USE_LEGACY_TYPEFACE_MAKE_FROM_NAME
sk_sp<SkTypeface> SkTypeface::MakeFromName(const char name[], Style style) {
if (gCreateTypefaceDelegate) {
sk_sp<SkTypeface> result = (*gCreateTypefaceDelegate)(name, style);
@@ -128,6 +133,23 @@ sk_sp<SkTypeface> SkTypeface::MakeFromName(const char name[], Style style) {
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
return sk_sp<SkTypeface>(fm->legacyCreateTypeface(name, SkFontStyle::FromOldStyle(style)));
}
+#endif
+
+sk_sp<SkTypeface> SkTypeface::MakeFromName(const char name[],
+ SkFontStyle fontStyle) {
+ if (gCreateTypefaceDelegate) {
+ sk_sp<SkTypeface> result = (*gNewCreateTypefaceDelegate)(name, fontStyle);
+ if (result) {
+ return result;
+ }
+ }
+ if (nullptr == name) {
bungeman-skia 2016/05/24 14:49:26 MakeDefault is just for caching common requests, a
Mikus 2016/05/24 15:22:26 Done.
+ return MakeDefault(static_cast<Style>((fontStyle.slant() == SkFontStyle::kItalic_Slant ? kItalic : kNormal) |
bungeman-skia 2016/05/24 14:49:26 nit (here and a few other places): Skia allows 100
Mikus 2016/05/24 15:22:26 Done.
+ (fontStyle.weight() >= SkFontStyle::kBold_Weight ? kBold : kNormal)));
+ }
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return sk_sp<SkTypeface>(fm->legacyCreateTypeface(name, fontStyle));
+}
sk_sp<SkTypeface> SkTypeface::MakeFromTypeface(SkTypeface* family, Style s) {
if (!family) {
@@ -192,7 +214,8 @@ sk_sp<SkTypeface> SkTypeface::MakeDeserialize(SkStream* stream) {
return typeface;
}
}
- return SkTypeface::MakeFromName(desc.getFamilyName(), desc.getStyle());
+
+ return SkTypeface::MakeFromName(desc.getFamilyName(), SkFontStyle::FromOldStyle(desc.getStyle()));
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « include/core/SkTypeface.h ('k') | src/utils/SkWhitelistTypefaces.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698