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

Unified Diff: src/core/SkFontHost.cpp

Issue 66783003: Remove SK_FONTHOST_USES_FONTMGR. (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 | « include/ports/SkFontMgr.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFontHost.cpp
===================================================================
--- src/core/SkFontHost.cpp (revision 12201)
+++ src/core/SkFontHost.cpp (working copy)
@@ -6,6 +6,7 @@
*/
#include "SkFontLCDConfig.h"
+#include "SkOnce.h"
static SkFontLCDConfig::LCDOrientation gLCDOrientation = SkFontLCDConfig::kHorizontal_LCDOrientation;
static SkFontLCDConfig::LCDOrder gLCDOrder = SkFontLCDConfig::kRGB_LCDOrder;
@@ -190,22 +191,19 @@
return this->onLegacyCreateTypeface(familyName, styleBits);
}
+void set_up_default(SkFontMgr** singleton) {
+ *singleton = SkFontMgr::Factory();
+}
+
SkFontMgr* SkFontMgr::RefDefault() {
- static SkFontMgr* gFM;
- if (NULL == gFM) {
- gFM = SkFontMgr::Factory();
- // we never want to return NULL
- if (NULL == gFM) {
- gFM = SkNEW(SkEmptyFontMgr);
- }
- }
+ static SkFontMgr* gFM = NULL;
+ SK_DECLARE_STATIC_ONCE(once);
+ SkOnce(&once, set_up_default, &gFM);
return SkRef(gFM);
}
//////////////////////////////////////////////////////////////////////////
-#ifdef SK_FONTHOST_USES_FONTMGR
-
#if 0
static SkFontStyle TypefaceStyleBitsToFontStyle(SkTypeface::Style styleBits) {
SkFontStyle::Weight weight = (styleBits & SkTypeface::kBold) ?
@@ -222,10 +220,17 @@
SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
const char familyName[],
SkTypeface::Style style) {
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
if (familyFace) {
- return familyFace->refMatchingStyle(style);
+ bool bold = style & SkTypeface::kBold;
+ bool italic = style & SkTypeface::kItalic;
+ SkFontStyle newStyle = SkFontStyle(bold ? SkFontStyle::kBold_Weight
+ : SkFontStyle::kNormal_Weight,
+ SkFontStyle::kNormal_Width,
+ italic ? SkFontStyle::kItalic_Slant
+ : SkFontStyle::kUpright_Slant);
+ return fm->matchFaceStyle(familyFace, newStyle);
} else {
- SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
return fm->legacyCreateTypeface(familyName, style);
}
}
@@ -239,5 +244,3 @@
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
return fm->createFromStream(stream);
}
-
-#endif
« no previous file with comments | « include/ports/SkFontMgr.h ('k') | src/core/SkTypeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698