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

Unified Diff: src/ports/SkFontHost_win_dw.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
« src/ports/SkFontHost_android.cpp ('K') | « src/ports/SkFontHost_win.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_win_dw.cpp
===================================================================
--- src/ports/SkFontHost_win_dw.cpp (revision 8346)
+++ src/ports/SkFontHost_win_dw.cpp (working copy)
@@ -485,6 +485,7 @@
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo,
const uint32_t*, uint32_t) const SK_OVERRIDE;
+ virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE;
};
class SkScalerContext_Windows : public SkScalerContext {
@@ -1046,13 +1047,11 @@
path->transform(mat);
}
-void SkFontHost::Serialize(const SkTypeface* rawFace, SkWStream* stream) {
- const DWriteFontTypeface* face = static_cast<const DWriteFontTypeface*>(rawFace);
- SkFontDescriptor descriptor(face->style());
-
+void DWriteFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
+ bool* isLocalStream) const {
// Get the family name.
SkTScopedComPtr<IDWriteLocalizedStrings> dwFamilyNames;
- HRV(face->fDWriteFontFamily->GetFamilyNames(&dwFamilyNames));
+ HRV(fDWriteFontFamily->GetFamilyNames(&dwFamilyNames));
UINT32 dwFamilyNamesLength;
HRV(dwFamilyNames->GetStringLength(0, &dwFamilyNamesLength));
@@ -1070,38 +1069,10 @@
str_len = WideCharToMultiByte(CP_UTF8, 0, dwFamilyNameChar.begin(), -1,
utf8FamilyName.begin(), str_len, NULL, NULL);
- descriptor.setFamilyName(utf8FamilyName.begin());
- //TODO: FileName and PostScriptName currently unsupported.
-
- descriptor.serialize(stream);
-
- if (NULL != face->fDWriteFontFileLoader.get()) {
- // store the entire font in the fontData
- SkStream* fontStream = face->fDWriteFontFileLoader->fStream.get();
- const uint32_t length = fontStream->getLength();
-
- stream->writePackedUInt(length);
- stream->writeStream(fontStream, length);
- } else {
- stream->writePackedUInt(0);
- }
+ desc->setFamilyName(utf8FamilyName.begin());
+ *isLocalStream = SkToBool(fDWriteFontFileLoader.get());
}
-SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
- SkFontDescriptor descriptor(stream);
-
- const uint32_t customFontDataLength = stream->readPackedUInt();
- if (customFontDataLength > 0) {
- // generate a new stream to store the custom typeface
- SkAutoTUnref<SkMemoryStream> fontStream(SkNEW_ARGS(SkMemoryStream, (customFontDataLength - 1)));
- stream->read((void*)fontStream->getMemoryBase(), customFontDataLength - 1);
-
- return CreateTypefaceFromStream(fontStream.get());
- }
-
- return SkFontHost::CreateTypeface(NULL, descriptor.getFamilyName(), descriptor.getStyle());
-}
-
SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
IDWriteFactory* factory;
HRN(get_dwrite_factory(&factory));
« src/ports/SkFontHost_android.cpp ('K') | « src/ports/SkFontHost_win.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698