author | John Daggett <jdaggett@mozilla.com> |
Sat, 28 Jun 2014 15:40:36 +0900 | |
changeset 191341 | c134a28bc14357b0d6fb45e4308666f61fc21936 |
parent 191340 | 6af052a9805e926e58a3605e0a0a7e373f4ca59b |
child 191342 | 6f97e210af1d5801161814c0992f1090877d5a48 |
push id | 27041 |
push user | philringnalda@gmail.com |
push date | Sun, 29 Jun 2014 00:39:21 +0000 |
treeherder | mozilla-central@afa67a2f7905 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | heycam |
bugs | 1029307 |
milestone | 33.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -311,32 +311,29 @@ gfxDWriteFont::ComputeMetrics(AntialiasO mMetrics->underlineOffset = fontMetrics.underlinePosition * mFUnitsConvFactor; mMetrics->underlineSize = fontMetrics.underlineThickness * mFUnitsConvFactor; mMetrics->strikeoutOffset = fontMetrics.strikethroughPosition * mFUnitsConvFactor; mMetrics->strikeoutSize = fontMetrics.strikethroughThickness * mFUnitsConvFactor; - mMetrics->superscriptOffset = 0; - mMetrics->subscriptOffset = 0; SanitizeMetrics(mMetrics, GetFontEntry()->mIsBadUnderlineFont); #if 0 printf("Font: %p (%s) size: %f\n", this, NS_ConvertUTF16toUTF8(GetName()).get(), mStyle.size); printf(" emHeight: %f emAscent: %f emDescent: %f\n", mMetrics->emHeight, mMetrics->emAscent, mMetrics->emDescent); 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 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 } using namespace mozilla; // for AutoSwap_* types struct EBLCHeader { AutoSwap_PRUint32 version; AutoSwap_PRUint32 numSizes;
--- a/gfx/thebes/gfxFT2FontBase.cpp +++ b/gfx/thebes/gfxFT2FontBase.cpp @@ -128,17 +128,17 @@ gfxFT2FontBase::GetMetrics() // printf("font name: %s %f\n", NS_ConvertUTF16toUTF8(GetName()).get(), GetStyle()->size); // printf ("pango font %s\n", pango_font_description_to_string (pango_font_describe (font))); fprintf (stderr, "Font: %s\n", NS_ConvertUTF16toUTF8(GetName()).get()); fprintf (stderr, " emHeight: %f emAscent: %f emDescent: %f\n", mMetrics.emHeight, mMetrics.emAscent, mMetrics.emDescent); 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; return mMetrics; } // Get the glyphID of a space uint32_t
--- a/gfx/thebes/gfxFT2Utils.cpp +++ b/gfx/thebes/gfxFT2Utils.cpp @@ -62,18 +62,16 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Me aMetrics->externalLeading = 0.2 * emHeight; const gfxFloat spaceWidth = 0.5 * emHeight; aMetrics->spaceWidth = spaceWidth; aMetrics->maxAdvance = spaceWidth; aMetrics->aveCharWidth = spaceWidth; 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; aMetrics->strikeoutOffset = 0.25 * emHeight; aMetrics->strikeoutSize = underlineSize; *aSpaceGlyph = 0; return; @@ -238,34 +236,16 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Me } else { // No strikeout info. aMetrics->strikeoutSize = aMetrics->underlineSize; // Use OpenType spec's suggested position for Roman font. aMetrics->strikeoutOffset = emHeight * 409.0 / 2048.0 + 0.5 * aMetrics->strikeoutSize; } 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 // equally spaced (rather than just being snapped to pixels, some up and // some down). Layout calculates line height from the emHeight + // internalLeading + externalLeading, but first each of these is rounded // to layout units. To ensure that the result is an integer number of // pixels, round each of the components to pixels.
--- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -4592,18 +4592,16 @@ gfxFont::InitMetricsFromSfntTables(Metri // version 2 and later includes the x-height field SET_SIGNED(xHeight, os2->sxHeight); // Abs because of negative xHeight seen in Kokonor (Tibetan) font aMetrics.xHeight = Abs(aMetrics.xHeight); } // 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); // for fonts with USE_TYPO_METRICS set in the fsSelection field, // and for all OpenType math fonts (having a 'MATH' table), // let the OS/2 sTypo* metrics override those from the hhea table // (see http://www.microsoft.com/typography/otspec/os2.htm#fss) const uint16_t kUseTypoMetricsMask = 1 << 7; @@ -4655,23 +4653,16 @@ void gfxFont::CalculateDerivedMetrics(Me if (GetFontEntry()->IsFixedPitch()) { // Some Quartz fonts are fixed pitch, but there's some glyph with a bigger // advance than the average character width... this forces // those fonts to be recognized like fixed pitch fonts by layout. 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; } if (!aMetrics.strikeoutSize) { aMetrics.strikeoutSize = aMetrics.underlineSize; } } @@ -4680,29 +4671,16 @@ gfxFont::SanitizeMetrics(gfxFont::Metric { // Even if this font size is zero, this font is created with non-zero size. // However, for layout and others, we should return the metrics of zero size font. if (mStyle.size == 0.0) { memset(aMetrics, 0, sizeof(gfxFont::Metrics)); 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); aMetrics->underlineOffset = std::min(aMetrics->underlineOffset, -1.0); if (aMetrics->maxAscent < 1.0) { // We cannot draw strikeout line and overline in the ascent... aMetrics->underlineSize = 0;
--- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -1653,18 +1653,16 @@ public: virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions() { return nullptr; } gfxFloat SynthesizeSpaceWidth(uint32_t aCh); // Font metrics struct Metrics { gfxFloat xHeight; - gfxFloat superscriptOffset; - gfxFloat subscriptOffset; gfxFloat strikeoutSize; gfxFloat strikeoutOffset; gfxFloat underlineSize; gfxFloat underlineOffset; gfxFloat internalLeading; gfxFloat externalLeading;
--- a/gfx/thebes/gfxGDIFont.cpp +++ b/gfx/thebes/gfxGDIFont.cpp @@ -242,19 +242,16 @@ gfxGDIFont::Initialize() // Get font metrics if size > 0 if (mAdjustedSize > 0.0) { OUTLINETEXTMETRIC oMetrics; 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; mMetrics->underlineOffset = (double)oMetrics.otmsUnderscorePosition; const MAT2 kIdentityMatrix = { {0, 1}, {0, 0}, {0, 0}, {0, 1} }; GLYPHMETRICS gm; DWORD len = GetGlyphOutlineW(dc.GetDC(), char16_t('x'), GGO_METRICS, &gm, 0, nullptr, &kIdentityMatrix); @@ -283,18 +280,16 @@ gfxGDIFont::Initialize() NS_WARNING("Missing or corrupt font data, fasten your seatbelt"); mIsValid = false; memset(mMetrics, 0, sizeof(*mMetrics)); return; } 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; mMetrics->underlineOffset = -ROUND((float)metrics.tmDescent * 0.30f); // 30% of descent mMetrics->emHeight = metrics.tmHeight - metrics.tmInternalLeading; mMetrics->emAscent = metrics.tmAscent - metrics.tmInternalLeading; mMetrics->emDescent = metrics.tmDescent; } @@ -389,19 +384,18 @@ gfxGDIFont::Initialize() #if 0 printf("Font: %p (%s) size: %f adjusted size: %f valid: %s\n", this, NS_ConvertUTF16toUTF8(GetName()).get(), mStyle.size, mAdjustedSize, (mIsValid ? "yes" : "no")); printf(" emHeight: %f emAscent: %f emDescent: %f\n", mMetrics->emHeight, mMetrics->emAscent, mMetrics->emDescent); 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 } void gfxGDIFont::FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize, bool aUseGDIFakeItalic) { GDIFontEntry *fe = static_cast<GDIFontEntry*>(GetFontEntry());
--- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -327,17 +327,17 @@ gfxMacFont::InitMetrics() #if 0 fprintf (stderr, "Font: %p (%s) size: %f\n", this, NS_ConvertUTF16toUTF8(GetName()).get(), mStyle.size); // fprintf (stderr, " fbounds.origin.x %f y %f size.width %f height %f\n", fbounds.origin.x, fbounds.origin.y, fbounds.size.width, fbounds.size.height); fprintf (stderr, " emHeight: %f emAscent: %f emDescent: %f\n", mMetrics.emHeight, mMetrics.emAscent, mMetrics.emDescent); 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 } gfxFloat gfxMacFont::GetCharWidth(CFDataRef aCmap, char16_t aUniChar, uint32_t *aGlyphID, gfxFloat aConvFactor) { CGGlyph glyph = 0;