[Fontconfig] How to use FcFontMatch to find a font with a given character

Elias MÃ¥rtenson lokedhs at gmail.com
Sun Jul 1 03:46:19 UTC 2018

On 1 July 2018 at 10:30, Lawrence D'Oliveiro <ldo at geek-central.gen.nz>

> On Sun, 1 Jul 2018 00:41:01 +0800, Elias MÃ¥rtenson wrote:
> > Bug in Fontconfig?
> Check your version of Fontconfig:
>     ldo at theon:python_fontconfig> python3 -ic "import fontconfig"
>     >>> fontconfig.get_version()
>     21300
> I previously reported what I thought was a problem, only to discover
> that it had already been fixed.

When I was younger I occasionally made fun of people that rush to blame
tools rather than their own code. It's time for be to accept some of that

I had made an error in my code, causing it to escape the loop early and
only ever
checking the first page returned from FcCharSet*Page(). After fixing that,
I now confirm that of course there is no bug in Fontconfig.

That said, I did find a bug in the documentation. The manual for

The documentation states:


*Builds an array of bits in map marking the first page of Unicode coverage
of a. *next is set to contains the base code point for the next page in a.
Returns the base code point for the page, or FC_CHARSET_DONE if a contains
no pages. As an example, if FcCharSetFirstPage returns 0x300 and
fills map with*

0xffffffff 0xffffffff 0x01000008 0x44300002 0xffffd7f0 0xfffffffb
0xffff7fff 0xffff0003

*Then the page contains code points 0x300 through 0x33f (the first 64 code
points on the page) because map[0] and map[1] both have all their bits set.
It also contains code points 0x343 (0x300 + 32*2 + (4-1)) and 0x35e (0x300
+ 32*2 + (31-1)) because map[2] has the 4th and 31st bits set. The code
points represented by map[3] and later are left as an excercise for the
reader ;).*


The highlighted quote: *"because map[2] has the 4th and 31st bits set"* is
wrong. map[2] has the value 0x01000008 which doesn't have the 31'st bit set.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/fontconfig/attachments/20180701/c42b3995/attachment.html>

More information about the Fontconfig mailing list