Bug 1394236 - For Apple fonts that include a 'kerx' table, prefer the Core Text shaping path so that we get kerning support. r=jrmuizel
authorJonathan Kew <jkew@mozilla.com>
Fri, 08 Sep 2017 15:33:48 +0100
changeset 661568 bd81dcf6af6067eff31ce2517b4cad9913188253
parent 661567 0b442d470556cd39f407c3395b006764b3038bf0
child 661569 d8ce26333a8b3b45a26199d79e8db6cc553c8068
push id78830
push userasasaki@mozilla.com
push dateFri, 08 Sep 2017 19:44:43 +0000
reviewersjrmuizel
bugs1394236
milestone57.0a1
Bug 1394236 - For Apple fonts that include a 'kerx' table, prefer the Core Text shaping path so that we get kerning support. r=jrmuizel
gfx/thebes/gfxMacPlatformFontList.mm
--- a/gfx/thebes/gfxMacPlatformFontList.mm
+++ b/gfx/thebes/gfxMacPlatformFontList.mm
@@ -178,24 +178,27 @@ MacOSFontEntry::ReadCMAP(FontInfoData *a
     }
 
     if (NS_SUCCEEDED(rv) && !HasGraphiteTables()) {
         // We assume a Graphite font knows what it's doing,
         // and provides whatever shaping is needed for the
         // characters it supports, so only check/clear the
         // complex-script ranges for non-Graphite fonts
 
-        // for layout support, check for the presence of mort/morx and/or
+        // for layout support, check for the presence of mort/morx/kerx and/or
         // opentype layout tables
         bool hasAATLayout = HasFontTable(TRUETYPE_TAG('m','o','r','x')) ||
                             HasFontTable(TRUETYPE_TAG('m','o','r','t'));
+        bool hasAppleKerning = HasFontTable(TRUETYPE_TAG('k','e','r','x'));
         bool hasGSUB = HasFontTable(TRUETYPE_TAG('G','S','U','B'));
         bool hasGPOS = HasFontTable(TRUETYPE_TAG('G','P','O','S'));
-        if (hasAATLayout && !(hasGSUB || hasGPOS)) {
-            mRequiresAAT = true; // prefer CoreText if font has no OTL tables
+        if ((hasAATLayout && !(hasGSUB || hasGPOS)) || hasAppleKerning) {
+            mRequiresAAT = true; // prefer CoreText if font has no OTL tables,
+                                 // or if it uses the Apple-specific 'kerx'
+                                 // variant of kerning table
         }
 
         for (const ScriptRange* sr = gfxPlatformFontList::sComplexScriptRanges;
              sr->rangeStart; sr++) {
             // check to see if the cmap includes complex script codepoints
             if (charmap->TestRange(sr->rangeStart, sr->rangeEnd)) {
                 if (hasAATLayout) {
                     // prefer CoreText for Apple's complex-script fonts,