aboutsummaryrefslogtreecommitdiffstats
path: root/src/ports
diff options
context:
space:
mode:
authordjsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-29 16:06:32 +0000
committerSteve Kondik <shade@chemlab.org>2012-09-11 06:07:40 -0700
commit0a58de2a1de572bb48f9e4027b53820f5c6ada52 (patch)
tree3df806bf9969444affa28c2b604483c9c448392e /src/ports
parent9f378eba14ab88fb600df59e4521fdac2c64e2a2 (diff)
downloadexternal_skia-0a58de2a1de572bb48f9e4027b53820f5c6ada52.zip
external_skia-0a58de2a1de572bb48f9e4027b53820f5c6ada52.tar.gz
external_skia-0a58de2a1de572bb48f9e4027b53820f5c6ada52.tar.bz2
Landing arm patch from contributor.
http://codereview.appspot.com/5649055 git-svn-id: http://skia.googlecode.com/svn/trunk@3541 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkFontHost_linux.cpp76
1 files changed, 33 insertions, 43 deletions
diff --git a/src/ports/SkFontHost_linux.cpp b/src/ports/SkFontHost_linux.cpp
index be99576..64fa2a3 100644
--- a/src/ports/SkFontHost_linux.cpp
+++ b/src/ports/SkFontHost_linux.cpp
@@ -464,53 +464,43 @@ static void load_system_fonts() {
///////////////////////////////////////////////////////////////////////////////
void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
-#if 0
- const char* name = ((FamilyTypeface*)face)->getUniqueString();
-
- stream->write8((uint8_t)face->getStyle());
-
- if (NULL == name || 0 == *name) {
- stream->writePackedUInt(0);
- // SkDebugf("--- fonthost serialize null\n");
- } else {
- uint32_t len = strlen(name);
- stream->writePackedUInt(len);
- stream->write(name, len);
- // SkDebugf("--- fonthost serialize <%s> %d\n", name, face->getStyle());
- }
-#endif
- sk_throw();
+ SkStream* fontStream = ((FamilyTypeface*)face)->openStream();
+
+ // store the length of the custom font
+ uint32_t len = fontStream->getLength();
+ stream->write32(len);
+
+ // store the entire font in the serialized stream
+ void* fontData = malloc(len);
+
+ fontStream->read(fontData, len);
+ stream->write(fontData, len);
+
+ fontStream->unref();
+ free(fontData);
+
+
+// sk_throw();
}
SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
-#if 0
load_system_fonts();
-
- int style = stream->readU8();
-
- int len = stream->readPackedUInt();
- if (len > 0) {
- SkString str;
- str.resize(len);
- stream->read(str.writable_str(), len);
-
- const FontInitRec* rec = gSystemFonts;
- for (size_t i = 0; i < SK_ARRAY_COUNT(gSystemFonts); i++) {
- if (strcmp(rec[i].fFileName, str.c_str()) == 0) {
- // backup until we hit the fNames
- for (int j = i; j >= 0; --j) {
- if (rec[j].fNames != NULL) {
- return SkFontHost::CreateTypeface(NULL, rec[j].fNames[0], NULL, 0,
- (SkTypeface::Style)style);
- }
- }
- }
- }
- }
- return SkFontHost::CreateTypeface(NULL, NULL, NULL, 0, (SkTypeface::Style)style);
-#endif
- sk_throw();
- return NULL;
+
+ // read the length of the custom font from the stream
+ uint32_t len = stream->readU32();
+
+ // generate a new stream to store the custom typeface
+ SkMemoryStream* fontStream = new SkMemoryStream(len);
+ stream->read((void*)fontStream->getMemoryBase(), len);
+
+ SkTypeface* face = CreateTypefaceFromStream(fontStream);
+
+ fontStream->unref();
+
+ return face;
+
+// sk_throw();
+// return NULL;
}
///////////////////////////////////////////////////////////////////////////////