MakeSpaceTextRun() should short-circuit zero-sized fonts. b=407352 r+sr=roc a=dsicore

This commit is contained in:
mats.palmgren@bredband.net 2008-01-13 23:05:19 -08:00
parent a90c543b46
commit 60f971e921
2 changed files with 11 additions and 1 deletions

View File

@ -86,6 +86,8 @@ public:
// Get the glyphID of a space
virtual PRUint32 GetSpaceGlyph() {
NS_ASSERTION(GetStyle()->size != 0,
"forgot to short-circuit a text run with zero-sized font?");
GetMetrics();
return mSpaceGlyph;
}

View File

@ -860,7 +860,15 @@ gfxFontGroup::MakeSpaceTextRun(const Parameters *aParams, PRUint32 aFlags)
return nsnull;
gfxFont *font = GetFontAt(0);
textRun->SetSpaceGlyph(font, aParams->mContext, 0);
if (NS_UNLIKELY(GetStyle()->size == 0)) {
// Short-circuit for size-0 fonts, as Windows and ATSUI can't handle
// them, and always create at least size 1 fonts, i.e. they still
// render something for size 0 fonts.
textRun->AddGlyphRun(font, 0);
}
else {
textRun->SetSpaceGlyph(font, aParams->mContext, 0);
}
// Note that the gfxGlyphExtents glyph bounds storage for the font will
// always contain an entry for the font's space glyph, so we don't have
// to call FetchGlyphExtents here.