b=480507, don't crash if no fonts found in Windows font family; r+sr=vlad

This commit is contained in:
Jonathan Kew 2009-03-03 11:14:07 -08:00
parent f4c8ebe128
commit 3898e3ebbd
2 changed files with 15 additions and 0 deletions

View File

@ -280,6 +280,14 @@ FontFamily::FindStyleVariations()
faspd.ff = this;
EnumFontFamiliesExW(hdc, &logFont, (FONTENUMPROCW)FontFamily::FamilyAddStylesProc, (LPARAM)&faspd, 0);
#ifdef DEBUG
if (mVariations.Length() == 0) {
char msgBuf[256];
(void)sprintf(msgBuf, "no styles available in family \"%s\"",
NS_ConvertUTF16toUTF8(mName).get());
NS_ASSERTION(mVariations.Length() != 0, msgBuf);
}
#endif
ReleaseDC(nsnull, hdc);

View File

@ -191,6 +191,9 @@ gfxWindowsPlatform::HashEnumFunc(nsStringHashKey::KeyType aKey,
gfxFontStyle style;
style.langGroup = data->mLangGroup;
nsRefPtr<FontEntry> aFontEntry = aFontFamily->FindFontEntry(style);
NS_ASSERTION(aFontEntry, "couldn't find any font entry in family");
if (!aFontEntry)
return PL_DHASH_NEXT;
#ifndef MOZ_FT2_FONTS
@ -549,6 +552,10 @@ gfxWindowsPlatform::FindFontForCharProc(nsStringHashKey::KeyType aKey,
const PRUint32 ch = data->ch;
nsRefPtr<FontEntry> fe = aFontFamily->FindFontEntry(*data->fontToMatch->GetStyle());
NS_ASSERTION(fe, "couldn't find any font entry in family");
if (!fe)
return PL_DHASH_NEXT;
PRInt32 rank = 0;
#ifndef MOZ_FT2_FONTS