Bug 1430216 - For non-scalable fonts, we can't use the linearHoriAdvance field from the glyph slot; use the advance field instead to get proper metrics. r=lsalzman
authorJonathan Kew <jkew@mozilla.com>
Sat, 13 Jan 2018 15:16:44 +0000
changeset 453555 7f9d938235e76b24ac6e169e79b4534b4315bb49
parent 453515 3d28ca7c05d8f9ba3ba6ff1cd5449dce42ae95c1
child 453556 abdfc64ff0889313de38af7c1bfd3382ebd81269
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1430216
milestone59.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 1430216 - For non-scalable fonts, we can't use the linearHoriAdvance field from the glyph slot; use the advance field instead to get proper metrics. r=lsalzman
gfx/thebes/gfxFT2FontBase.cpp
--- a/gfx/thebes/gfxFT2FontBase.cpp
+++ b/gfx/thebes/gfxFT2FontBase.cpp
@@ -514,17 +514,21 @@ gfxFT2FontBase::GetFTGlyphAdvance(uint16
     int32_t flags =
         gfxPlatform::GetPlatform()->FontHintingEnabled()
             ? FT_LOAD_ADVANCE_ONLY
             : FT_LOAD_ADVANCE_ONLY | FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING;
     FT_Fixed advance = 0;
     mozilla::DebugOnly<FT_Error> ftError =
         FT_Load_Glyph(face.get(), aGID, flags);
     MOZ_ASSERT(!ftError);
-    advance = face.get()->glyph->linearHoriAdvance;
+    if (face.get()->face_flags & FT_FACE_FLAG_SCALABLE) {
+        advance = face.get()->glyph->linearHoriAdvance;
+    } else {
+        advance = face.get()->glyph->advance.x << 10; // convert 26.6 to 16.16
+    }
 
     // If freetype emboldening is being used, and it's not a zero-width glyph,
     // adjust the advance to account for the increased width.
     if (mEmbolden && advance > 0) {
         // This is the embolden "strength" used by FT_GlyphSlot_Embolden,
         // converted from 26.6 to 16.16
         FT_Fixed strength = 1024 *
             FT_MulFix(face.get()->units_per_EM,