Bug 1056479 p1a - use lang as part of pref font fallback. r=karlt

This commit is contained in:
John Daggett 2015-05-12 17:44:13 +09:00
parent 2de852fdbe
commit 14ad02c693
3 changed files with 53 additions and 1 deletions

View File

@ -382,6 +382,39 @@ static const char *gPrefLangNames[] = {
"x-unicode",
};
// this needs to match the list of pref font.default.xx entries listed in all.js!
// the order *must* match the order in eFontPrefLang
static nsIAtom* gPrefLangToLangGroups[] = {
nsGkAtoms::x_western,
nsGkAtoms::Japanese,
nsGkAtoms::Taiwanese,
nsGkAtoms::Chinese,
nsGkAtoms::HongKongChinese,
nsGkAtoms::ko,
nsGkAtoms::x_cyrillic,
nsGkAtoms::el,
nsGkAtoms::th,
nsGkAtoms::he,
nsGkAtoms::ar,
nsGkAtoms::x_devanagari,
nsGkAtoms::x_tamil,
nsGkAtoms::x_armn,
nsGkAtoms::x_beng,
nsGkAtoms::x_cans,
nsGkAtoms::x_ethi,
nsGkAtoms::x_geor,
nsGkAtoms::x_gujr,
nsGkAtoms::x_guru,
nsGkAtoms::x_khmr,
nsGkAtoms::x_mlym,
nsGkAtoms::x_orya,
nsGkAtoms::x_telu,
nsGkAtoms::x_knda,
nsGkAtoms::x_sinh,
nsGkAtoms::x_tibt,
nsGkAtoms::Unicode
};
gfxPlatform::gfxPlatform()
: mTileWidth(-1)
, mTileHeight(-1)
@ -1474,6 +1507,19 @@ gfxPlatform::GetFontPrefLangFor(nsIAtom *aLang)
return GetFontPrefLangFor(lang.get());
}
nsIAtom*
gfxPlatform::GetLangGroupForPrefLang(eFontPrefLang aLang)
{
// the special CJK set pref lang should be resolved into separate
// calls to individual CJK pref langs before getting here
NS_ASSERTION(aLang != eFontPrefLang_CJKSet, "unresolved CJK set pref lang");
if (uint32_t(aLang) < ArrayLength(gPrefLangToLangGroups)) {
return gPrefLangToLangGroups[uint32_t(aLang)];
}
return nsGkAtoms::Unicode;
}
const char*
gfxPlatform::GetPrefLangName(eFontPrefLang aLang)
{

View File

@ -470,6 +470,9 @@ public:
// convert a lang group atom to enum constant
static eFontPrefLang GetFontPrefLangFor(nsIAtom *aLang);
// convert an enum constant to a lang group atom
static nsIAtom* GetLangGroupForPrefLang(eFontPrefLang aLang);
// convert a enum constant to lang group string (i.e. eFontPrefLang_ChineseTW ==> "zh-TW")
static const char* GetPrefLangName(eFontPrefLang aLang);

View File

@ -3082,7 +3082,10 @@ struct PrefFontCallbackData {
{
PrefFontCallbackData *prefFontData = static_cast<PrefFontCallbackData*>(aClosure);
gfxFontFamily *family = gfxPlatformFontList::PlatformFontList()->FindFamily(aName);
// map pref lang to langGroup for language-sensitive lookups
nsIAtom* lang = gfxPlatform::GetLangGroupForPrefLang(aLang);
gfxFontFamily *family =
gfxPlatformFontList::PlatformFontList()->FindFamily(aName, lang);
if (family) {
prefFontData->mPrefFamilies.AppendElement(family);
}