From bf51b7a7abb7e876f1be332d242d9cffb1925721 Mon Sep 17 00:00:00 2001 From: Ted Mielczarek Date: Wed, 20 Aug 2008 10:42:57 -0400 Subject: [PATCH] Backed out changeset d55aac0ec553, bug 446529 - Disable discretionary ligatures on Mac, due to reftest failures on mac REFTEST TEST-UNEXPECTED-FAIL | file:///builds/slave/trunk_darwin_mini01/build/layout/reftests/text/wordwrap-01.html | REFTEST TEST-UNEXPECTED-FAIL | file:///builds/slave/trunk_darwin_mini01/build/layout/reftests/text/wordwrap-03.html | --- gfx/thebes/src/gfxAtsuiFonts.cpp | 104 ++++++++++++++----------------- 1 file changed, 48 insertions(+), 56 deletions(-) diff --git a/gfx/thebes/src/gfxAtsuiFonts.cpp b/gfx/thebes/src/gfxAtsuiFonts.cpp index 75b61541809a..9a1a3e9346d0 100644 --- a/gfx/thebes/src/gfxAtsuiFonts.cpp +++ b/gfx/thebes/src/gfxAtsuiFonts.cpp @@ -168,85 +168,51 @@ ATSUFontID gfxAtsuiFont::GetATSUFontID() return GetFontEntry()->GetFontID(); } -static void -SetLigatureFeatures(ATSUStyle aStyle, PRBool aEnableLigatures) -{ - static const ATSUFontFeatureType types[] = { - kLigaturesType, - kLigaturesType, - kLigaturesType, - kLigaturesType, - kLigaturesType, - kLigaturesType, - kLigaturesType, - kLigaturesType - }; - static const ATSUFontFeatureType disablingSelectors[NS_ARRAY_LENGTH(types)] = { - kCommonLigaturesOffSelector, - kRareLigaturesOffSelector, - kLogosOffSelector, - kRebusPicturesOffSelector, - kDiphthongLigaturesOffSelector, - kSquaredLigaturesOffSelector, - kAbbrevSquaredLigaturesOffSelector, - kSymbolLigaturesOffSelector - }; - static const ATSUFontFeatureType enablingSelectors[NS_ARRAY_LENGTH(types)] = { - kCommonLigaturesOnSelector, - kRareLigaturesOffSelector, - kLogosOffSelector, - kRebusPicturesOffSelector, - kDiphthongLigaturesOffSelector, - kSquaredLigaturesOffSelector, - kAbbrevSquaredLigaturesOffSelector, - kSymbolLigaturesOffSelector - }; - ATSUSetFontFeatures(aStyle, NS_ARRAY_LENGTH(types), types, - aEnableLigatures ? enablingSelectors : disablingSelectors); -} - void gfxAtsuiFont::InitMetrics(ATSUFontID aFontID, ATSFontRef aFontRef) { /* Create the ATSUStyle */ + ATSUAttributeTag styleTags[] = { + kATSUFontTag, + kATSUSizeTag, + kATSUFontMatrixTag + }; + + ByteCount styleArgSizes[] = { + sizeof(ATSUFontID), + sizeof(Fixed), + sizeof(CGAffineTransform), + sizeof(Fract) + }; + gfxFloat size = PR_MAX(((mAdjustedSize != 0.0f) ? mAdjustedSize : GetStyle()->size), 1.0f); //fprintf (stderr, "string: '%s', size: %f\n", NS_ConvertUTF16toUTF8(aString).get(), size); - if (mATSUStyle) - ATSUDisposeStyle(mATSUStyle); - - ATSUFontID fid = aFontID; // fSize is in points (72dpi) Fixed fSize = FloatToFixed(size); + ATSUFontID fid = aFontID; + // make the font render right-side up CGAffineTransform transform = CGAffineTransformMakeScale(1, -1); - static const ATSUAttributeTag styleTags[] = { - kATSUFontTag, - kATSUSizeTag, - kATSUFontMatrixTag - }; - const ATSUAttributeValuePtr styleArgs[NS_ARRAY_LENGTH(styleTags)] = { + ATSUAttributeValuePtr styleArgs[] = { &fid, &fSize, - &transform - }; - static const ByteCount styleArgSizes[NS_ARRAY_LENGTH(styleTags)] = { - sizeof(ATSUFontID), - sizeof(Fixed), - sizeof(CGAffineTransform) + &transform, }; + if (mATSUStyle) + ATSUDisposeStyle(mATSUStyle); + ATSUCreateStyle(&mATSUStyle); ATSUSetAttributes(mATSUStyle, - NS_ARRAY_LENGTH(styleTags), + sizeof(styleTags)/sizeof(ATSUAttributeTag), styleTags, styleArgSizes, styleArgs); - SetLigatureFeatures(mATSUStyle, PR_TRUE); /* Now pull out the metrics */ @@ -1297,6 +1263,32 @@ GetFontPrefLangFor(PRUint8 aUnicodeRange) } } +static void +DisableOptionalLigaturesInStyle(ATSUStyle aStyle) +{ + static ATSUFontFeatureType selectors[] = { + kCommonLigaturesOffSelector, + kRareLigaturesOffSelector, + kLogosOffSelector, + kRebusPicturesOffSelector, + kDiphthongLigaturesOffSelector, + kSquaredLigaturesOffSelector, + kAbbrevSquaredLigaturesOffSelector, + kSymbolLigaturesOffSelector + }; + static ATSUFontFeatureType types[NS_ARRAY_LENGTH(selectors)] = { + kLigaturesType, + kLigaturesType, + kLigaturesType, + kLigaturesType, + kLigaturesType, + kLigaturesType, + kLigaturesType, + kLigaturesType + }; + ATSUSetFontFeatures(aStyle, NS_ARRAY_LENGTH(selectors), types, selectors); +} + // 361695 - ATSUI only does glyph mirroring when the font contains a 'prop' table // with glyph mirroring info, the character mirroring has to be done manually in the // fallback case. Only used for RTL text runs. The autoptr for the mirrored copy @@ -1389,7 +1381,7 @@ gfxAtsuiFontGroup::InitTextRun(gfxTextRun *aRun, status = ATSUCreateAndCopyStyle(mainStyle, &mainStyle); if (status == noErr) { stylesToDispose.AppendElement(mainStyle); - SetLigatureFeatures(mainStyle, PR_FALSE); + DisableOptionalLigaturesInStyle(mainStyle); } }