Re: editing FcConfig in code

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

 





On 4/14/23 12:16, Akira TAGOH wrote:
On Thu, Apr 13, 2023 at 10:48 PM Idriss Fekir <mcsm224@xxxxxxxxx> 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.

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



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

  Powered by Linux