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

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: Add the legacy code back Created 4 years, 9 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 8b7620b484680ed0a0f6dd36f3a10bec31cae570..dd053f17c1b9a3aaa5123733d081f167462ec155 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -27,7 +27,10 @@ extern void WhitelistSerializeTypeface(const SkTypeface*, SkWStream* );
#define SK_TYPEFACE_DELEGATE nullptr
#endif
-SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style ) = nullptr;
+#ifndef SK_DONT_USE_LEGACY_TYPEFACE_CREATE_FROM_NAME
+SkTypeface* (*gCreateTypefaceDelegate)(const char[], SkTypeface::Style style) = nullptr;
+#endif
+SkTypeface* (*gNewCreateTypefaceDelegate)(const char[], SkFontStyle) = nullptr;
void (*gSerializeTypefaceDelegate)(const SkTypeface*, SkWStream* ) = SK_TYPEFACE_DELEGATE;
SkTypeface* (*gDeserializeTypefaceDelegate)(SkStream* ) = nullptr;
@@ -108,7 +111,8 @@ bool SkTypeface::Equal(const SkTypeface* facea, const SkTypeface* faceb) {
///////////////////////////////////////////////////////////////////////////////
-SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) {
+#ifndef SK_DONT_USE_LEGACY_TYPEFACE_CREATE_FROM_NAME
+SkTypeface* SkTypeface::CreateFromName(const char name[], SkTypeface::Style style) {
if (gCreateTypefaceDelegate) {
SkTypeface* result = (*gCreateTypefaceDelegate)(name, style);
if (result) {
@@ -121,6 +125,23 @@ SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) {
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
return fm->legacyCreateTypeface(name, style);
}
+#endif
+
+SkTypeface* SkTypeface::CreateFromName(const char name[],
+ SkFontStyle fontStyle) {
+ if (gNewCreateTypefaceDelegate) {
+ SkTypeface* result = (*gNewCreateTypefaceDelegate)(name, fontStyle);
+ if (result) {
+ return result;
+ }
+ }
+ if (nullptr == name) {
+ return RefDefault();
+ }
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->matchFamilyStyle(name, fontStyle);
bungeman-skia 2016/04/08 18:59:21 I believe Chromium on Linux is currently using an
Mikus 2016/05/19 09:34:02 Maybe I'll disable this for Linux and let the Linu
+}
+
SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) {
if (!family) {
@@ -193,7 +214,8 @@ SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
return typeface;
}
}
- return SkTypeface::CreateFromName(desc.getFamilyName(), desc.getStyle());
+ return SkTypeface::CreateFromName(desc.getFamilyName(),
+ SkFontStyle(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