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

Unified Diff: src/core/SkTypeface.cpp

Issue 105223006: Remove a layer of indirection and code from SkFontHost. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Rebase, should now work due to Android changes. Created 6 years, 3 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/core/SkFontHost.cpp ('k') | no next file » | 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 01b534c95fa4adb28f216b4818e4ef9c42b957cd..fcb2b8e2b13ae7d7430cb9863ff47a9f4a0bf650 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -8,7 +8,7 @@
#include "SkAdvancedTypefaceMetrics.h"
#include "SkEndian.h"
#include "SkFontDescriptor.h"
-#include "SkFontHost.h"
+#include "SkFontMgr.h"
#include "SkLazyPtr.h"
#include "SkOTTable_OS_2.h"
#include "SkStream.h"
@@ -84,7 +84,8 @@ SkTypeface* SkTypeface::CreateDefault(int style) {
// TODO(bungeman, mtklein): This is sad. Make our fontconfig code safe?
SkAutoMutexAcquire lock(&gCreateDefaultMutex);
- SkTypeface* t = SkFontHost::CreateTypeface(NULL, NULL, (Style)style);
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ SkTypeface* t = fm->legacyCreateTypeface(NULL, style);;
return t ? t : SkEmptyTypeface::Create();
}
@@ -123,7 +124,8 @@ SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) {
if (NULL == name) {
return RefDefault(style);
}
- return SkFontHost::CreateTypeface(NULL, name, style);
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->legacyCreateTypeface(name, style);
}
SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) {
@@ -131,15 +133,25 @@ SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) {
family->ref();
return const_cast<SkTypeface*>(family);
}
- return SkFontHost::CreateTypeface(family, NULL, s);
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ bool bold = s & SkTypeface::kBold;
+ bool italic = s & 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(family, newStyle);
}
SkTypeface* SkTypeface::CreateFromStream(SkStream* stream) {
- return SkFontHost::CreateTypefaceFromStream(stream);
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->createFromStream(stream);
}
SkTypeface* SkTypeface::CreateFromFile(const char path[]) {
- return SkFontHost::CreateTypefaceFromFile(path);
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->createFromFile(path);
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/core/SkFontHost.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698