<p>Le mercredi 12 avril 2023 à 01:12 +0100, Idriss Fekir a écrit :</p>
<blockquote type="cite">
<p>Hi,</p>
<p>Some fonts aren't matched by fontconfig correctly e.g: the Amber Whiskey<br />
family has 4 faces Regular, Aged, Full Color, Shadow.<br />
<code>fc-match "Amber Whiskey"</code> outputs "Aged" instead of "Regular", And<br />
since Pango relies on fontconfig for that, it also exhibits the same<br />
behavior (e.g: Inkscape an gimp, both rely on pango, would pick the<br />
"Aged" variant). This could be worked around with a rule:</p>
<pre><code><match target="pattern">  
     <test name="family">  
         <string>Amber Whiskey</string>  
     </test>  
     <edit name="style">  
         <string>Regular</string>  
     </edit>  
</match>  
</code></pre>
<p>My question is how can i do that but in code (in C), that is<br />
how can i check what fc-match would output, then if the output is wrong<br />
add a rule like the following to the FcConfig?</p>
<p>I'm open to suggestions if there are better ways.</p>
<p>I did read the docs but i couldn't figure out how.</p>
<p>The man page for FcFontMatch says that it should only be called after<br />
FcConfigSubstitute and FcDefaultSubstitute have been called for<br />
the pattern, i don't understand what that means exactly.</p>
<p>Thanks a lot.</p>
</blockquote>
<p>I'm not a Fontconfig developer, but I will try to answer your question anyway.</p>
<p>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.</p>
<p>If you're not taking it from a package, I think you could try</p>
<pre><code>FcConfigParseAndLoad(NULL, (FcChar8 *) "your-config-file.conf", FcTrue);
</code></pre>
<p>or</p>
<pre><code>FcConfigParseAndLoadFromMemory(NULL, (FcChar8 *) "<the string of Fontconfig XML code that you would put in a file>", FcTrue);
</code></pre>
<p>Best,</p>
<p>Jean</p>