Bug 1293210 - get cap height from FT2 backend. r=jfkthame

MozReview-Commit-ID: 7EnaxRYpwJU

--HG--
extra : rebase_source : 043d0f5601d261adb122c5ffe408daa07965fd4b
This commit is contained in:
Jeremy Chen 2016-08-18 17:43:54 +08:00
parent 16b102d35e
commit 5459f4df5a

View File

@ -67,6 +67,7 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics,
aMetrics->zeroOrAveCharWidth = spaceWidth;
const gfxFloat xHeight = 0.5 * emHeight;
aMetrics->xHeight = xHeight;
aMetrics->capHeight = aMetrics->maxAscent;
const gfxFloat underlineSize = emHeight / 14.0;
aMetrics->underlineSize = underlineSize;
aMetrics->underlineOffset = -underlineSize;
@ -175,6 +176,17 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics,
}
aMetrics->aveCharWidth = 0.0; // updated below
}
if (GetCharExtents('H', &extents) && extents.y_bearing < 0.0) {
aMetrics->capHeight = -extents.y_bearing;
} else {
if (os2 && os2->sCapHeight && yScale > 0.0) {
aMetrics->capHeight = os2->sCapHeight * yScale;
} else {
aMetrics->capHeight = aMetrics->maxAscent;
}
}
// aveCharWidth is used for the width of text input elements so be
// liberal rather than conservative in the estimate.
if (os2 && os2->xAvgCharWidth) {