зеркало из https://github.com/mozilla/gecko-dev.git
bug 223653 : support localized (native) font names in Xft, r=blizzard, sr=rbs, a=asa
This commit is contained in:
Родитель
21cd26cdab
Коммит
3678df3a9a
|
@ -1685,10 +1685,8 @@ nsresult
|
|||
nsFontMetricsXft::FamilyExists(nsIDeviceContext *aDevice,
|
||||
const nsString &aName)
|
||||
{
|
||||
if (!NS_IsASCIIFontName(aName))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ConvertUCS2toUTF8 name(aName);
|
||||
// fontconfig family name is always in UTF-8
|
||||
NS_ConvertUTF16toUTF8 name(aName);
|
||||
|
||||
FcFontSet *set = nsnull;
|
||||
FcObjectSet *os = nsnull;
|
||||
|
@ -1741,13 +1739,12 @@ PRBool
|
|||
nsFontMetricsXft::EnumFontCallback(const nsString &aFamily, PRBool aIsGeneric,
|
||||
void *aData)
|
||||
{
|
||||
// make sure it's an ascii name, if not then return and continue
|
||||
// enumerating
|
||||
if (!NS_IsASCIIFontName(aFamily))
|
||||
return PR_TRUE;
|
||||
NS_ConvertUTF16toUTF8 name(aFamily);
|
||||
|
||||
nsCAutoString name;
|
||||
name.AssignWithConversion(aFamily.get());
|
||||
// The newest fontconfig does the full Unicode case folding so that
|
||||
// we're being lazy here by calling |ToLowerCase| after converting
|
||||
// to UTF-8 assuming that in virtually all cases, we just have to
|
||||
// fold [A-Z]. (bug 223653).
|
||||
ToLowerCase(name);
|
||||
nsFontMetricsXft *metrics = (nsFontMetricsXft *)aData;
|
||||
metrics->mFontList.AppendCString(name);
|
||||
|
@ -2308,7 +2305,6 @@ EnumFontsXft(nsIAtom* aLangGroup, const char* aGeneric,
|
|||
|
||||
for (int i=0; i < fs->nfont; ++i) {
|
||||
char *family;
|
||||
PRUnichar *name;
|
||||
|
||||
// if there's no family, just move to the next iteration
|
||||
if (FcPatternGetString (fs->fonts[i], FC_FAMILY, 0,
|
||||
|
@ -2316,18 +2312,12 @@ EnumFontsXft(nsIAtom* aLangGroup, const char* aGeneric,
|
|||
continue;
|
||||
}
|
||||
|
||||
name = NS_STATIC_CAST(PRUnichar *,
|
||||
nsMemory::Alloc ((strlen (family) + 1)
|
||||
* sizeof (PRUnichar)));
|
||||
// fontconfig always returns family names in UTF-8
|
||||
PRUnichar* name = UTF8ToNewUnicode(nsDependentCString(family));
|
||||
|
||||
if (!name)
|
||||
goto end;
|
||||
|
||||
PRUnichar *r = name;
|
||||
for (char *f = family; *f; ++f)
|
||||
*r++ = *f;
|
||||
*r = '\0';
|
||||
|
||||
array[narray++] = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -801,12 +801,15 @@ nsFontPSXft::CSSFontEnumCallback(const nsString& aFamily, PRBool aIsGeneric,
|
|||
{
|
||||
fontPSInfo *fpi = (fontPSInfo *)aFpi;
|
||||
|
||||
// make sure it's an ascii name, if not then return and continue
|
||||
// enumerating
|
||||
if (!NS_IsASCIIFontName(aFamily))
|
||||
return PR_TRUE;
|
||||
|
||||
NS_LossyConvertUTF16toASCII name(aFamily);
|
||||
// fontconfig always returns family names in UTF-8 so that we
|
||||
// should do the same here.
|
||||
NS_ConvertUTF16toUTF8 name(aFamily);
|
||||
|
||||
// The newest fontconfig does the full Unicode case folding so that
|
||||
// we're being lazy here by calling |ToLowerCase| after converting
|
||||
// to UTF-8 assuming that in virtually all cases, we just have to
|
||||
// fold [A-Z]. (bug 223653).
|
||||
ToLowerCase(name);
|
||||
fpi->mFontList.AppendCString(name);
|
||||
fpi->mFontIsGeneric.AppendElement((void *)aIsGeneric);
|
||||
|
|
|
@ -208,20 +208,3 @@ NS_FFRECountHyphens (nsACString &aFFREName)
|
|||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
PRBool
|
||||
NS_IsASCIIFontName(const nsString& aName)
|
||||
{
|
||||
PRUint32 len = aName.Length();
|
||||
const PRUnichar* str = aName.get();
|
||||
for (PRUint32 i = 0; i < len; i++) {
|
||||
/*
|
||||
* X font names are printable ASCII, ignore others (for now)
|
||||
*/
|
||||
if ((str[i] < 0x20) || (str[i] > 0x7E)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,5 @@ extern void NS_AddLangGroup (FcPattern *aPattern, nsIAtom *aLangGroup);
|
|||
extern void NS_AddFFRE (FcPattern *aPattern, nsCString *aFamily,
|
||||
PRBool aWeak);
|
||||
extern int NS_FFRECountHyphens (nsACString &aFFREName);
|
||||
extern PRBool NS_IsASCIIFontName (const nsString& aName);
|
||||
#endif
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче