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

Unified Diff: src/ports/SkFontHost_linux.cpp

Issue 12676024: Force all font backends to override onGetFontDescriptor, so we can (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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/SkFontHost_linux.cpp
===================================================================
--- src/ports/SkFontHost_linux.cpp (revision 8346)
+++ src/ports/SkFontHost_linux.cpp (working copy)
@@ -261,6 +261,9 @@
virtual const char* getUniqueString() const = 0;
+protected:
+ virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE;
+
private:
FamilyRec* fFamilyRec; // we don't own this, just point to it
bool fIsSysFont;
@@ -457,53 +460,13 @@
///////////////////////////////////////////////////////////////////////////////
-void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
-
- SkFontDescriptor descriptor;
- descriptor.setFamilyName(find_family_name(face));
- descriptor.setStyle(face->style());
- descriptor.setFontFileName(((FamilyTypeface*)face)->getUniqueString());
-
- descriptor.serialize(stream);
-
- const bool isCustomFont = !((FamilyTypeface*)face)->isSysFont();
- if (isCustomFont) {
- // store the entire font in the fontData
- SkStream* fontStream = face->openStream(NULL);
- const uint32_t length = fontStream->getLength();
-
- stream->writePackedUInt(length);
- stream->writeStream(fontStream, length);
-
- fontStream->unref();
- } else {
- stream->writePackedUInt(0);
- }
+void FamilyTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
+ bool* isLocalStream) const {
+ desc->setFamilyName(find_family_name(this));
+ desc->setFontFileName(this->getUniqueString());
+ *isLocalStream = !this->isSysFont();
}
-SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
- load_system_fonts();
-
- SkFontDescriptor descriptor(stream);
- const char* familyName = descriptor.getFamilyName();
- const SkTypeface::Style style = descriptor.getStyle();
-
- const uint32_t customFontDataLength = stream->readPackedUInt();
- if (customFontDataLength > 0) {
-
- // generate a new stream to store the custom typeface
- SkMemoryStream* fontStream = new SkMemoryStream(customFontDataLength - 1);
- stream->read((void*)fontStream->getMemoryBase(), customFontDataLength - 1);
-
- SkTypeface* face = CreateTypefaceFromStream(fontStream);
-
- fontStream->unref();
- return face;
- }
-
- return SkFontHost::CreateTypeface(NULL, familyName, style);
-}
-
///////////////////////////////////////////////////////////////////////////////
SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,

Powered by Google App Engine
This is Rietveld 408576698