Ignore 'und-' prefix for in FcLangCompare
See https://bugs.freedesktop.org/show_bug.cgi?id=94551#c54 For example, matching for :lang=und-zsye matches emoji font, but searching for :lang=und-xyz wouldn't match an emoji font anymore. Neither does :lang-und.
This commit is contained in:
parent
cc8442dec8
commit
064440d597
23
src/fclang.c
23
src/fclang.c
|
@ -351,6 +351,13 @@ FcLangCompare (const FcChar8 *s1, const FcChar8 *s2)
|
||||||
{
|
{
|
||||||
FcChar8 c1, c2;
|
FcChar8 c1, c2;
|
||||||
FcLangResult result = FcLangDifferentLang;
|
FcLangResult result = FcLangDifferentLang;
|
||||||
|
FcChar8 *s1_orig = s1;
|
||||||
|
FcBool is_und;
|
||||||
|
|
||||||
|
is_und = FcToLower (s1[0]) == 'u' &&
|
||||||
|
FcToLower (s1[1]) == 'n' &&
|
||||||
|
FcToLower (s1[2]) == 'd' &&
|
||||||
|
FcLangEnd (s1[3]);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -361,14 +368,24 @@ FcLangCompare (const FcChar8 *s1, const FcChar8 *s2)
|
||||||
c2 = FcToLower (c2);
|
c2 = FcToLower (c2);
|
||||||
if (c1 != c2)
|
if (c1 != c2)
|
||||||
{
|
{
|
||||||
if (FcLangEnd (c1) && FcLangEnd (c2))
|
if (!is_und && FcLangEnd (c1) && FcLangEnd (c2))
|
||||||
result = FcLangDifferentTerritory;
|
result = FcLangDifferentTerritory;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (!c1)
|
else if (!c1)
|
||||||
return FcLangEqual;
|
{
|
||||||
|
return is_und ? result : FcLangEqual;
|
||||||
|
}
|
||||||
else if (c1 == '-')
|
else if (c1 == '-')
|
||||||
result = FcLangDifferentTerritory;
|
{
|
||||||
|
if (!is_und)
|
||||||
|
result = FcLangDifferentTerritory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we parsed past "und-", then do not consider it undefined anymore,
|
||||||
|
* as there's *something* specified. */
|
||||||
|
if (is_und && s1 - s1_orig == 4)
|
||||||
|
is_und = FcFalse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue