Index: src/ports/SkFontHost_win.cpp |
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp |
index 953a9e457243f2be4755b64476d30c0606962f52..d6bd0a175f6bfda90f87e514919a15dda25cb14f 100755 |
--- a/src/ports/SkFontHost_win.cpp |
+++ b/src/ports/SkFontHost_win.cpp |
@@ -252,6 +252,7 @@ public: |
} |
protected: |
+ bool onCanEmbed() const override; |
SkStreamAsset* onOpenStream(int* ttcIndex) const override; |
SkScalerContext* onCreateScalerContext(const SkDescriptor*) const override; |
void onFilterRec(SkScalerContextRec*) const override; |
@@ -1729,6 +1730,38 @@ static bool getWidthAdvance(HDC hdc, int gId, int16_t* advance) { |
return true; |
} |
+bool LogFontTypeface::onCanEmbed() const { |
+ bool ret = false; |
+ LOGFONT lf = fLogFont; |
+ HDC hdc = CreateCompatibleDC(NULL); |
+ HFONT font = CreateFontIndirect(&lf); |
+ HFONT savefont = (HFONT)SelectObject(hdc, font); |
+ HFONT designFont = NULL; |
+ |
+ OUTLINETEXTMETRIC otm; |
+ if (0 == GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) { |
+ call_ensure_accessible(lf); |
+ if (0 == GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) { |
+ goto Done; |
+ } |
+ } |
+ lf.lfHeight = -SkToS32(otm.otmEMSquare); |
+ designFont = CreateFontIndirect(&lf); |
+ SelectObject(hdc, designFont); |
+ if (0 == GetOutlineTextMetrics(hdc, sizeof(otm), &otm)) { |
+ goto Done; |
+ } |
+ // If bit 1 is set, the font may not be embedded in a document. |
+ ret = (0 == (otm.otmfsType & 0x1)); |
+ |
+Done: |
+ SelectObject(hdc, savefont); |
+ DeleteObject(designFont); |
+ DeleteObject(font); |
+ DeleteDC(hdc); |
+ return ret; |
+} |
+ |
bungeman-skia
2015/07/15 18:09:01
I think onGetFamilyName above is a little more san
|
SkAdvancedTypefaceMetrics* LogFontTypeface::onGetAdvancedTypefaceMetrics( |
PerGlyphInfo perGlyphInfo, |
const uint32_t* glyphIDs, |