aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_mac_coretext.cpp
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-02 20:39:53 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-02 20:39:53 +0000
commitc8ccfb0fbadfdcadcc860bc648c5ac42aa9277b1 (patch)
treed5a4a1aea6aee6b6d4c40c7807f2c88dac69e5b3 /src/ports/SkFontHost_mac_coretext.cpp
parentc1dd88852a37de9f8d1d3ed75593614e41d51b46 (diff)
Check to see if font is TrueType before making TrueType specific calls.
See chromium bug 116185 Review URL: https://codereview.appspot.com/5731046 git-svn-id: http://skia.googlecode.com/svn/trunk@3309 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports/SkFontHost_mac_coretext.cpp')
-rw-r--r--src/ports/SkFontHost_mac_coretext.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/ports/SkFontHost_mac_coretext.cpp b/src/ports/SkFontHost_mac_coretext.cpp
index d39db2a273..c5ac27ee57 100644
--- a/src/ports/SkFontHost_mac_coretext.cpp
+++ b/src/ports/SkFontHost_mac_coretext.cpp
@@ -1635,10 +1635,24 @@ SkAdvancedTypefaceMetrics* SkFontHost::GetAdvancedTypefaceMetrics(
populate_glyph_to_unicode(ctFont, glyphCount, &info->fGlyphToUnicode);
}
- // TODO: get font type, ala:
- // CFTypeRef attr = CTFontCopyAttribute(ctFont, kCTFontFormatAttribute);
- info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font;
info->fStyle = 0;
+
+ // If it's not a truetype font, mark it as 'other'. Assume that TrueType
+ // fonts always have glyf tables. CTFontCopyAttribute() does not always
+ // succeed in determining this directly.
+ if (!GetTableSize(fontID, 'glyf')) {
+ info->fType = SkAdvancedTypefaceMetrics::kOther_Font;
+ info->fItalicAngle = 0;
+ info->fAscent = 0;
+ info->fDescent = 0;
+ info->fStemV = 0;
+ info->fCapHeight = 0;
+ info->fBBox = SkIRect::MakeEmpty();
+ CFSafeRelease(ctFont);
+ return info;
+ }
+
+ info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font;
CTFontSymbolicTraits symbolicTraits = CTFontGetSymbolicTraits(ctFont);
if (symbolicTraits & kCTFontMonoSpaceTrait) {
info->fStyle |= SkAdvancedTypefaceMetrics::kFixedPitch_Style;