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

Unified Diff: src/core/SkTypeface.cpp

Issue 1027373002: Font variations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase 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/core/SkFontMgr.cpp ('k') | src/fonts/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTypeface.cpp
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 0f5d70b1a8ccbe28ce2c51252223e2e70f11ed31..342c41553d15da8e98a2764eb46e40fe808ec4e7 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -143,6 +143,11 @@ SkTypeface* SkTypeface::CreateFromStream(SkStreamAsset* stream, int index) {
return fm->createFromStream(stream, index);
}
+SkTypeface* SkTypeface::CreateFromFontData(SkFontData* data) {
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->createFromFontData(data);
+}
+
SkTypeface* SkTypeface::CreateFromFile(const char path[], int index) {
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
return fm->createFromFile(path, index);
@@ -157,9 +162,7 @@ void SkTypeface::serialize(SkWStream* wstream) const {
// Embed font data if it's a local font.
if (isLocal && !desc.hasFontData()) {
- int ttcIndex;
- desc.setFontData(this->onOpenStream(&ttcIndex));
- desc.setFontIndex(ttcIndex);
+ desc.setFontData(this->onCreateFontData());
}
desc.serialize(wstream);
}
@@ -171,18 +174,16 @@ void SkTypeface::serializeForcingEmbedding(SkWStream* wstream) const {
// Always embed font data.
if (!desc.hasFontData()) {
- int ttcIndex;
- desc.setFontData(this->onOpenStream(&ttcIndex));
- desc.setFontIndex(ttcIndex);
+ desc.setFontData(this->onCreateFontData());
}
desc.serialize(wstream);
}
SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
SkFontDescriptor desc(stream);
- SkStreamAsset* data = desc.transferFontData();
+ SkFontData* data = desc.detachFontData();
if (data) {
- SkTypeface* typeface = SkTypeface::CreateFromStream(data, desc.getFontIndex());
+ SkTypeface* typeface = SkTypeface::CreateFromFontData(data);
if (typeface) {
return typeface;
}
@@ -218,6 +219,17 @@ SkStreamAsset* SkTypeface::openStream(int* ttcIndex) const {
return this->onOpenStream(ttcIndex);
}
+SkFontData* SkTypeface::createFontData() const {
+ return this->onCreateFontData();
+}
+
+// This implementation is temporary until this method can be made pure virtual.
+SkFontData* SkTypeface::onCreateFontData() const {
+ int index;
+ SkAutoTDelete<SkStreamAsset> stream(this->onOpenStream(&index));
+ return new SkFontData(stream.detach(), index, NULL, 0);
+};
+
int SkTypeface::charsToGlyphs(const void* chars, Encoding encoding,
uint16_t glyphs[], int glyphCount) const {
if (glyphCount <= 0) {
« no previous file with comments | « src/core/SkFontMgr.cpp ('k') | src/fonts/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698