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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonathan Kew 2019-05-28 17:05:25 +00:00
parent 9ef9fc2fd8
commit ca3651796b
3 changed files with 26 additions and 23 deletions

View File

@ -195,6 +195,8 @@ bool gfxMacFont::ShapeText(DrawTarget* aDrawTarget, const char16_t* aText,
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());
@ -203,33 +205,34 @@ bool gfxMacFont::ShapeText(DrawTarget* aDrawTarget, const char16_t* aText,
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) {

View File

@ -1425,7 +1425,7 @@ fuzzy-if(Android,0-5,0-1656) fuzzy-if(skiaContent,0-1,0-1200) == 512410.html 512
== 512631-1.html 512631-1-ref.html
== 513153-1a.html 513153-1-ref.html
== 513153-1b.html 513153-1-ref.html
fuzzy-if(webrender&&winWidget,82-82,76-76) fuzzy-if(webrender&&OSX,34-34,138-138) == 513153-2a.html 513153-2-ref.html
fuzzy-if(webrender&&winWidget,82-82,76-76) == 513153-2a.html 513153-2-ref.html
fuzzy-if(webrender&&OSX,34-34,138-138) == 513153-2b.html 513153-2-ref.html
== 513318-1.xul 513318-1-ref.xul
fails-if(Android&&(!asyncPan)) != 513318-2.xul 513318-2-ref.xul

View File

@ -5,7 +5,7 @@ fuzzy-if(gtkWidget||webrender,0-1,0-10) fails-if(Android) == background.html bac
fuzzy-if(gtkWidget,0-1,0-10) fails-if(Android) == style.html style-ref.xul
!= width-clip.html width-clip-ref.html
fails-if(Android) == color-inherit.html color-inherit-ref.html
fuzzy-if(Android,0-2,0-2) fails-if(webrender&&!cocoaWidget) == dynamic-max-width.html dynamic-max-width-ref.html # bug 1496542 for webrender.
fuzzy-if(Android,0-2,0-2) fuzzy-if(OSX,0-34,0-134) fails-if(webrender&&!cocoaWidget) == dynamic-max-width.html dynamic-max-width-ref.html # bug 1496542 for webrender.
== label-min-inline-size.html label-min-inline-size-ref.html
== css-overflow.html css-overflow-ref.html
== css-display.html css-display-ref.html