Bug 947650 - [FT2 fonts] Prefer OS/2 sTypo* metrics to hhea ascent/descent if USE_TYPO_METRICS flag is set, and for OpenType Math fonts. r=karlt

This commit is contained in:
Jonathan Kew 2014-02-04 13:06:27 +00:00
parent a8d40c0ff2
commit f8cc32297f
3 changed files with 22 additions and 10 deletions

View File

@ -124,14 +124,26 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics,
os2->sTypoAscender - os2->sTypoDescender + os2->sTypoLineGap;
lineHeight = typoHeight * yScale;
// maxAscent/maxDescent get used for frame heights, and some fonts
// don't have the HHEA table ascent/descent set (bug 279032).
// We use NS_round here to parallel the pixel-rounded values that
// freetype gives us for ftMetrics.ascender/descender.
aMetrics->maxAscent =
std::max(aMetrics->maxAscent, NS_round(aMetrics->emAscent));
aMetrics->maxDescent =
std::max(aMetrics->maxDescent, NS_round(aMetrics->emDescent));
// If the OS/2 fsSelection USE_TYPO_METRICS bit is set,
// or if this is an OpenType Math font,
// set maxAscent/Descent from the sTypo* fields instead of hhea.
const uint16_t kUseTypoMetricsMask = 1 << 7;
FT_ULong length = 0;
if ((os2->fsSelection & kUseTypoMetricsMask) ||
0 == FT_Load_Sfnt_Table(mFace, FT_MAKE_TAG('M','A','T','H'),
0, nullptr, &length)) {
aMetrics->maxAscent = NS_round(aMetrics->emAscent);
aMetrics->maxDescent = NS_round(aMetrics->emDescent);
} else {
// maxAscent/maxDescent get used for frame heights, and some fonts
// don't have the HHEA table ascent/descent set (bug 279032).
// We use NS_round here to parallel the pixel-rounded values that
// freetype gives us for ftMetrics.ascender/descender.
aMetrics->maxAscent =
std::max(aMetrics->maxAscent, NS_round(aMetrics->emAscent));
aMetrics->maxDescent =
std::max(aMetrics->maxDescent, NS_round(aMetrics->emDescent));
}
} else {
aMetrics->emAscent = aMetrics->maxAscent;
aMetrics->emDescent = aMetrics->maxDescent;

View File

@ -79,4 +79,4 @@ fails-if(OSX) == border-image-repeating-radial-gradient-repeat-repeat-2.html bor
fuzzy(1,1054) fails-if(OSX) == border-image-repeating-radial-gradient-repeat-round-2.html border-image-repeating-radial-gradient-repeat-round-2-ref.html
# border-image-source (-moz-)element
fuzzy(125,5808) == border-image-element.html border-image-element-ref.html
fuzzy(125,5808) fuzzy-if(B2G,151,5809) == border-image-element.html border-image-element-ref.html

View File

@ -5,5 +5,5 @@ random-if(Android||B2G) fails-if(winWidget) == menulist-shrinkwrap-2.xul menulis
== textbox-overflow-1.xul textbox-overflow-1-ref.xul # for bug 749658
# accesskeys are not normally displayed on Mac, so skip this test
skip-if(cocoaWidget) == accesskey.xul accesskey-ref.xul
fails-if(cocoaWidget) fails-if(B2G) == tree-row-outline-1.xul tree-row-outline-1-ref.xul
fails-if(cocoaWidget) == tree-row-outline-1.xul tree-row-outline-1-ref.xul
!= tree-row-outline-1.xul tree-row-outline-1-notref.xul