Re: editing FcConfig in code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le mercredi 12 avril 2023 à 01:12 +0100, Idriss Fekir a écrit :

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.

I'm not a Fontconfig developer, but I will try to answer your question anyway.

As far as I understand, the intent of Fontconfig is to make font configuration shared and static. So, if the font in question is installed through a package manager, the package should normally also include a conf file that makes Fontconfig handle the font correctly.

If you're not taking it from a package, I think you could try

FcConfigParseAndLoad(NULL, (FcChar8 *) "your-config-file.conf", FcTrue);

or

FcConfigParseAndLoadFromMemory(NULL, (FcChar8 *) "<the string of Fontconfig XML code that you would put in a file>", FcTrue);

Best,

Jean

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux