FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]);
FcPatternAddLangSet(pattern, FC_LANG, ls);
FcLangSetDestroy(ls);
+ } else if (!family.isEmpty()) {
+ // If script is common then it may include languages like CJK,
+ // we should attach system default language set to the pattern
+ // to obtain correct font fallback list (i.e. if LANG=zh_CN
+ // then we normally want to use a Chinese font for CJK text;
+ // while a Japanese font should be use for that if LANG=ja)
+ FcPattern *dummy = FcPatternCreate();
+ FcDefaultSubstitute(dummy);
+ FcChar8 *lang = 0;
+ FcResult res = FcPatternGetString(dummy, FC_LANG, 0, &lang);
+ if (res == FcResultMatch)
+ FcPatternAddString(pattern, FC_LANG, lang);
+ FcPatternDestroy(dummy);
}
const char *stylehint = getFcFamilyForStyleHint(styleHint);