[Fontconfig] editing FcConfig in code

Idriss Fekir mcsm224 at gmail.com
Wed Apr 12 00:12:45 UTC 2023


Hi,

Some fonts aren't matched by fontconfig correctly e.g: the Amber Whiskey 
family has 4 faces Regular, Aged, Full Color, Shadow.
`fc-match "Amber Whiskey"` outputs "Aged" instead of "Regular", And 
since Pango relies on fontconfig for that, it also exhibits the same 
behavior (e.g: Inkscape an gimp, both rely on pango, would pick the 
"Aged" variant). This could be worked around with a rule:

```
<match target="pattern">
     <test name="family">
         <string>Amber Whiskey</string>
     </test>
     <edit name="style">
         <string>Regular</string>
     </edit>
</match>
```

My question is how can i do that but in code (in C), that is
how can i check what fc-match would output, then if the output is wrong 
add a rule like the following to the FcConfig?

I'm open to suggestions if there are better ways.

I did read the docs but i couldn't figure out how.

The man page for FcFontMatch says that it should only be called after 
FcConfigSubstitute and FcDefaultSubstitute have been called for
the pattern, i don't understand what that means exactly.

Thanks a lot.


More information about the Fontconfig mailing list