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

Unified Diff: src/ports/SkFontHost_win.cpp

Issue 1157163007: SkPDF: fall back on paths for unembeddable fonts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-07-15 (Wednesday) 10:13:03 EDT Created 5 years, 5 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
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | tests/PDFPrimitivesTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | tests/PDFPrimitivesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698