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

Unified Diff: src/ports/SkFontHost_mac.cpp

Issue 21142004: support SK_FONTHOST_USES_FONTMGR on mac (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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/fonts/SkGScalerContext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_mac.cpp
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index ef51aef018a9b650aed4f27cee2c7e074c6913ed..52a3fd69308dbdea29b2fee5a5241cb632af6b8c 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -465,6 +465,7 @@ protected:
virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[],
int glyphCount) const SK_OVERRIDE;
virtual int onCountGlyphs() const SK_OVERRIDE;
+ virtual SkTypeface* onRefMatchingStyle(Style) const SK_OVERRIDE;
private:
@@ -597,27 +598,27 @@ static const char* map_css_names(const char* name) {
return name; // no change
}
-SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
- const char familyName[],
- SkTypeface::Style style) {
+static SkTypeface* create_typeface(const SkTypeface* familyFace,
+ const char familyName[],
+ SkTypeface::Style style) {
if (familyName) {
familyName = map_css_names(familyName);
}
-
+
// Clone an existing typeface
// TODO: only clone if style matches the familyFace's style...
if (familyName == NULL && familyFace != NULL) {
familyFace->ref();
return const_cast<SkTypeface*>(familyFace);
}
-
+
if (!familyName || !*familyName) {
familyName = FONT_DEFAULT_NAME;
}
-
+
NameStyleRec rec = { familyName, style };
SkTypeface* face = SkTypefaceCache::FindByProcAndRef(FindByNameStyle, &rec);
-
+
if (NULL == face) {
face = NewFromName(familyName, style);
if (face) {
@@ -630,6 +631,10 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
return face;
}
+SkTypeface* SkTypeface_Mac::onRefMatchingStyle(Style styleBits) const {
+ return create_typeface(this, NULL, styleBits);
+}
+
///////////////////////////////////////////////////////////////////////////////
/** GlyphRect is in FUnits (em space, y up). */
@@ -1437,22 +1442,6 @@ static SkTypeface* create_from_dataProvider(CGDataProviderRef provider) {
return cg ? SkCreateTypefaceFromCTFont(ct) : NULL;
}
-SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
- AutoCFRelease<CGDataProviderRef> provider(SkCreateDataProviderFromStream(stream));
- if (NULL == provider) {
- return NULL;
- }
- return create_from_dataProvider(provider);
-}
-
-SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
- AutoCFRelease<CGDataProviderRef> provider(CGDataProviderCreateWithFilename(path));
- if (NULL == provider) {
- return NULL;
- }
- return create_from_dataProvider(provider);
-}
-
// Web fonts added to the the CTFont registry do not return their character set.
// Iterate through the font in this case. The existing caller caches the result,
// so the performance impact isn't too bad.
@@ -2258,8 +2247,41 @@ protected:
}
return create_from_dataProvider(pr);
}
+
+ virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
+ unsigned styleBits) SK_OVERRIDE {
+ return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits);
+ }
};
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef SK_FONTHOST_USES_FONTMGR
+
+SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
+ const char familyName[],
+ SkTypeface::Style style) {
+ return create_typeface(familyFace, familyName, style);
+}
+
+SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
+ AutoCFRelease<CGDataProviderRef> provider(SkCreateDataProviderFromStream(stream));
+ if (NULL == provider) {
+ return NULL;
+ }
+ return create_from_dataProvider(provider);
+}
+
+SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
+ AutoCFRelease<CGDataProviderRef> provider(CGDataProviderCreateWithFilename(path));
+ if (NULL == provider) {
+ return NULL;
+ }
+ return create_from_dataProvider(provider);
+}
+
+#endif
+
SkFontMgr* SkFontMgr::Factory() {
return SkNEW(SkFontMgr_Mac);
}
« no previous file with comments | « src/fonts/SkGScalerContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698