Index: src/ports/SkFontHost_linux.cpp |
diff --git a/src/ports/SkFontHost_linux.cpp b/src/ports/SkFontHost_linux.cpp |
index 2904cac9bcecd34c19c5364bf709f3d881b6d343..a4202aabd21d9ce4b728e6719451f51bb7130c90 100644 |
--- a/src/ports/SkFontHost_linux.cpp |
+++ b/src/ports/SkFontHost_linux.cpp |
@@ -30,9 +30,10 @@ |
/** The base SkTypeface implementation for the custom font manager. */ |
class SkTypeface_Custom : public SkTypeface_FreeType { |
public: |
- SkTypeface_Custom(Style style, bool isFixedPitch, bool sysFont, const SkString familyName) |
+ SkTypeface_Custom(Style style, bool isFixedPitch, |
+ bool sysFont, const SkString familyName, int index) |
: INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch) |
- , fIsSysFont(sysFont), fFamilyName(familyName) |
+ , fIsSysFont(sysFont), fFamilyName(familyName), fIndex(index) |
{ } |
bool isSysFont() const { return fIsSysFont; } |
@@ -47,12 +48,16 @@ protected: |
virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const SK_OVERRIDE { |
desc->setFamilyName(fFamilyName.c_str()); |
desc->setFontFileName(this->getUniqueString()); |
+ desc->setFontIndex(fIndex); |
*isLocal = !this->isSysFont(); |
} |
+ int getIndex() const { return fIndex; } |
+ |
private: |
- bool fIsSysFont; |
- SkString fFamilyName; |
+ const bool fIsSysFont; |
+ const SkString fFamilyName; |
+ const int fIndex; |
typedef SkTypeface_FreeType INHERITED; |
}; |
@@ -62,7 +67,7 @@ private: |
*/ |
class SkTypeface_Empty : public SkTypeface_Custom { |
public: |
- SkTypeface_Empty() : INHERITED(SkTypeface::kNormal, false, true, SkString()) {} |
+ SkTypeface_Empty() : INHERITED(SkTypeface::kNormal, false, true, SkString(), 0) {} |
virtual const char* getUniqueString() const SK_OVERRIDE { return NULL; } |
@@ -78,21 +83,20 @@ class SkTypeface_Stream : public SkTypeface_Custom { |
public: |
SkTypeface_Stream(Style style, bool isFixedPitch, bool sysFont, const SkString familyName, |
SkStream* stream, int ttcIndex) |
- : INHERITED(style, isFixedPitch, sysFont, familyName) |
- , fStream(SkRef(stream)), fTtcIndex(ttcIndex) |
+ : INHERITED(style, isFixedPitch, sysFont, familyName, ttcIndex) |
+ , fStream(SkRef(stream)) |
{ } |
virtual const char* getUniqueString() const SK_OVERRIDE { return NULL; } |
protected: |
virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { |
- *ttcIndex = 0; |
+ *ttcIndex = this->getIndex(); |
return fStream->duplicate(); |
} |
private: |
- SkAutoTUnref<SkStream> fStream; |
- int fTtcIndex; |
+ const SkAutoTUnref<const SkStream> fStream; |
typedef SkTypeface_Custom INHERITED; |
}; |
@@ -101,8 +105,8 @@ private: |
class SkTypeface_File : public SkTypeface_Custom { |
public: |
SkTypeface_File(Style style, bool isFixedPitch, bool sysFont, const SkString familyName, |
- const char path[]) |
- : INHERITED(style, isFixedPitch, sysFont, familyName) |
+ const char path[], int index) |
+ : INHERITED(style, isFixedPitch, sysFont, familyName, index) |
, fPath(path) |
{ } |
@@ -116,7 +120,7 @@ public: |
protected: |
virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { |
- *ttcIndex = 0; |
+ *ttcIndex = this->getIndex(); |
return SkStream::NewFromFile(fPath.c_str()); |
} |
@@ -343,7 +347,7 @@ private: |
isFixedPitch, |
true, // system-font (cannot delete) |
realname, |
- filename.c_str())); |
+ filename.c_str(), 0)); |
SkFontStyleSet_Custom* addTo = this->onMatchFamily(realname.c_str()); |
if (NULL == addTo) { |