Tell PDF on Mac when a font is a variation font.

PDF needs to know when a font is a variation font so that it knows
it cannot just embed the typeface.

BUG=chromium:697916

Change-Id: I85091e444a235545f0f63fe131729c107bb664a0
Reviewed-on: https://skia-review.googlesource.com/9158
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2017-03-02 13:31:16 -05:00 committed by Skia Commit-Bot
parent e646afb49e
commit c66390560e

View File

@ -1488,6 +1488,18 @@ SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics(
}
}
// In 10.10 and earlier, CTFontCopyVariationAxes and CTFontCopyVariation do not work when
// applied to fonts which started life with CGFontCreateWithDataProvider (they simply always
// return nullptr). As a result, we are limited to CGFontCopyVariationAxes and
// CGFontCopyVariations here until support for 10.10 and earlier is removed.
UniqueCFRef<CGFontRef> cgFont(CTFontCopyGraphicsFont(ctFont.get(), nullptr));
if (cgFont) {
UniqueCFRef<CFArrayRef> cgAxes(CGFontCopyVariationAxes(cgFont.get()));
if (cgAxes && CFArrayGetCount(cgAxes.get()) > 0) {
info->fFlags |= SkAdvancedTypefaceMetrics::kMultiMaster_FontFlag;
}
}
CFIndex glyphCount = CTFontGetGlyphCount(ctFont.get());
info->fLastGlyphID = SkToU16(glyphCount - 1);
info->fEmSize = CTFontGetUnitsPerEm(ctFont.get());