Reputation: 629
Recently, a windows user made us aware that Japanese (and other unicode) characters in our app don't display properly under Windows. He just gets boxes with numbers instead.
We're using Pango, Fontconfig/freetype and rendering with Cairo. In Unix (that is, both Linux and macOS) it works perfectly. However, under Windows we just can't seem to get it to work.
I imagine it has to do with how font fallback/linking works under Windows, but I have no idea even where to begin looking into making this work properly.
Upvotes: 3
Views: 2557
Reputation: 2449
Linux systems are built around fontconfig and font substitution, so fonts available under Linux are curated to work well in that scenario.
It is very common to encounter in other systems fonts that do stupid stuff like mapping all the glyphs the font designer has not drawn yet to a placeholder symbol (typically squarish). When fontconfig encounters such a font it won't replace the missing glyphs with material from other fonts, since the font already declares something to display for those codepoints.
Another common case is non-latin fonts shipping quick and dirty latin glyphs so software that can not substitute fonts still displays errors in English. They require specific rules in fontconfig, to promote the useful part of the font, but not the fill-in one.
Upvotes: 2
Reputation: 629
Turns out the issue is simpler than expected, but not very well documented anywhere. Fontconfig needs its config files (fonts.conf and the secondary configs found under conf.d). In linux it's never an issue because most (if not all) distros use fontconfig by default so even if one botches it, there's still a system config to fall back on.
By contrast, windows doesn't normally use fontconfig, so unless devs ship out a set of fontconfig configuration files, it will at most load the specified fonts but it won't be able to do anything else (like font fallback).
The solution to this is to ship out a "fonts" folder containing at least fonts.conf and also any appropriate definitions from conf.d, usually the folder should be in the same folder as the fontconfig library. (and if that doesn't work you can set FONTCONFIG_PATH to ".")
Finally, unless you actually made any special changes to the config, you can just copy the default config files from /etc/ to ship out with your app.
Upvotes: 3