From c3a2ae5823049f589c1841a855bb5675d69e31dd Mon Sep 17 00:00:00 2001 From: "vandebo@chromium.org" Date: Thu, 3 Feb 2011 21:48:23 +0000 Subject: [PATCH] Improve usability of SkAdvancedTypefaceMetrics for non PDF cases. Change the code to fill out the metrics even if the font isn't embeddable. Previously, if the font wasn't embeddable, the code would set the type to not embeddable and return without filling out the rest of the metrics. Review URL: http://codereview.appspot.com/3973053 git-svn-id: http://skia.googlecode.com/svn/trunk@758 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/ports/SkFontHost_FreeType.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index fd6af07..1b1d47b 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -449,9 +449,7 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( bool cid = false; const char* fontType = FT_Get_X11_Font_Format(face); - if (!canEmbed(face)) { - info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; - } else if (strcmp(fontType, "Type 1") == 0) { + if (strcmp(fontType, "Type 1") == 0) { info->fType = SkAdvancedTypefaceMetrics::kType1_Font; } else if (strcmp(fontType, "CID Type 1") == 0) { info->fType = SkAdvancedTypefaceMetrics::kType1CID_Font; @@ -468,12 +466,6 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( } } - if (info->fType == SkAdvancedTypefaceMetrics::kOther_Font || - info->fType == SkAdvancedTypefaceMetrics::kNotEmbeddable_Font || - !FT_IS_SCALABLE(face)) { - perGlyphInfo = false; - } - SkASSERT(!FT_HAS_VERTICAL(face)); #ifdef FT_IS_CID_KEYED SkASSERT(FT_IS_CID_KEYED(face) == @@ -550,7 +542,8 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax, face->bbox.xMax, face->bbox.yMin); - if (perGlyphInfo) { + if (perGlyphInfo && canEmbed(face) && FT_IS_SCALABLE(face) && + info->fType != SkAdvancedTypefaceMetrics::kOther_Font) { if (FT_IS_FIXED_WIDTH(face)) { appendRange(&info->fGlyphWidths, 0); int16_t advance = face->max_advance_width; @@ -592,6 +585,9 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics( } } + if (!canEmbed(face)) + info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; + unref_ft_face(face); return info; } -- 2.7.4