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

Unified Diff: src/ports/SkFontMgr_android.cpp

Issue 1027373002: Font variations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Slightly more palatable. Created 5 years, 9 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
Index: src/ports/SkFontMgr_android.cpp
diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp
index 49ca08194be77cb7044779abce2b07b0d87cdeb7..9bb7cb0d689e217a0e2dd46e6fed11f628d8cc34 100644
--- a/src/ports/SkFontMgr_android.cpp
+++ b/src/ports/SkFontMgr_android.cpp
@@ -28,6 +28,7 @@ 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)
@@ -42,6 +43,7 @@ protected:
int fIndex;
SkString fFamilyName;
+ const SkTArray<SkFixed, true> fAxes;
private:
typedef SkTypeface_FreeType INHERITED;
@@ -51,12 +53,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,14 +69,16 @@ public:
SkASSERT(desc);
SkASSERT(serialize);
desc->setFamilyName(fFamilyName.c_str());
- desc->setFontFileName(fPathName.c_str());
- desc->setFontIndex(fIndex);
*serialize = false;
}
SkStreamAsset* onOpenStream(int* ttcIndex) const override {
*ttcIndex = fIndex;
return SkStream::NewFromFile(fPathName.c_str());
}
+ SkFontData* onCreateFontData() const SK_OVERRIDE {
+ return new SkFontData(SkStream::NewFromFile(fPathName.c_str()), fIndex,
+ fAxes.count(), fAxes.begin());
+ }
const SkString fPathName;
const SkLanguage fLang;
@@ -86,10 +91,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,
@@ -97,7 +103,6 @@ public:
SkASSERT(desc);
SkASSERT(serialize);
desc->setFamilyName(fFamilyName.c_str());
- desc->setFontFileName(NULL);
*serialize = true;
}
@@ -106,6 +111,10 @@ public:
return fStream->duplicate();
}
+ SkFontData* onCreateFontData() const SK_OVERRIDE {
+ return new SkFontData(fStream->duplicate(), fIndex, fAxes.count(), fAxes.begin());
+ }
+
private:
SkAutoTDelete<SkStreamAsset> fStream;
@@ -163,7 +172,7 @@ public:
}
fStyles.push_back().reset(SkNEW_ARGS(SkTypeface_AndroidSystem,
- (pathName, ttcIndex,
+ (pathName, ttcIndex, fontFile.fAxes,
style, isFixedWidth, familyName,
lang, variant)));
}
@@ -410,7 +419,20 @@ protected:
if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch)) {
return NULL;
}
- return SkNEW_ARGS(SkTypeface_AndroidStream, (stream.detach(), ttcIndex,
+ return SkNEW_ARGS(SkTypeface_AndroidStream, (stream.detach(), ttcIndex, SkTArray<SkFixed, true>(),
+ style, isFixedPitch, name));
+ }
+
+ SkTypeface* onCreateFromFontData(SkFontData* data) const SK_OVERRIDE {
+ SkAutoTDelete<SkStreamAsset> stream(data->transferStream());
+ bool isFixedPitch;
+ SkFontStyle style;
+ SkString name;
+ if (!fScanner.scanFont(stream, data->getIndex(), &name, &style, &isFixedPitch)) {
+ return NULL;
+ }
+ return SkNEW_ARGS(SkTypeface_AndroidStream, (stream.detach(), data->getIndex(),
+ SkTArray<SkFixed, true>(data->getAxis(), data->getAxisCount()),
style, isFixedPitch, name));
}

Powered by Google App Engine
This is Rietveld 408576698