Index: src/ports/SkFontMgr_android.cpp |
diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp |
index ae1b663e261dd30a976fbed417e09d033c92bee7..02ea0d91ddcdb096a7056f822bfc7f5e50b52f24 100644 |
--- a/src/ports/SkFontMgr_android.cpp |
+++ b/src/ports/SkFontMgr_android.cpp |
@@ -28,12 +28,15 @@ static const char* gTestBasePath = NULL; |
class SkTypeface_Android : public SkTypeface_FreeType { |
public: |
SkTypeface_Android(int index, |
+ const SkTArray<SkFixed, true>& axes, |
const SkFontStyle& style, |
bool isFixedPitch, |
const SkString& familyName) |
: INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch) |
, fIndex(index) |
- , fFamilyName(familyName) { } |
+ , fFamilyName(familyName) |
+ , fAxes(axes) |
+ { } |
protected: |
void onGetFamilyName(SkString* familyName) const override { |
@@ -42,6 +45,7 @@ protected: |
int fIndex; |
SkString fFamilyName; |
+ const SkTArray<SkFixed, true> fAxes; |
private: |
typedef SkTypeface_FreeType INHERITED; |
@@ -51,12 +55,13 @@ class SkTypeface_AndroidSystem : public SkTypeface_Android { |
public: |
SkTypeface_AndroidSystem(const SkString& pathName, |
int index, |
+ const SkTArray<SkFixed, true>& axes, |
const SkFontStyle& style, |
bool isFixedPitch, |
const SkString& familyName, |
const SkLanguage& lang, |
FontVariant variantStyle) |
- : INHERITED(index, style, isFixedPitch, familyName) |
+ : INHERITED(index, axes, style, isFixedPitch, familyName) |
, fPathName(pathName) |
, fLang(lang) |
, fVariantStyle(variantStyle) { } |
@@ -66,13 +71,16 @@ public: |
SkASSERT(desc); |
SkASSERT(serialize); |
desc->setFamilyName(fFamilyName.c_str()); |
- desc->setFontIndex(fIndex); |
*serialize = false; |
} |
SkStreamAsset* onOpenStream(int* ttcIndex) const override { |
*ttcIndex = fIndex; |
return SkStream::NewFromFile(fPathName.c_str()); |
} |
+ SkFontData* onCreateFontData() const override { |
+ return new SkFontData(SkStream::NewFromFile(fPathName.c_str()), fIndex, |
+ fAxes.count(), fAxes.begin()); |
+ } |
const SkString fPathName; |
const SkLanguage fLang; |
@@ -85,10 +93,11 @@ class SkTypeface_AndroidStream : public SkTypeface_Android { |
public: |
SkTypeface_AndroidStream(SkStreamAsset* stream, |
int index, |
+ const SkTArray<SkFixed, true>& axes, |
const SkFontStyle& style, |
bool isFixedPitch, |
const SkString& familyName) |
- : INHERITED(index, style, isFixedPitch, familyName) |
+ : INHERITED(index, axes, style, isFixedPitch, familyName) |
, fStream(stream) { } |
virtual void onGetFontDescriptor(SkFontDescriptor* desc, |
@@ -104,6 +113,10 @@ public: |
return fStream->duplicate(); |
} |
+ SkFontData* onCreateFontData() const override { |
+ return new SkFontData(fStream->duplicate(), fIndex, fAxes.count(), fAxes.begin()); |
+ } |
+ |
private: |
SkAutoTDelete<SkStreamAsset> fStream; |
@@ -137,7 +150,9 @@ public: |
SkString familyName; |
SkFontStyle style; |
bool isFixedWidth; |
- if (!scanner.scanFont(stream.get(), ttcIndex, &familyName, &style, &isFixedWidth)) { |
+ SkTArray<SkFixed, true> axes; |
+ if (!scanner.scanFont(stream.get(), ttcIndex, fontFile.fAxes.begin(), fontFile.fAxes.count(), |
+ &familyName, &style, &isFixedWidth, &axes)) { |
SkDEBUGF(("Requested font file %s exists, but is not a valid font.\n", |
pathName.c_str())); |
continue; |
@@ -167,7 +182,7 @@ public: |
} |
fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem, |
- (pathName, ttcIndex, |
+ (pathName, ttcIndex, axes, |
style, isFixedWidth, familyName, |
lang, variant))); |
} |
@@ -411,10 +426,25 @@ protected: |
bool isFixedPitch; |
SkFontStyle style; |
SkString name; |
- if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch)) { |
+ SkTArray<SkFixed, true> axes; |
+ if (!fScanner.scanFont(stream, ttcIndex, NULL, 0, &name, &style, &isFixedPitch, &axes)) { |
+ return NULL; |
+ } |
+ return SkNEW_ARGS(SkTypeface_AndroidStream, (stream.detach(), ttcIndex, axes, |
+ style, isFixedPitch, name)); |
+ } |
+ |
+ SkTypeface* onCreateFromFontData(SkFontData* data) const override { |
+ SkAutoTDelete<SkStreamAsset> stream(data->transferStream()); |
+ bool isFixedPitch; |
+ SkFontStyle style; |
+ SkString name; |
+ SkTArray<SkFixed, true> axes; |
+ if (!fScanner.scanFont(stream, data->getIndex(), NULL, 0, &name, &style, &isFixedPitch, &axes)) { |
return NULL; |
} |
- return SkNEW_ARGS(SkTypeface_AndroidStream, (stream.detach(), ttcIndex, |
+ return SkNEW_ARGS(SkTypeface_AndroidStream, (stream.detach(), data->getIndex(), |
+ SkTArray<SkFixed, true>(data->getAxis(), data->getAxisCount()), |
style, isFixedPitch, name)); |
} |