| Index: src/ports/SkFontHost_mac.cpp
|
| ===================================================================
|
| --- src/ports/SkFontHost_mac.cpp (revision 8581)
|
| +++ src/ports/SkFontHost_mac.cpp (working copy)
|
| @@ -438,21 +438,23 @@
|
| class SkTypeface_Mac : public SkTypeface {
|
| public:
|
| SkTypeface_Mac(SkTypeface::Style style, SkFontID fontID, bool isFixedPitch,
|
| - CTFontRef fontRef, const char name[])
|
| + CTFontRef fontRef, const char name[], bool serializeData)
|
| : SkTypeface(style, fontID, isFixedPitch)
|
| , fName(name)
|
| , fFontRef(fontRef) // caller has already called CFRetain for us
|
| , fFontStyle(stylebits2fontstyle(style))
|
| + , fSerializeData(serializeData)
|
| {
|
| SkASSERT(fontRef);
|
| }
|
|
|
| SkTypeface_Mac(const SkFontStyle& fs, SkFontID fontID, bool isFixedPitch,
|
| - CTFontRef fontRef, const char name[])
|
| + CTFontRef fontRef, const char name[], bool serializeData)
|
| : SkTypeface(fontstyle2stylebits(fs), fontID, isFixedPitch)
|
| , fName(name)
|
| , fFontRef(fontRef) // caller has already called CFRetain for us
|
| , fFontStyle(fs)
|
| + , fSerializeData(serializeData)
|
| {
|
| SkASSERT(fontRef);
|
| }
|
| @@ -460,6 +462,7 @@
|
| SkString fName;
|
| AutoCFRelease<CTFontRef> fFontRef;
|
| SkFontStyle fFontStyle;
|
| + bool fSerializeData;
|
|
|
| protected:
|
| friend class SkFontHost; // to access our protected members for deprecated methods
|
| @@ -481,13 +484,13 @@
|
| typedef SkTypeface INHERITED;
|
| };
|
|
|
| -static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[]) {
|
| +static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[], bool serializeData) {
|
| SkASSERT(fontRef);
|
| bool isFixedPitch;
|
| SkTypeface::Style style = computeStyleBits(fontRef, &isFixedPitch);
|
| SkFontID fontID = CTFontRef_to_SkFontID(fontRef);
|
|
|
| - return new SkTypeface_Mac(style, fontID, isFixedPitch, fontRef, name);
|
| + return new SkTypeface_Mac(style, fontID, isFixedPitch, fontRef, name, serializeData);
|
| }
|
|
|
| static SkTypeface* NewFromName(const char familyName[], SkTypeface::Style theStyle) {
|
| @@ -538,7 +541,7 @@
|
| }
|
| }
|
|
|
| - return ctFont ? NewFromFontRef(ctFont, familyName) : NULL;
|
| + return ctFont ? NewFromFontRef(ctFont, familyName, false) : NULL;
|
| }
|
|
|
| static SkTypeface* GetDefaultFace() {
|
| @@ -565,13 +568,13 @@
|
| /* This function is visible on the outside. It first searches the cache, and if
|
| * not found, returns a new entry (after adding it to the cache).
|
| */
|
| -SkTypeface* SkCreateTypefaceFromCTFont(CTFontRef fontRef) {
|
| +SkTypeface* SkCreateTypefaceFromCTFont(CTFontRef fontRef, bool serializeData) {
|
| SkFontID fontID = CTFontRef_to_SkFontID(fontRef);
|
| SkTypeface* face = SkTypefaceCache::FindByID(fontID);
|
| if (face) {
|
| face->ref();
|
| } else {
|
| - face = NewFromFontRef(fontRef, NULL);
|
| + face = NewFromFontRef(fontRef, NULL, serializeData);
|
| SkTypefaceCache::Add(face, face->style());
|
| // NewFromFontRef doesn't retain the parameter, but the typeface it
|
| // creates does release it in its destructor, so we balance that with
|
| @@ -1417,7 +1420,7 @@
|
| return NULL;
|
| }
|
| CTFontRef ct = CTFontCreateWithGraphicsFont(cg, 0, NULL, NULL);
|
| - return cg ? SkCreateTypefaceFromCTFont(ct) : NULL;
|
| + return cg ? SkCreateTypefaceFromCTFont(ct, true) : NULL;
|
| }
|
|
|
| SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
|
| @@ -1870,8 +1873,7 @@
|
| desc->setFamilyName(get_str(CTFontCopyFamilyName(fFontRef), &tmpStr));
|
| desc->setFullName(get_str(CTFontCopyFullName(fFontRef), &tmpStr));
|
| desc->setPostscriptName(get_str(CTFontCopyPostScriptName(fFontRef), &tmpStr));
|
| - // TODO: need to add support for local-streams (here and openStream)
|
| - *isLocalStream = false;
|
| + *isLocalStream = fSerializeData;
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| @@ -1993,7 +1995,7 @@
|
| SkFontID fontID = CTFontRef_to_SkFontID(ctFont);
|
|
|
| face = SkNEW_ARGS(SkTypeface_Mac, (rec.fFontStyle, fontID, isFixedPitch,
|
| - ctFont, str.c_str()));
|
| + ctFont, str.c_str(), false));
|
| SkTypefaceCache::Add(face, face->style());
|
| return face;
|
| }
|
|
|