Re: editing FcConfig in code

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

 



Nevermind. you can simply drop the 3rd test then.

> Is there a way to match fonts by their PostScript name?

Yes. you can use "postscriptname" property.

> My goal is, at application startup to check for fonts that aren't
> matched properly, then remap then load the config, is there a general
> solution?

That depends on the meaning of "not matched". speaking of the fallback
font, that is exactly what fontconfig does. In case of your issue,
that is the case-by-case. If there are any generally useful solutions,
please let us know.

On Thu, Apr 13, 2023 at 8:04 AM Idriss Fekir <mcsm224@xxxxxxxxx> wrote:
>
>
>
> On 4/12/23 08:45, Akira TAGOH wrote:
> > First of all, Please note that "Regular" style is default style
> > though, most applications request *Regular weight* instead of style
> > name. So the correct command to represent a request is `fc-match
> > "Amber Whiskey:weight=regular".
> > Based on that, let's see what happened.
> >
> > AmberWhiskey-Aged.otf has two family names. one is "Amber Whiskey" and
> > one is "Amber Whiskey Aged". And, weight is set to 80 which is the
> > same as FC_WEIGHT_REGULAR. So the behavior itself isn't wrong.
> >
> > Second, I don't recommend using the above config because that will
> > break non-Regular selection. I didn't test but this may works instead:
> >
> > <match>
> >    <test name="family">
> >      <string>Amber Whiskey</string>
> >    </test>
> >    <test name="weight">
> >      <const>regular</const>
> >    </test>
> >    <test qual="all" name="style" compare="eq">
> >      <string></string>
> >    </test>
> >    <edit name="style">
> >      <string>Regular</string>
> >    </edit>
> > </match>
> >
> > This will add Regular to style property only when weight is set to
> > "regular" and no styles is set. you can still pick up the aged variant
> > with "Amber Whiskey:style=Aged".
> >
> > If you don't want to see the aged variant as a part of "Amber
> > Whiskey", things would be much simpler. you may have another
> > workaround like this:
> >
> > <match target="scan">
> >    <test name="family">
> >      <string>Amber Whiskey</string>
> >    </test>
> >    <test name="family">
> >      <string>Amber Whiskey Aged</string>
> >    </test>
> >    <edit name="family" mode="delete" />
> > </match>
> >
> > This will modify the fontconfig cache. AmberWhiskey-Aged.otf is then
> > represented as "Amber Whiskey Aged" only.
> >
> > For your original question, if there are any reasons you can't put
> > something into a config file, you can use
> > FcConfigParseAndLoadFromMemory() function as said in other mail.
> > otherwise you can create your own config for a workaround and put it
> > into $HOME/.config/fontconfig or something like that.
> >
> > Hope that helps,
> >
> > On Wed, Apr 12, 2023 at 9:12 AM Idriss Fekir <mcsm224@xxxxxxxxx> wrote:
> >>
> >> 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.
> >
> >
> >
> Thanks for your replies Jean and Akira.
>
> Akira, your first solution worked, but i don't understand what you meant
> that my config breaks non-regular selection, all other variants are
> matched correctly.
>
> Some faces of Iosevka (e.g Iosevka Fixed Extrabold Extended Oblique is
> matched as NotoSans Italic) also have this problem but fc-match returns
> the fallback font, so I'm not sure how to fix that .
>
> Is there a way to match fonts by their PostScript name?
>
> My goal is, at application startup to check for fonts that aren't
> matched properly, then remap then load the config, is there a general
> solution?
>
> Thanks
> --
> Idriss



-- 
Akira TAGOH




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

  Powered by Linux