Bug 1349308 - Ensure we get glyph metrics via Core Text for variation fonts such as faces of SFNSText/Display. r=jrmuizel

This commit is contained in:
Jonathan Kew 2017-04-03 15:45:52 +01:00
parent 28a16a418c
commit 3e217c19d1
4 changed files with 23 additions and 7 deletions

View File

@ -165,12 +165,11 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl
mCGFont(nullptr),
mCTFont(nullptr),
mFontFace(nullptr),
mVariationFont(false)
mVariationFont(aFontEntry->HasVariations())
{
mApplySyntheticBold = aNeedsBold;
auto varCount = aFontStyle->variationSettings.Length();
if (varCount > 0) {
if (mVariationFont && aFontStyle->variationSettings.Length() > 0) {
CGFontRef baseFont = aFontEntry->GetFontRef();
if (!baseFont) {
mIsValid = false;
@ -181,7 +180,6 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl
if (variations) {
mCGFont = ::CGFontCreateCopyWithVariations(baseFont, variations);
::CFRelease(variations);
mVariationFont = true;
} else {
::CFRetain(baseFont);
mCGFont = baseFont;

View File

@ -106,7 +106,7 @@ protected:
Metrics mMetrics;
uint32_t mSpaceGlyph;
bool mVariationFont; // true if variations are in effect
bool mVariationFont; // true if font has OpenType variations
};
#endif /* GFX_MACFONT_H */

View File

@ -54,6 +54,7 @@ public:
bool RequiresAATLayout() const { return mRequiresAAT; }
bool HasVariations();
bool IsCFF();
protected:
@ -72,6 +73,8 @@ protected:
bool mRequiresAAT;
bool mIsCFF;
bool mIsCFFInitialized;
bool mHasVariations;
bool mHasVariationsInitialized;
nsTHashtable<nsUint32HashKey> mAvailableTables;
};

View File

@ -247,6 +247,17 @@ MacOSFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBo
return new gfxMacFont(this, aFontStyle, aNeedsBold);
}
bool
MacOSFontEntry::HasVariations()
{
if (!mHasVariationsInitialized) {
mHasVariationsInitialized = true;
mHasVariations = HasFontTable(TRUETYPE_TAG('f','v','a','r'));
}
return mHasVariations;
}
bool
MacOSFontEntry::IsCFF()
{
@ -268,7 +279,9 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
mFontRefInitialized(false),
mRequiresAAT(false),
mIsCFF(false),
mIsCFFInitialized(false)
mIsCFFInitialized(false),
mHasVariations(false),
mHasVariationsInitialized(false)
{
mWeight = aWeight;
}
@ -285,7 +298,9 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
mFontRefInitialized(false),
mRequiresAAT(false),
mIsCFF(false),
mIsCFFInitialized(false)
mIsCFFInitialized(false),
mHasVariations(false),
mHasVariationsInitialized(false)
{
mFontRef = aFontRef;
mFontRefInitialized = true;