fontconfig: Branch 'master'

[email protected] (Behdad Esfahbod)
Newsgroups gmane.comp.fonts.fontconfig
Message-ID <[email protected]>
 src/fclang.c |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

New commits:
commit 064440d59797b1158badfb9144f3188cda11a791
Author: Behdad Esfahbod <[email protected]>
Date:   Thu Aug 3 11:02:32 2017 +0100

    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.

diff --git a/src/fclang.c b/src/fclang.c
index 8418b46..1eee8ef 100644
--- a/src/fclang.c
+++ b/src/fclang.c
@@ -351,6 +351,13 @@ FcLangCompare (const FcChar8 *s1, const FcChar8 *s2)
 {
     FcChar8	    c1, c2;
     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 (;;)
     {
@@ -361,14 +368,24 @@ FcLangCompare (const FcChar8 *s1, const FcChar8 *s2)
 	c2 = FcToLower (c2);
 	if (c1 != c2)
 	{
-	    if (FcLangEnd (c1) && FcLangEnd (c2))
+	    if (!is_und && FcLangEnd (c1) && FcLangEnd (c2))
 		result = FcLangDifferentTerritory;
 	    return result;
 	}
 	else if (!c1)
-	    return FcLangEqual;
+	{
+	    return is_und ? result : FcLangEqual;
+	}
 	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;
     }
 }
 
_______________________________________________
Fontconfig mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/fontconfig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.