Bug 533251. Always insert default font if needed when rebuilding font list. r=jkew

This commit is contained in:
John Daggett 2010-02-24 16:18:49 +09:00
parent 6dbfd82c90
commit d33c429bba
5 changed files with 76 additions and 5 deletions

View File

@ -1854,6 +1854,9 @@ protected:
// as invalidation of font lists and caches is not considered.
void SetUserFontSet(gfxUserFontSet *aUserFontSet);
// Initialize the list of fonts
void BuildFontList();
// Init this font group's font metrics. If there no bad fonts, you don't need to call this.
// But if there are one or more bad fonts which have bad underline offset,
// you should call this with the *first* bad font.

View File

@ -1417,6 +1417,13 @@ gfxFontGroup::gfxFontGroup(const nsAString& aFamilies, const gfxFontStyle *aStyl
mUserFontSet = nsnull;
SetUserFontSet(aUserFontSet);
mPageLang = gfxPlatform::GetFontPrefLangFor(mStyle.langGroup.get());
BuildFontList();
}
void
gfxFontGroup::BuildFontList()
{
// "#if" to be removed once all platforms are moved to gfxPlatformFontList interface
// and subclasses of gfxFontGroup eliminated
#if defined(XP_MACOSX) || defined(XP_WIN)
@ -1425,17 +1432,15 @@ gfxFontGroup::gfxFontGroup(const nsAString& aFamilies, const gfxFontStyle *aStyl
if (mFonts.Length() == 0) {
PRBool needsBold;
gfxFontEntry *defaultFont =
gfxPlatformFontList::PlatformFontList()->GetDefaultFont(aStyle, needsBold);
gfxPlatformFontList::PlatformFontList()->GetDefaultFont(&mStyle, needsBold);
NS_ASSERTION(defaultFont, "invalid default font returned by GetDefaultFont");
nsRefPtr<gfxFont> font = defaultFont->FindOrMakeFont(aStyle, needsBold);
nsRefPtr<gfxFont> font = defaultFont->FindOrMakeFont(&mStyle, needsBold);
if (font) {
mFonts.AppendElement(font);
}
}
mPageLang = gfxPlatform::GetFontPrefLangFor(mStyle.langGroup.get());
if (!mStyle.systemFont) {
for (PRUint32 i = 0; i < mFonts.Length(); ++i) {
gfxFont* font = mFonts[i];
@ -2010,7 +2015,13 @@ gfxFontGroup::UpdateFontList()
// xxx - can probably improve this to detect when all fonts were found, so no need to update list
mFonts.Clear();
mUnderlineOffset = UNDERLINE_OFFSET_NOT_SET;
// bug 548184 - need to clean up FT2, OS/2 platform code to use BuildFontList
#if defined(XP_MACOSX) || defined(XP_WIN)
BuildFontList();
#else
ForEachFont(FindPlatformFont, this);
#endif
mCurrGeneration = GetGeneration();
}
}

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 533251 crashtest</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@font-face {
font-family: test;
src: url(../fonts/markA.ttf);
}
body {
background-color: white;
}
p { font-family: test; }
</style>
</head>
<body>
<p>A</p>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html lang="ru">
<head>
<title>Bug 533251 crashtest</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@font-face {
font-family: test;
src: url(../fonts/markA.ttf);
}
body {
background-color: white;
}
div {
font-family: Bongo2020; /* non-existent font */
color: white;
}
p { font-family: test; }
</style>
</head>
<body>
<p>A</p>
<div>This shouldn't crash...</div>
</body>
</html>

View File

@ -121,3 +121,4 @@ HTTP(..) == underline-offset-change-2.html underline-offset-change-2-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") fails-if(MOZ_WIDGET_TOOLKIT=="windows") HTTP(..) != underline-offset-change-1-ref.html underline-offset-change-2-ref.html # Bug 534132
HTTP(..) != 534352-1-extra-cmap-sentinel.html 534352-1-extra-cmap-sentinel-ref.html
HTTP(..) == bug533251.html bug533251-ref.html