From 4c288caa59538cbdf9583b578ffaa284f39fe8bf Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Fri, 6 Jan 2017 16:35:12 +0000 Subject: [PATCH] Bug 1321031 pt 3 - Preserve variations settings when creating a new CTFont in SkFontHost_mac. r=lsalzman --- gfx/skia/skia/src/ports/SkFontHost_mac.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gfx/skia/skia/src/ports/SkFontHost_mac.cpp b/gfx/skia/skia/src/ports/SkFontHost_mac.cpp index da1399504ee8..76b691d19139 100644 --- a/gfx/skia/skia/src/ports/SkFontHost_mac.cpp +++ b/gfx/skia/skia/src/ports/SkFontHost_mac.cpp @@ -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 + varAttr(CFDictionaryCreate(nullptr, + (const void**)&kCTFontVariationAttribute, + (const void**)&variations, + 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks)); + CFRelease(variations); + + AutoCFRelease + varDesc(CTFontDescriptorCreateWithAttributes(varAttr)); + + return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, varDesc); + } + return CTFontCreateWithGraphicsFont(baseCGFont, textSize, transform, nullptr); }