[Fontconfig] editing FcConfig in code

Akira TAGOH akira at tagoh.org
Fri Apr 14 14:53:38 UTC 2023


2023年4月14日(金) 23:11 Idriss Fekir <mcsm224 at gmail.com>:

>
>
> On 4/14/23 12:16, Akira TAGOH wrote:
> > On Thu, Apr 13, 2023 at 10:48 PM Idriss Fekir <mcsm224 at gmail.com> wrote:
> >> Sorry, my question wasn't clear, what i meant is, is there a way in in
> >> the config file to say, "if given this string, match it to this psname,
> >> or this full_name", e.g: if given "Iosevka Extrabold Extended Oblique"
> >> match it to the font with psname:"Iosevka-Extrabold-Extended-Oblique".
> >
> > No. we could guess a postscript name from family and/or fullname but
> > it is't perfect because they are stored as independent metadata. they
> > are free to set regardless of regularity.
> >
> > So you need to do compare "family" and "postscriptname" separately.
> >
> >>>> 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.
> >>>
> >>
> >> What could be done in this particular case? that is,
> >> `fc-match "Isoveka Extrabold Extended Oblique"` outputs
> >> `Noto Sans Regular` instead of the correct font.
> >
> > You want to substitute it with Noto Sans no matter what they exist and
> > change the weight and the slant too?
>
> No, i just want for the font to match correctly,
> `fc-match "Isoveka Extrabold Extended Oblique"` should output
> `iosevka-extrabold.ttc: "Iosevka" "Extrabold Extended Oblique"`
> but it doesn't output that. It outputs `NotoSans-Regular.ttf: "Noto
> Sans" "Regular"`, which is wrong since i do have that Iosevka font
> installed.
>

Ah, got it. You set the wrong query string then. What you want to would be:

$ fc-match ":full name=Isoveka Extrabold Extended Oblique"

Or

$ fc-match "Isoveka:style=Extrabold Extended Oblique"

Though I'm not sure what the real issue was then. I presume that you wanted
to reproduce your issue on some application with fc-match?


> The only way i'm getting the correct font is with
> `fc-match ":postscriptname=Iosevka-Extrabold-Extended-Oblique"`
> i just want the output of:
> `fc-match "Isoveka Extrabold Extended Oblique"`
> to be identical to the output of:
> `fc-match ":postscriptname=Iosevka-Extrabold-Extended-Oblique"`
> (because matching like this with the psname outputs the correct font)
>
> Really sorry that my previous question wasn't clear enough.
>
> > I didn't test but this may *theoretically* works:
> >
> > <match>
> >    <test name="fullname">
> >      <string>Isoveka Extrabold Extended Oblique</string>
> >    </test>
> >    <edit name="family" mode="prepend">
> >      <string>Noto Sans</string>
> >    </edit>
> >    <edit name="weight" mode="prepend">
> >      <const>regular</const>
> >    </edit>
> >    <edit name="slant" mode="prepend">
> >      <const>roman</const>
> >    </edit>
> > </match>
> >
> > This assumes that applications request a font with fullname. you may
> > need to replace it with "family", and "style" or "weight" and "slant"
> > in some case.
> > If you want to fallback only when they aren't available, that may be
> > much more complicated.
> >
> >> Another question, what does `FcConfigSubstituteWithPat` do, i couldn't
> >> understand from the man page.
> >
> > Well, there are three matching patterns in fontconfig. "pattern",
> > "font", and "scan". These patterns are performed only when "kind" is
> > the same. however, if you call FcConfigSubstituteWithPat(config,
> > pfont, ppat, FcMatchFont) then, you can get both "pattern" in ppat and
> > "font" in pfont FcPatterns. see FcFontRenderPrepare() for more
> > details.
> >
> >>
> >> Sorry for asking so many questions.
> >>
> >> Thank.
> >> --
> >> Idriss
> >
> >
> >
>
> Thank a lot.
> --
> Idriss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/fontconfig/attachments/20230414/74b308ee/attachment.htm>


More information about the Fontconfig mailing list