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

Unified Diff: src/ports/SkFontHost_FreeType.cpp

Issue 107863002: [PDF] Fix font embedding restrictions. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix Mac Created 7 years 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_FreeType.cpp
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index fd87a66dc6a8f8d9da40fb993c459e8d4e52a966..134cc052be52291b83c6ec957e38425a494d495f 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -411,6 +411,20 @@ static bool canEmbed(FT_Face face) {
#endif
}
+static bool canSubset(FT_Face face) {
+#ifdef FT_FSTYPE_NO_SUBSETTING
+ FT_UShort fsType = FT_Get_FSType_Flags(face);
+ return (fsType & FT_FSTYPE_NO_SUBSETTING) == 0;
+#else
+ // No subset is 0x100.
+ TT_OS2* os2_table;
+ if ((os2_table = (TT_OS2*)FT_Get_Sfnt_Table(face, ft_sfnt_os2)) != NULL) {
+ return (os2_table->fsType & 0x100) == 0;
+ }
+ return false; // We tried, fail safe.
+#endif
+}
+
static bool GetLetterCBox(FT_Face face, char letter, FT_BBox* bbox) {
const FT_UInt glyph_id = FT_Get_Char_Index(face, letter);
if (!glyph_id)
@@ -495,7 +509,21 @@ SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics;
info->fFontName.set(FT_Get_Postscript_Name(face));
- info->fMultiMaster = FT_HAS_MULTIPLE_MASTERS(face);
+ info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag;
+ if (FT_HAS_MULTIPLE_MASTERS(face)) {
+ info->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>(
+ info->fFlags, SkAdvancedTypefaceMetrics::kMultiMaster_FontFlag);
+ }
+ if (!canEmbed(face)) {
+ info->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>(
+ info->fFlags,
+ SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag);
+ }
+ if (!canSubset(face)) {
+ info->fFlags = SkTBitOr<SkAdvancedTypefaceMetrics::FontFlags>(
+ info->fFlags,
+ SkAdvancedTypefaceMetrics::kNotSubsettable_FontFlag);
+ }
info->fLastGlyphID = face->num_glyphs - 1;
info->fEmSize = 1000;
@@ -588,8 +616,7 @@ SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics(
info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax,
face->bbox.xMax, face->bbox.yMin);
- if (!canEmbed(face) || !FT_IS_SCALABLE(face) ||
- info->fType == SkAdvancedTypefaceMetrics::kOther_Font) {
+ if (!FT_IS_SCALABLE(face)) {
perGlyphInfo = SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo;
}
@@ -652,9 +679,6 @@ SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics(
populate_glyph_to_unicode(face, &(info->fGlyphToUnicode));
}
- if (!canEmbed(face))
- info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font;
-
return info;
#endif
}

Powered by Google App Engine
This is Rietveld 408576698