Bug 457194. Be careful when we do NS_ceil for font max-ascent/max-descent; we don't want a number that's an integer plus epsilon to round up to the next integer. r=vlad

This commit is contained in:
Robert O'Callahan 2008-10-13 14:08:27 +13:00
parent da78ac865a
commit 7a386793fc

View File

@ -205,6 +205,12 @@ DisableCommonLigatures(ATSUStyle aStyle)
ATSUSetFontFeatures(aStyle, NS_ARRAY_LENGTH(types), types, selectors);
}
static double
RoundToNearestMultiple(double aValue, double aFraction)
{
return floor(aValue/aFraction + 0.5)*aFraction;
}
void
gfxAtsuiFont::InitMetrics(ATSUFontID aFontID, ATSFontRef aFontRef)
{
@ -274,8 +280,10 @@ gfxAtsuiFont::InitMetrics(ATSUFontID aFontID, ATSFontRef aFontRef)
mMetrics.emHeight = size;
mMetrics.maxAscent = NS_ceil(atsMetrics.ascent * size);
mMetrics.maxDescent = NS_ceil(- (atsMetrics.descent * size));
mMetrics.maxAscent =
NS_ceil(RoundToNearestMultiple(atsMetrics.ascent*size, 1/1024.0));
mMetrics.maxDescent =
NS_ceil(-RoundToNearestMultiple(atsMetrics.descent*size, 1/1024.0));
mMetrics.maxHeight = mMetrics.maxAscent + mMetrics.maxDescent;