mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 693143. Fix top crasher related to small font sizes and bitmap fonts. r=roc
This commit is contained in:
parent
b86796df77
commit
7fef4d4b86
@ -1832,7 +1832,7 @@ gfxFont::SanitizeMetrics(gfxFont::Metrics *aMetrics, bool aIsBadUnderlineFont)
|
||||
{
|
||||
// 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) {
|
||||
if (mStyle.size == 0.0) {
|
||||
memset(aMetrics, 0, sizeof(gfxFont::Metrics));
|
||||
return;
|
||||
}
|
||||
|
@ -327,6 +327,7 @@ gfxGDIFont::Initialize()
|
||||
}
|
||||
}
|
||||
|
||||
// this may end up being zero
|
||||
mAdjustedSize = ROUND(mAdjustedSize);
|
||||
FillLogFont(logFont, mAdjustedSize);
|
||||
mFont = ::CreateFontIndirectW(&logFont);
|
||||
@ -338,7 +339,9 @@ gfxGDIFont::Initialize()
|
||||
SetGraphicsMode(dc.GetDC(), GM_ADVANCED);
|
||||
AutoSelectFont selectFont(dc.GetDC(), mFont);
|
||||
|
||||
// Get font metrics
|
||||
// Get font metrics if size > 0
|
||||
if (mAdjustedSize > 0.0) {
|
||||
|
||||
OUTLINETEXTMETRIC oMetrics;
|
||||
TEXTMETRIC& metrics = oMetrics.otmTextMetrics;
|
||||
|
||||
@ -434,6 +437,7 @@ gfxGDIFont::Initialize()
|
||||
}
|
||||
|
||||
SanitizeMetrics(mMetrics, GetFontEntry()->mIsBadUnderlineFont);
|
||||
}
|
||||
|
||||
mFontFace = cairo_win32_font_face_create_for_logfontw_hfont(&logFont,
|
||||
mFont);
|
||||
@ -460,20 +464,21 @@ gfxGDIFont::Initialize()
|
||||
mScaledFont ? cairo_scaled_font_status(mScaledFont) : 0);
|
||||
NS_WARNING(warnBuf);
|
||||
#endif
|
||||
mIsValid = false;
|
||||
} else {
|
||||
mIsValid = true;
|
||||
}
|
||||
|
||||
mIsValid = true;
|
||||
|
||||
#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 xHeight: %f\n", mMetrics.spaceWidth, mMetrics.aveCharWidth, mMetrics.xHeight);
|
||||
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);
|
||||
mMetrics->underlineOffset, mMetrics->underlineSize, mMetrics->strikeoutOffset, mMetrics->strikeoutSize,
|
||||
mMetrics->superscriptOffset, mMetrics->subscriptOffset);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user