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

Unified Diff: src/ports/SkFontMgr_fontconfig.cpp

Issue 1139123008: Revert of Font variations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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/ports/SkFontMgr_android.cpp ('k') | src/ports/SkTypeface_win_dw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontMgr_fontconfig.cpp
diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp
index 3baec41cb541d0a0a5b2a40f9423f35431cd14e3..f03e5acaf1382d50fc6ababd4d682f7cabacd632 100644
--- a/src/ports/SkFontMgr_fontconfig.cpp
+++ b/src/ports/SkFontMgr_fontconfig.cpp
@@ -375,10 +375,11 @@
class SkTypeface_stream : public SkTypeface_FreeType {
public:
- /** @param data takes ownership of the font data.*/
- SkTypeface_stream(SkFontData* data, const SkFontStyle& style, bool fixedWidth)
+ /** @param stream does not take ownership of the reference, does take ownership of the stream.*/
+ SkTypeface_stream(const SkFontStyle& style, bool fixedWidth, int index, SkStreamAsset* stream)
: INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth)
- , fData(data)
+ , fStream(stream)
+ , fIndex(index)
{ };
void onGetFamilyName(SkString* familyName) const override {
@@ -386,20 +387,18 @@
}
void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const override {
+ desc->setFontIndex(fIndex);
*serialize = true;
}
SkStreamAsset* onOpenStream(int* ttcIndex) const override {
- *ttcIndex = fData->getIndex();
- return fData->duplicateStream();
- }
-
- SkFontData* onCreateFontData() const override {
- return new SkFontData(*fData.get());
+ *ttcIndex = fIndex;
+ return fStream->duplicate();
}
private:
- const SkAutoTDelete<const SkFontData> fData;
+ SkAutoTDelete<SkStreamAsset> fStream;
+ int fIndex;
typedef SkTypeface_FreeType INHERITED;
};
@@ -421,6 +420,7 @@
desc->setFamilyName(get_string(fPattern, FC_FAMILY));
desc->setFullName(get_string(fPattern, FC_FULLNAME));
desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME));
+ desc->setFontIndex(get_int(fPattern, FC_INDEX, 0));
*serialize = false;
}
@@ -822,12 +822,12 @@
SkFontStyle style;
bool isFixedWidth = false;
- if (!fScanner.scanFont(stream, ttcIndex, NULL, &style, &isFixedWidth, NULL)) {
+ if (!fScanner.scanFont(stream, ttcIndex, NULL, &style, &isFixedWidth)) {
return NULL;
}
- return SkNEW_ARGS(SkTypeface_stream, (new SkFontData(stream.detach(), ttcIndex, NULL, 0),
- style, isFixedWidth));
+ return SkNEW_ARGS(SkTypeface_stream, (style, isFixedWidth, ttcIndex,
+ static_cast<SkStreamAsset*>(stream.detach())));
}
SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
@@ -836,23 +836,6 @@
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
return this->createFromStream(SkStream::NewFromFile(path), ttcIndex);
- }
-
- SkTypeface* onCreateFromFontData(SkFontData* fontData) const override {
- SkStreamAsset* stream(fontData->getStream());
- const size_t length = stream->getLength();
- if (length <= 0 || (1u << 30) < length) {
- return NULL;
- }
-
- const int ttcIndex = fontData->getIndex();
- SkFontStyle style;
- bool isFixedWidth = false;
- if (!fScanner.scanFont(stream, ttcIndex, NULL, &style, &isFixedWidth, NULL)) {
- return NULL;
- }
-
- return SkNEW_ARGS(SkTypeface_stream, (fontData, style, isFixedWidth));
}
virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
« no previous file with comments | « src/ports/SkFontMgr_android.cpp ('k') | src/ports/SkTypeface_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698