As Qianqian Fang reported, fc-cache cannot recognize bitmap-only TTF well. I wrote a patch to scan a strike instead of glyf table (specified by setting environmental variable FC_BITMAP_SIZE), by hooking FcFreeTypeCheckGlyph(). Although I wrote for obsolete fontconfig-2.2.3, but I suppose it can be applicable to latest fontconfig.
Created attachment 6773 [details] [review] patch to use specified bitmap strike for glyph availability check When environmental variable is set as FC_BITMAP_SIZE="12,14,0,16,18", fc-cache lookups 12pixel strike for first. If the font provide it, fc-cache checks the glyph availability by glyph data by 12pixel strike. If the font has no 12pixel strike, fc-cache lookups 14pixel in next. If the font has no 12/14pixel strikes, fc-cache lookups vector data in next. If the font has no 12/14pixel strike or vector data, fc-cache lookups 16pixel strike in next...
Keith, anything to pick from this bug?
we'd need to have a font that doesn't currently work; every bitmap-only TTF I've created has a glyf table, making this patch unnecessary.
Created attachment 12576 [details] TTF-packed font that I and Qianqian Fang discussed Behdad, thank you for reminding this to Keith. This is the bitmap-only TrueType font that I and Qianqian Fang discussed (and I wrote the patch for). The file is too large to fit within 1MB, I divide it into 2 parts.
Created attachment 12577 [details] TTF-packed font that I and Qianqian Fang discussed here is part 2.
fontconfig-2.4.91 generates following line into cache: "wqy-bsong.ttf" 0 "WenQuanYi Bitmap Song,文泉驿点阵宋体 :familylang=en,zh-sg:style=medium:stylelang=en: fullname=WenQuanYi Bitmap Song-medium:fullnamelang=en:slant=0:weight=100:width=100 :pixelsize=12,13,15,16:spacing=100:foundry=unknown :antialias=False:index=0:outline=False:scalable=False :charset=:lang=:fontversion=45875 :capability=otlayout\\:DFLT:fontformat=TrueType:decorative=False" As you can find, the charset is empty. That's what I and Qianqian Fang were trying to fix.
Created attachment 16336 [details] [review] Look for glyphs in a bitmap when the glyf table is missing This patch checks fonts which have no glyphs to see if they are fixed-size true type fonts. If so, it then selects a single size (nearest 16 pixels) and uses that to measure the font coverage. Please test and report back if it doesn't work for you.
I haven't heard any response to the proposed patch (which is in master), so I'm closing this bug.
At present I don't have a time to execute comprehensive checking, but I confirmed that wqy-bsong.ttf (I attached ever) is recognized as non-empty TTF. Anyway the situation was improved. Thanks. There are two points I have to consider. * the patch tries to check bitmap table when FcCharSetCount is zero. If a TTF has only a few outline glyphs (e.g. Roman characters) and many bitmap glyphs (e.g. CJK ideographs), how fontconfig should handle it? * the patch check the pixel size which is the nearest size to 16pixel. I guess 10-14 pixels are popular among CJK bitmap only fonts. I wish if the size is configurable in ./configure options.
If the font has any outline characters, it will need a glyf table to map them. Until we find a counter example, we'll assume that any sane font will have a complete glyf table if it has any glyf entries. Also, it only looks at a single bitmap instance; assuming (once again, until we find a counter example) that a font will have all of the same bitmaps at each size, and not subset them at some sizes. I strongly prefer not providing configuration until we find a place where it is needed, and even then, it would be best to figure out a mechanism which doesn't require that the user "know" about the fonts they are installing.
OK, when I find a TTF described as above (the coverage of glyf table is smaller than that of bitmap tables), I will file another entry in bugzilla. Thus I have no objection to close this bug now.
*** Bug 81375 has been marked as a duplicate of this bug. ***
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.