[Interest] Qt uses fontconfig on Linux, but what about Windows?

Allan Sandfeld Jensen kde at carewolf.com
Mon Dec 18 11:20:50 CET 2023


On Montag, 18. Dezember 2023 05:14:38 CET Thomas Larsen Wessel wrote:
> Thanks :) In case others will be looking / googling for this, I will try to
> share what I found out in the meantime. Please correct me where I am wrong
> 
> :)
> 
> At first I thought fontconfig was more of a software library that should
> serve as an intermediate layer between OS and whatever piece of software
> one might build (in Qt or not). I thought it would serve as an abstraction
> so that I could query / access (and maybe even install) fonts on the OS, no
> matter if the OS is Windows, Linux, etc.
> 
> I think fontconfig is more like a service that is installed independently
> (ie not something that comes bundled with a piece of software that one
> installs) on the OS. It happens to be installed by default on at least most
> Linux distributions (and maybe also on FreeBSD? MacOS?). It is possible to
> install fontconfig on Windows (or at least it was at some point in the
> past), but it is generally not a used or recommended solution. If one
> Googles for this, the results are old and sparse.
> 
Fontconfig is a full fontdatabase system. It searches for and implements 
queries for fonts.  macOS and Windows already have system services for this, 
Linux does not, which makes fontconfig  the default. For Qt though we also 
have a system where Qt itself searches defined directories without fontconfig, 
but I think that is only for embedded Linux systems, or for applications that 
bundles their own fonts.

If you look in src/gui/text you can in new qt versions see multiple subdirs, 
coretext, freetype, unix and windows. They contain implementation of the Qt 
fontengine backends and fontdatabase backends. In the unix subdir is the 
fontconfig fontdatabaes backend, whiile coretext and windows dirs contain both 
fontengine and fontdatabse backends for the respective platforms.


> 
> So in short, if I want to find a generic way of getting / querying /
> installing fonts across OS'es (including Windows), fontconfig is probably
> not the way to go, though it may technically be possible.
> 
Yeah, that is complicated. I think you can do it with Qt APIs, but I wouldn't 
know how myself.

Best regards
Allan




More information about the Interest mailing list