зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1321031
pt 5 - Preserve any variation settings present in the CGFont when the cairo quartz backend creates a new CTFont. r=jrmuizel
This commit is contained in:
Родитель
a926c70f28
Коммит
67b65a3027
|
@ -335,6 +335,33 @@ const cairo_font_face_backend_t _cairo_quartz_font_face_backend = {
|
|||
_cairo_quartz_font_face_scaled_font_create
|
||||
};
|
||||
|
||||
// Helper to create a CTFont from a CGFont, copying any variations that were
|
||||
// set on the original CGFont.
|
||||
static CTFontRef
|
||||
CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize)
|
||||
{
|
||||
CFDictionaryRef vars = CGFontCopyVariations(aCGFont);
|
||||
CTFontRef ctFont;
|
||||
if (vars) {
|
||||
CFDictionaryRef varAttr =
|
||||
CFDictionaryCreate(NULL,
|
||||
(const void**)&kCTFontVariationAttribute,
|
||||
(const void**)&vars, 1,
|
||||
&kCFTypeDictionaryKeyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks);
|
||||
CFRelease(vars);
|
||||
|
||||
CTFontDescriptorRef varDesc = CTFontDescriptorCreateWithAttributes(varAttr);
|
||||
CFRelease(varAttr);
|
||||
|
||||
ctFont = CTFontCreateWithGraphicsFont(aCGFont, aSize, NULL, varDesc);
|
||||
CFRelease(varDesc);
|
||||
} else {
|
||||
ctFont = CTFontCreateWithGraphicsFont(aCGFont, aSize, NULL, NULL);
|
||||
}
|
||||
return ctFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_quartz_font_face_create_for_cgfont
|
||||
* @font: a #CGFontRef obtained through a method external to cairo.
|
||||
|
@ -365,7 +392,7 @@ cairo_quartz_font_face_create_for_cgfont (CGFontRef font)
|
|||
font_face->cgFont = CGFontRetain (font);
|
||||
|
||||
if (CTFontCreateWithGraphicsFontPtr) {
|
||||
font_face->ctFont = CTFontCreateWithGraphicsFontPtr (font, 1.0, NULL, NULL);
|
||||
font_face->ctFont = CreateCTFontFromCGFontWithVariations (font, 1.0);
|
||||
} else {
|
||||
font_face->ctFont = NULL;
|
||||
}
|
||||
|
@ -570,7 +597,7 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font,
|
|||
-font->base.scale.yy,
|
||||
0, 0);
|
||||
|
||||
ctFont = CTFontCreateWithGraphicsFont (font_face->cgFont, 1.0, NULL, NULL);
|
||||
ctFont = CreateCTFontFromCGFontWithVariations (font_face->cgFont, 1.0);
|
||||
glyphPath = CTFontCreatePathForGlyph (ctFont, glyph, &textMatrix);
|
||||
CFRelease (ctFont);
|
||||
if (!glyphPath)
|
||||
|
|
Загрузка…
Ссылка в новой задаче