Bug 395866 font fallback does not respect stylesheet font list r=vlad, b1.9=stuart

This commit is contained in:
masayuki@d-toybox.com 2007-09-28 10:33:50 -07:00
parent ae36f23f23
commit 556d3b4dc6
2 changed files with 20 additions and 2 deletions

View File

@ -128,6 +128,8 @@ public:
gfxAtsuiFont* FindFontFor(ATSUFontID fid);
PRBool HasFont(ATSUFontID fid);
protected:
static PRBool FindATSUFont(const nsAString& aName,
const nsACString& aGenericName,

View File

@ -429,7 +429,7 @@ gfxAtsuiFontGroup::gfxAtsuiFontGroup(const nsAString& families,
GetOrMakeFont(fontID, aStyle, &mFonts);
}
CreateFontFallbacksFromFontList(&mFonts, &mFallbacks, kATSULastResortOnlyFallback);
CreateFontFallbacksFromFontList(&mFonts, &mFallbacks, kATSUSequentialFallbacksExclusive);
}
PRBool
@ -443,7 +443,7 @@ gfxAtsuiFontGroup::FindATSUFont(const nsAString& aName,
gfxQuartzFontCache *fc = gfxQuartzFontCache::SharedFontCache();
ATSUFontID fontID = fc->FindATSUFontIDForFamilyAndStyle (aName, fontStyle);
if (fontID != kATSUInvalidFontID) {
if (fontID != kATSUInvalidFontID && !fontGroup->HasFont(fontID)) {
//fprintf (stderr, "..FindATSUFont: %s\n", NS_ConvertUTF16toUTF8(aName).get());
GetOrMakeFont(fontID, fontStyle, &fontGroup->mFonts);
}
@ -673,6 +673,16 @@ gfxAtsuiFontGroup::FindFontFor(ATSUFontID fid)
return GetOrMakeFont(fid, GetStyle(), &mFonts);
}
PRBool
gfxAtsuiFontGroup::HasFont(ATSUFontID fid)
{
for (PRUint32 i = 0; i < mFonts.Length(); ++i) {
if (fid == static_cast<gfxAtsuiFont *>(mFonts.ElementAt(i).get())->GetATSUFontID())
return PR_TRUE;
}
return PR_FALSE;
}
/**
* Simple wrapper for ATSU "direct data arrays"
*/
@ -1519,6 +1529,12 @@ gfxAtsuiFontGroup::InitTextRun(gfxTextRun *aRun,
break;
}
if (firstTime && !HasFont(substituteFontID)) {
// XXX We are using kATSUSequentialFallbacksExclusive at first time.
// But the method uses non-listed font in font fallbacks on 10.4. (ATSUI Reference does not say so...)
status = kATSUFontsNotMatched;
}
// then, handle any chars that were found in the fallback list
if (status == kATSUFontsMatched) {
// substitute font will be used in [changedOffset, changedOffset + changedLength)