[Fontconfig] Detecting whether a font is a fallback

Akira TAGOH akira at tagoh.org
Thu Apr 20 08:56:28 UTC 2023


Well, no, unfortunately we don't. In the first place, most
applications request a font with a generic family name. In that sense,
the result will always be a fallback. and there is no way to know in
fontconfig which one is reliable.

We could export a result of score that fontconfig figured out from
FcPattern and see how it was picked up though. that may be too
primitive. may need to think about better interface.

On Thu, Apr 20, 2023 at 7:56 AM Jean Abou Samra <jean at abou-samra.fr> wrote:
>
> Hi,
>
> Suppose I call FcFontMatch on a font pattern with a family name that doesn't exist on my system. I get some default system font.
>
> Is there a reliable way to tell whether the FcPattern I get is for a fallback font like this? I could compare the two FC_FAMILY values, but it seems that Fontconfig does some case transformations — and possibly other things like replacing dashes? Is there a simple way to know if two FC_FAMILY strings match? Is there a better approach that I'm missing?
>
> This is for LilyPond, which has ways of configuring fonts, and where we'd like to display a warning if a font is not found (unlike a GUI application, which just wants to display the text even if it's in a suboptimal font).
>
> Thanks,
>
> Jean
>


-- 
Akira TAGOH


More information about the Fontconfig mailing list