| 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),
|
|
|