Bug 48 - FcCharSetIsSubset returns wrong result
Summary: FcCharSetIsSubset returns wrong result
Status: RESOLVED FIXED
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: 2.1
Hardware: x86 (IA32) FreeBSD
: high normal
Assignee: Keith Packard
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-17 23:23 UTC by ITO Tsuyoshi
Modified: 2003-03-17 05:04 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Sample program written in C to reproduce problem (1.72 KB, text/plain)
2003-03-17 23:25 UTC, ITO Tsuyoshi
Details

Description ITO Tsuyoshi 2003-03-17 23:23:32 UTC
FcCharSetIsSubset(cs1, cs2) sometimes returns true even if cs1 is not a subset
of cs2.
This causes FcFontSort (with parameter `trim' set to true) to return fewer fonts
than it should, and Pango to draw some characters as `unknown characters'
(squares with character codes written inside) when it should not.
It is always reproducible with Fontconfig 2.1 and 2.1.92 on my environment.
I have not tried CVS versions of Fontconfig.
I will post sample code shortly.
Comment 1 ITO Tsuyoshi 2003-03-17 23:25:34 UTC
Created attachment 33 [details]
Sample program written in C to reproduce problem
Comment 2 Keith Packard 2003-03-17 23:32:33 UTC
Can you provide a pair of fonts which cause the test to fail?
Comment 3 ITO Tsuyoshi 2003-03-17 23:35:09 UTC
Now I will :)

The result:
> ./attachment33 [details] 'Kochi Mincho' 'Charter'
cs1 has the character.
cs2 does not have the character.
FcCharSetIsSubset says cs1 is a subset of cs2.

Here, Kochi Mincho is a Japanese TrueType font and Charter is an English
non-TrueType font.
The first two lines of the result shows correctly that Kochi Mincho contains the
character U+65E5 (a CJK unified ideograph) and that Charter does not.
FcCharSetIsSubset should return false, but actually it returns true.
Comment 4 Keith Packard 2003-03-17 23:46:25 UTC
Can you test the following patch?

Index: fccharset.c
===================================================================
RCS file: /local/src/CVS/fontconfig/src/fccharset.c,v
retrieving revision 1.21
diff -u -r1.21 fccharset.c
--- fccharset.c 5 Mar 2003 05:51:27 -0000       1.21
+++ fccharset.c 18 Mar 2003 07:45:23 -0000
@@ -637,7 +637,7 @@
                bi++;
        }
     }
-    return FcTrue;
+    return ai >= a->num;
 }
 
 /*
Comment 5 ITO Tsuyoshi 2003-03-17 23:56:14 UTC
Seems to fix the problem.  Thank you for your rapid reply!
Comment 6 Keith Packard 2003-03-18 00:04:07 UTC
Thanks for the test case; that's the fastest way to a fix...


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.