How do I set the fallback font for special characters in Pango strings on Windows?

834 views Asked by At

My application displays strings using Pango, Cairo and GTK3. Some of those strings include some special characters, including one not in the Unicode basic plane. On Linux this just worked, but on Windows it can't find the special characters and displays the unknown character box instead.

I'm using Roboto for the text, but it doesn't include these characters. Using a trick I found here I've discovered that on Linux the underlying fontconfig library fails over to Symbolica or STIX.

FC_DEBUG=4 pango-view -q -t '{character}' 2>&1 | grep -o 'family: "[^"]+' | cut -c 10- | tail -n 1

I've tried installing those fonts on the Windows machine, but no joy.

My Windows machine is running Mingw-w64 which ships with /etc/fonts containing the fontconfig files, but they don't seem to be doing the right thing. Unfortunately pango-view doesn't seem to be paying attention to the FC_DEBUG environment variable there so I can't find out what it's doing.

How can I tell fontconfig on Windows where to get glyphs for code points that Roboto doesn't provide?

Update: I've set AttrFallback on the strings in question to be True, just in case the Pango builds were treating this differently on Linux and Windows. Still no luck.

1

There are 1 answers

0
Paul Johnson On

I still don't know why this works differently in Windows and Linux, but the answer turned out to be hidden in the Pango.FontDescription.set_family documentation:

In some uses of pango.FontDescription, it is also possible to use a comma separated list of family names for this field.

When I added the required fallback fonts in a comma-separated list it worked.