Bug 1321031 pt 3 - Preserve variations settings when creating a new CTFont in SkFontHost_mac. r=lsalzman

This commit is contained in:
Jonathan Kew 2017-01-06 16:35:12 +00:00
parent 3adad63030
commit 4c288caa59

View File

@ -800,6 +800,25 @@ static CTFontRef ctfont_create_exact_copy(CTFontRef baseFont, CGFloat textSize,
// Because we cannot setup the CTFont descriptor to match, the same restriction applies here
// as other uses of CTFontCreateWithGraphicsFont which is that such CTFonts should not escape
// the scaler context, since they aren't 'normal'.
// Not AutoCFRelease<> because CGFontCopyVariations can return null!
CFDictionaryRef variations = CGFontCopyVariations(baseCGFont);
if (variations) {
AutoCFRelease<CFDictionaryRef>
varAttr(CFDictionaryCreate(nullptr,
(const void**)&kCTFontVariationAttribute,
(const void**)&variations,
1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
CFRelease(variations);
AutoCFRelease<CTFontDescriptorRef>
varDesc(CTFontDescriptorCreateWithAttributes(varAttr));
return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, varDesc);
}
return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, nullptr);
}