Bug 1553889 - Apply the AAT 'trak' table to macOS fonts regardless of whether we shaped using CoreText or HarfBuzz. r=jrmuizel
☠☠ backed out by 46eeb92b85f8 ☠ ☠
authorJonathan Kew <jkew@mozilla.com>
Mon, 27 May 2019 14:48:25 +0000
changeset 475757 91d8ca122edaf8e547b832f6e7f06e32cb13523a
parent 475756 b9a0f1a3364270c102b8d7103bebcb576a0e2deb
child 475758 f1f333d752907c5c3e0c96846f0e669daa178233
push id86462
push userjkew@mozilla.com
push dateMon, 27 May 2019 17:42:51 +0000
treeherderautoland@91d8ca122eda [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1553889
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1553889 - Apply the AAT 'trak' table to macOS fonts regardless of whether we shaped using CoreText or HarfBuzz. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D32447
gfx/thebes/gfxMacFont.cpp
--- a/gfx/thebes/gfxMacFont.cpp
+++ b/gfx/thebes/gfxMacFont.cpp
@@ -190,51 +190,54 @@ bool gfxMacFont::ShapeText(DrawTarget* a
                            uint32_t aOffset, uint32_t aLength, Script aScript,
                            bool aVertical, RoundingFlags aRounding,
                            gfxShapedText* aShapedText) {
   if (!mIsValid) {
     NS_WARNING("invalid font! expect incorrect text rendering");
     return false;
   }
 
+  bool ok = false;
+
   // Currently, we don't support vertical shaping via CoreText,
   // so we ignore RequiresAATLayout if vertical is requested.
   auto macFontEntry = static_cast<MacOSFontEntry*>(GetFontEntry());
   if (macFontEntry->RequiresAATLayout() && !aVertical &&
       StaticPrefs::CoreTextEnabled()) {
     if (!mCoreTextShaper) {
       mCoreTextShaper = MakeUnique<gfxCoreTextShaper>(this);
     }
-    if (mCoreTextShaper->ShapeText(aDrawTarget, aText, aOffset, aLength,
-                                   aScript, aVertical, aRounding,
-                                   aShapedText)) {
+    ok = mCoreTextShaper->ShapeText(aDrawTarget, aText, aOffset, aLength,
+                                    aScript, aVertical, aRounding, aShapedText);
+    if (ok) {
       PostShapingFixup(aDrawTarget, aText, aOffset, aLength, aVertical,
                        aShapedText);
-
-      if (macFontEntry->HasTrackingTable()) {
-        // Convert font size from device pixels back to CSS px
-        // to use in selecting tracking value
-        float trackSize = GetAdjustedSize() *
-                          aShapedText->GetAppUnitsPerDevUnit() /
-                          AppUnitsPerCSSPixel();
-        float tracking =
-            macFontEntry->TrackingForCSSPx(trackSize) * mFUnitsConvFactor;
-        // Applying tracking is a lot like the adjustment we do for
-        // synthetic bold: we want to apply between clusters, not to
-        // non-spacing glyphs within a cluster. So we can reuse that
-        // helper here.
-        aShapedText->AdjustAdvancesForSyntheticBold(tracking, aOffset, aLength);
-      }
-
-      return true;
     }
   }
 
-  return gfxFont::ShapeText(aDrawTarget, aText, aOffset, aLength, aScript,
+  if (!ok) {
+    ok = gfxFont::ShapeText(aDrawTarget, aText, aOffset, aLength, aScript,
                             aVertical, aRounding, aShapedText);
+  }
+
+  if (ok && macFontEntry->HasTrackingTable()) {
+    // Convert font size from device pixels back to CSS px
+    // to use in selecting tracking value
+    float trackSize = GetAdjustedSize() * aShapedText->GetAppUnitsPerDevUnit() /
+                      AppUnitsPerCSSPixel();
+    float tracking =
+        macFontEntry->TrackingForCSSPx(trackSize) * mFUnitsConvFactor;
+    // Applying tracking is a lot like the adjustment we do for
+    // synthetic bold: we want to apply between clusters, not to
+    // non-spacing glyphs within a cluster. So we can reuse that
+    // helper here.
+    aShapedText->AdjustAdvancesForSyntheticBold(tracking, aOffset, aLength);
+  }
+
+  return ok;
 }
 
 bool gfxMacFont::SetupCairoFont(DrawTarget* aDrawTarget) {
   if (cairo_scaled_font_status(mScaledFont) != CAIRO_STATUS_SUCCESS) {
     // Don't cairo_set_scaled_font as that would propagate the error to
     // the cairo_t, precluding any further drawing.
     return false;
   }