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

Unified Diff: src/ports/SkFontHost_win.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_win.cpp
===================================================================
--- src/ports/SkFontHost_win.cpp (revision 8346)
+++ src/ports/SkFontHost_win.cpp (working copy)
@@ -216,6 +216,7 @@
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo,
const uint32_t*, uint32_t) const SK_OVERRIDE;
+ virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE;
};
class FontMemResourceTypeface : public LogFontTypeface {
@@ -1279,19 +1280,17 @@
#endif
}
-void SkFontHost::Serialize(const SkTypeface* rawFace, SkWStream* stream) {
- const LogFontTypeface* face = static_cast<const LogFontTypeface*>(rawFace);
- SkFontDescriptor descriptor(face->style());
-
+void LogFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc,
+ bool* isLocalStream) const {
// Get the actual name of the typeface. The logfont may not know this.
- HFONT font = CreateFontIndirect(&face->fLogFont);
+ HFONT font = CreateFontIndirect(&fLogFont);
HDC deviceContext = ::CreateCompatibleDC(NULL);
HFONT savefont = (HFONT)SelectObject(deviceContext, font);
int fontNameLen; //length of fontName in TCHARS.
if (0 == (fontNameLen = GetTextFace(deviceContext, 0, NULL))) {
- LogFontTypeface::EnsureAccessible(rawFace);
+ call_ensure_accessible(fLogFont);
if (0 == (fontNameLen = GetTextFace(deviceContext, 0, NULL))) {
fontNameLen = 0;
}
@@ -1299,7 +1298,7 @@
SkAutoSTArray<LF_FULLFACESIZE, TCHAR> fontName(fontNameLen+1);
if (0 == GetTextFace(deviceContext, fontNameLen, fontName.get())) {
- LogFontTypeface::EnsureAccessible(rawFace);
+ call_ensure_accessible(fLogFont);
if (0 == GetTextFace(deviceContext, fontNameLen, fontName.get())) {
fontName[0] = 0;
}
@@ -1315,41 +1314,11 @@
SkString familyName;
tchar_to_skstring(fontName.get(), &familyName);
- descriptor.setFamilyName(familyName.c_str());
- //TODO: FileName and PostScriptName currently unsupported.
- descriptor.serialize(stream);
-
- if (face->fSerializeAsStream) {
- // store the entire font in the fontData
- SkAutoTUnref<SkStream> fontStream(face->openStream(NULL));
- if (fontStream.get()) {
- const uint32_t length = fontStream->getLength();
- stream->writePackedUInt(length);
- stream->writeStream(fontStream, length);
- } else {
- stream->writePackedUInt(0);
- }
- } else {
- stream->writePackedUInt(0);
- }
+ desc->setFamilyName(familyName.c_str());
+ *isLocalStream = this->fSerializeAsStream;
}
-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());
-}
-
static bool getWidthAdvance(HDC hdc, int gId, int16_t* advance) {
// Initialize the MAT2 structure to the identify transformation matrix.
static const MAT2 mat2 = {SkScalarToFIXED(1), SkScalarToFIXED(0),

Powered by Google App Engine
This is Rietveld 408576698