[PATCH 1/1] FcLangSetCompare(): fix bug when two charsets come from different "buckets"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In fcLangCountrySets, it may happen that two charsets for the same
language but different territories are found in different FcChar32
"buckets" (different "columns" on the same line). This is currently the
case for the following pairs:

  mn-cn  and mn-mn
  pap-an and pap-aw

The FcLangSetCompare() code so far used to return FcLangDifferentLang
instead of FcLangDifferentTerritory when comparing:

  an FcLangSet containing only mn-cn with one containing only mn-mn

or

  an FcLangSet containing only pap-an with one containing only pap-aw

This commit fixes this problem.
---
 src/fclang.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/fclang.c b/src/fclang.c
index dbbe721..18a373c 100644
--- a/src/fclang.c
+++ b/src/fclang.c
@@ -680,6 +680,7 @@ FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb)
 {
     int		    i, j, count;
     FcLangResult    best, r;
+    FcChar32 aInCountrySet, bInCountrySet;
 
     count = FC_MIN (lsa->map_size, lsb->map_size);
     count = FC_MIN (NUM_LANG_SET_MAP, count);
@@ -688,13 +689,22 @@ FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb)
 	    return FcLangEqual;
     best = FcLangDifferentLang;
     for (j = 0; j < NUM_COUNTRY_SET; j++)
+    {
+	aInCountrySet = 0;
+	bInCountrySet = 0;
+
 	for (i = 0; i < count; i++)
-	    if ((lsa->map[i] & fcLangCountrySets[j][i]) &&
-		(lsb->map[i] & fcLangCountrySets[j][i]))
+	{
+	    aInCountrySet |= lsa->map[i] & fcLangCountrySets[j][i];
+	    bInCountrySet |= lsb->map[i] & fcLangCountrySets[j][i];
+
+	    if (aInCountrySet && bInCountrySet)
 	    {
 		best = FcLangDifferentTerritory;
 		break;
 	    }
+	}
+    }
     if (lsa->extra)
     {
 	r = FcLangSetCompareStrSet (lsb, lsa->extra);
-- 
2.11.0

_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/fontconfig




[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux