Bug 1029307 - remove subscript/superscript metrics. r=heycam

This commit is contained in:
John Daggett 2014-06-28 15:40:36 +09:00
parent c0310a0a41
commit 9beb5203b2
7 changed files with 6 additions and 59 deletions

View File

@ -316,8 +316,6 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption)
fontMetrics.strikethroughPosition * mFUnitsConvFactor;
mMetrics->strikeoutSize =
fontMetrics.strikethroughThickness * mFUnitsConvFactor;
mMetrics->superscriptOffset = 0;
mMetrics->subscriptOffset = 0;
SanitizeMetrics(mMetrics, GetFontEntry()->mIsBadUnderlineFont);
@ -329,9 +327,8 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption)
printf(" internalLeading: %f externalLeading: %f\n", mMetrics->internalLeading, mMetrics->externalLeading);
printf(" spaceWidth: %f aveCharWidth: %f zeroOrAve: %f xHeight: %f\n",
mMetrics->spaceWidth, mMetrics->aveCharWidth, mMetrics->zeroOrAveCharWidth, mMetrics->xHeight);
printf(" uOff: %f uSize: %f stOff: %f stSize: %f supOff: %f subOff: %f\n",
mMetrics->underlineOffset, mMetrics->underlineSize, mMetrics->strikeoutOffset, mMetrics->strikeoutSize,
mMetrics->superscriptOffset, mMetrics->subscriptOffset);
printf(" uOff: %f uSize: %f stOff: %f stSize: %f\n",
mMetrics->underlineOffset, mMetrics->underlineSize, mMetrics->strikeoutOffset, mMetrics->strikeoutSize);
#endif
}

View File

@ -133,7 +133,7 @@ gfxFT2FontBase::GetMetrics()
fprintf (stderr, " maxAscent: %f maxDescent: %f\n", mMetrics.maxAscent, mMetrics.maxDescent);
fprintf (stderr, " internalLeading: %f externalLeading: %f\n", mMetrics.externalLeading, mMetrics.internalLeading);
fprintf (stderr, " spaceWidth: %f aveCharWidth: %f xHeight: %f\n", mMetrics.spaceWidth, mMetrics.aveCharWidth, mMetrics.xHeight);
fprintf (stderr, " uOff: %f uSize: %f stOff: %f stSize: %f suOff: %f suSize: %f\n", mMetrics.underlineOffset, mMetrics.underlineSize, mMetrics.strikeoutOffset, mMetrics.strikeoutSize, mMetrics.superscriptOffset, mMetrics.subscriptOffset);
fprintf (stderr, " uOff: %f uSize: %f stOff: %f stSize: %f\n", mMetrics.underlineOffset, mMetrics.underlineSize, mMetrics.strikeoutOffset, mMetrics.strikeoutSize);
#endif
mHasMetrics = true;

View File

@ -67,8 +67,6 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics,
aMetrics->zeroOrAveCharWidth = spaceWidth;
const gfxFloat xHeight = 0.5 * emHeight;
aMetrics->xHeight = xHeight;
aMetrics->superscriptOffset = xHeight;
aMetrics->subscriptOffset = xHeight;
const gfxFloat underlineSize = emHeight / 14.0;
aMetrics->underlineSize = underlineSize;
aMetrics->underlineOffset = -underlineSize;
@ -243,24 +241,6 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics,
}
SnapLineToPixels(aMetrics->strikeoutOffset, aMetrics->strikeoutSize);
if (os2 && os2->ySuperscriptYOffset) {
gfxFloat val = ScaleRoundDesignUnits(os2->ySuperscriptYOffset,
ftMetrics.y_scale);
aMetrics->superscriptOffset = std::max(1.0, val);
} else {
aMetrics->superscriptOffset = aMetrics->xHeight;
}
if (os2 && os2->ySubscriptYOffset) {
gfxFloat val = ScaleRoundDesignUnits(os2->ySubscriptYOffset,
ftMetrics.y_scale);
// some fonts have the incorrect sign.
val = fabs(val);
aMetrics->subscriptOffset = std::max(1.0, val);
} else {
aMetrics->subscriptOffset = aMetrics->xHeight;
}
aMetrics->maxHeight = aMetrics->maxAscent + aMetrics->maxDescent;
// Make the line height an integer number of pixels so that lines will be

View File

@ -4597,8 +4597,6 @@ gfxFont::InitMetricsFromSfntTables(Metrics& aMetrics)
// this should always be present in any valid OS/2 of any version
if (len >= offsetof(OS2Table, sTypoLineGap) + sizeof(int16_t)) {
SET_SIGNED(aveCharWidth, os2->xAvgCharWidth);
SET_SIGNED(subscriptOffset, os2->ySubscriptYOffset);
SET_SIGNED(superscriptOffset, os2->ySuperscriptYOffset);
SET_SIGNED(strikeoutSize, os2->yStrikeoutSize);
SET_SIGNED(strikeoutOffset, os2->yStrikeoutPosition);
@ -4660,13 +4658,6 @@ void gfxFont::CalculateDerivedMetrics(Metrics& aMetrics)
aMetrics.maxAdvance = aMetrics.aveCharWidth;
}
if (!aMetrics.subscriptOffset) {
aMetrics.subscriptOffset = aMetrics.xHeight;
}
if (!aMetrics.superscriptOffset) {
aMetrics.superscriptOffset = aMetrics.xHeight;
}
if (!aMetrics.strikeoutOffset) {
aMetrics.strikeoutOffset = aMetrics.xHeight * 0.5;
}
@ -4685,19 +4676,6 @@ gfxFont::SanitizeMetrics(gfxFont::Metrics *aMetrics, bool aIsBadUnderlineFont)
return;
}
// MS (P)Gothic and MS (P)Mincho are not having suitable values in their super script offset.
// If the values are not suitable, we should use x-height instead of them.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=353632
if (aMetrics->superscriptOffset <= 0 ||
aMetrics->superscriptOffset >= aMetrics->maxAscent) {
aMetrics->superscriptOffset = aMetrics->xHeight;
}
// And also checking the case of sub script offset. The old gfx for win has checked this too.
if (aMetrics->subscriptOffset <= 0 ||
aMetrics->subscriptOffset >= aMetrics->maxAscent) {
aMetrics->subscriptOffset = aMetrics->xHeight;
}
aMetrics->underlineSize = std::max(1.0, aMetrics->underlineSize);
aMetrics->strikeoutSize = std::max(1.0, aMetrics->strikeoutSize);

View File

@ -1658,8 +1658,6 @@ public:
// Font metrics
struct Metrics {
gfxFloat xHeight;
gfxFloat superscriptOffset;
gfxFloat subscriptOffset;
gfxFloat strikeoutSize;
gfxFloat strikeoutOffset;
gfxFloat underlineSize;

View File

@ -247,9 +247,6 @@ gfxGDIFont::Initialize()
TEXTMETRIC& metrics = oMetrics.otmTextMetrics;
if (0 < GetOutlineTextMetrics(dc.GetDC(), sizeof(oMetrics), &oMetrics)) {
mMetrics->superscriptOffset = (double)oMetrics.otmptSuperscriptOffset.y;
// Some fonts have wrong sign on their subscript offset, bug 410917.
mMetrics->subscriptOffset = fabs((double)oMetrics.otmptSubscriptOffset.y);
mMetrics->strikeoutSize = (double)oMetrics.otmsStrikeoutSize;
mMetrics->strikeoutOffset = (double)oMetrics.otmsStrikeoutPosition;
mMetrics->underlineSize = (double)oMetrics.otmsUnderscoreSize;
@ -288,8 +285,6 @@ gfxGDIFont::Initialize()
mMetrics->xHeight =
ROUND((float)metrics.tmAscent * DEFAULT_XHEIGHT_FACTOR);
mMetrics->superscriptOffset = mMetrics->xHeight;
mMetrics->subscriptOffset = mMetrics->xHeight;
mMetrics->strikeoutSize = 1;
mMetrics->strikeoutOffset = ROUND(mMetrics->xHeight * 0.5f); // 50% of xHeight
mMetrics->underlineSize = 1;
@ -394,9 +389,8 @@ gfxGDIFont::Initialize()
printf(" maxAscent: %f maxDescent: %f maxAdvance: %f\n", mMetrics->maxAscent, mMetrics->maxDescent, mMetrics->maxAdvance);
printf(" internalLeading: %f externalLeading: %f\n", mMetrics->internalLeading, mMetrics->externalLeading);
printf(" spaceWidth: %f aveCharWidth: %f xHeight: %f\n", mMetrics->spaceWidth, mMetrics->aveCharWidth, mMetrics->xHeight);
printf(" uOff: %f uSize: %f stOff: %f stSize: %f supOff: %f subOff: %f\n",
mMetrics->underlineOffset, mMetrics->underlineSize, mMetrics->strikeoutOffset, mMetrics->strikeoutSize,
mMetrics->superscriptOffset, mMetrics->subscriptOffset);
printf(" uOff: %f uSize: %f stOff: %f stSize: %f\n",
mMetrics->underlineOffset, mMetrics->underlineSize, mMetrics->strikeoutOffset, mMetrics->strikeoutSize);
#endif
}

View File

@ -332,7 +332,7 @@ gfxMacFont::InitMetrics()
fprintf (stderr, " maxAscent: %f maxDescent: %f maxAdvance: %f\n", mMetrics.maxAscent, mMetrics.maxDescent, mMetrics.maxAdvance);
fprintf (stderr, " internalLeading: %f externalLeading: %f\n", mMetrics.internalLeading, mMetrics.externalLeading);
fprintf (stderr, " spaceWidth: %f aveCharWidth: %f xHeight: %f\n", mMetrics.spaceWidth, mMetrics.aveCharWidth, mMetrics.xHeight);
fprintf (stderr, " uOff: %f uSize: %f stOff: %f stSize: %f supOff: %f subOff: %f\n", mMetrics.underlineOffset, mMetrics.underlineSize, mMetrics.strikeoutOffset, mMetrics.strikeoutSize, mMetrics.superscriptOffset, mMetrics.subscriptOffset);
fprintf (stderr, " uOff: %f uSize: %f stOff: %f stSize: %f\n", mMetrics.underlineOffset, mMetrics.underlineSize, mMetrics.strikeoutOffset, mMetrics.strikeoutSize);
#endif
}