Bug 1095334 - Adjust ascent/descent to provide centered vertical baseline when reading 'vhea' table. r=smontagu
authorJonathan Kew <jkew@mozilla.com>
Tue, 06 Jan 2015 20:56:02 +0000
changeset 239007 1e64da07365b304b6819a7f06dd76458b6c7ee1f
parent 239006 6536d9885d2e2cc7fab98f5518fb23ad5e1251cf
child 239008 646e58995d5356cdc21cb64d909dfa8f3fd8ba44
push id7472
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 20:36:27 +0000
treeherdermozilla-aurora@300ca104f8fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs1095334
milestone37.0a1
Bug 1095334 - Adjust ascent/descent to provide centered vertical baseline when reading 'vhea' table. r=smontagu
gfx/thebes/gfxFont.cpp
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -3440,18 +3440,22 @@ gfxFont::CreateVerticalMetrics()
     // Read real vertical metrics if available.
     gfxFontEntry::AutoTable vheaTable(mFontEntry, kVheaTableTag);
     if (vheaTable && mFUnitsConvFactor > 0.0) {
         const MetricsHeader* vhea =
             reinterpret_cast<const MetricsHeader*>
                 (hb_blob_get_data(vheaTable, &len));
         if (len >= sizeof(MetricsHeader)) {
             SET_UNSIGNED(maxAdvance, vhea->advanceWidthMax);
-            SET_SIGNED(maxAscent, vhea->ascender);
-            SET_SIGNED(maxDescent, -int16_t(vhea->descender));
+            // Redistribute space between ascent/descent because we want a
+            // centered vertical baseline by default.
+            gfxFloat halfExtent = 0.5 * gfxFloat(mFUnitsConvFactor) *
+                (int16_t(vhea->ascender) - int16_t(vhea->descender));
+            metrics->maxAscent = halfExtent;
+            metrics->maxDescent = halfExtent;
             SET_SIGNED(externalLeading, vhea->lineGap);
         }
     }
 
     // If we didn't set aveCharWidth above, we must be dealing with a non-sfnt
     // font of some kind (Type1, bitmap, vector, ...), so fall back to using
     // whatever the platform backend figured out for horizontal layout.
     // And if we haven't set externalLeading yet, then copy that from the