Bug 1450209 - Avoid use of CTFontGetAdvancesForGlyphs with variation fonts due to possible Core Text crash. r=mstange

This commit is contained in:
Jonathan Kew 2018-04-06 19:44:05 +01:00
Родитель b12501054b
Коммит 309329c3c0
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -457,6 +457,16 @@ gfxMacFont::CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont,
int32_t
gfxMacFont::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID)
{
if (mVariationFont) {
// Avoid a potential Core Text crash (bug 1450209) by using
// CoreGraphics glyph advance API. This is inferior for 'sbix'
// fonts, but those won't have variations, so it's OK.
int cgAdvance;
if (::CGFontGetGlyphAdvances(mCGFont, &aGID, 1, &cgAdvance)) {
return cgAdvance * mFUnitsConvFactor * 0x10000;
}
}
if (!mCTFont) {
mCTFont = CreateCTFontFromCGFontWithVariations(mCGFont, mAdjustedSize);
if (!mCTFont) { // shouldn't happen, but let's be safe