Fontconfig needs support for detecting dual-width fonts.
Created attachment 54 [details] [review]
There are some unexpected results with this patch, including the following:
Lucida Console Regular: spacing = 90 [advances = 1234, 1235]
Nimbus Mono L Bold Oblique: spacing = 90 [advances = 600, 740]
Courier 10 Pitch Italic: spacing = 90 [advances = 602, 607]
(No wonder lucida console wasn't showing up as monospace!)
Can we safely ignore these broken fonts?
Created attachment 55 [details] [review]
new patch checks that the advances are roughly 2:1 (within 1%)
Created attachment 56 [details] [review]
this patch is the same as above, except that it checks for approximate equality wherever it makes sense
The extra change in that last patch sort of belongs in its own bug, but since it
is so intertwined in this patch I just added it here. It lets things like
"Lucida Console", with its two different but approximately equal advances, pass
for monospace fonts.
-#define APPROXIMATELY_EQUAL(x,y) (ABS ((x) - (y)) < MAX (ABS (x), ABS (y)) / 100)
+#define APPROXIMATELY_EQUAL(x,y) (ABS ((x) - (y)) <= MAX (ABS (x), ABS (y)) / 100)
otherwise APPROXIMATELY_EQUAL (50, 50) is false.
Bug 82 also deals with dual-width fonts.
In addition to the patch committed on May 12 for bug 82, I think this or similar
patch is necessary., .
With the patch committed on May 12, CJK dual-width fonts don't have
'spacing=100' (monospace) any more in font-cache file. If it's not 'spacing=100'
(monospace), there must be something to indicate 'dual-width-ness' of a font as
is done in the patch uploaded here.
BTW, 1% does not work for 'infamous' Dynalab Chinese fonts. They have the half
width of 500 and the full width of 1024 (or 512 : 1000)
Should we ignore dynalab, or change it to 3%?
It seems like Chinese(Hong Kong and Taiwan) Linux users use them pretty often so
that we have to be generous. Is there any non-dual-width font that might be
mistaken if we increase the error margin to 3%?
You're probably right, chances are slim that there could be a proportional width
font that happens to match within 3%.
2003-09-06 Noah Levitt <email@example.com>
* src/fcfreetype.c (FcFreeTypeCharSetAndSpacing): Add new spacing
value FC_DUAL (dual-width, as some CJK fonts). (bug #111)
* src/fcfreetype.c (FcFreeTypeCharSetAndSpacing): When checking for
monospace and dual-width fonts, allow roughly a 3% variance in the
If we want to be 100% sure, we can add a check for U+4E00 (Chinese character
number 1) and U+AC00(the first Korean syllable. some Korean fonts don't have a
single Chinese character). The presence of either of them, in addition to the
fact that it falls within our allowance (3%), should be a sure sign :-)