Force match italic variant
Fontconfig has the ability to generate oblique variants of fonts if it is explicitly configured to do so, by editing fonts.conf. This is useful for generating italic variants for fonts which don't have, which is quite common (Fira Code in my case).
However, Kitty doesn't allow this, as it effectively only returns fonts that are found in the output of fc-list, as opposed to the data actually returned by fc-match.
As an example, in kitty/fonts/fontconfig.py, calling fc_match with italic as True gives:
>>> fc_match("FiraCode Nerd Font Mono",False,True)
{
'path':
'/home/zuzi/.local/share/fonts/FiraCodeNerdFont/Fira Code Regular Nerd Font Complete Mono.otf',
'family': 'FiraCode Nerd Font Mono',
'style': 'Regular',
'full_name': 'Fira Code Regular Nerd Font Complete Mono',
'postscript_name': 'FiraCodeNerdFontCompleteM-Regular',
'weight': 80,
'width': 100,
'slant': 100,
'hint_style': 3,
'index': 0,
'subpixel': 1,
'lcdfilter': 1,
'hinting': True,
'scalable': True,
'outline': True,
'color': False,
'spacing': 'MONO'
}
Note it found the right font, and recognizes the slant, whereas calling find_best_match with the same gives
>>> find_best_match("FiraCode Nerd Font Mono",False,True)
{
'path':
'/home/zuzi/.local/share/fonts/FiraCodeNerdFont/Fira Code Regular Nerd Font Complete Mono.otf',
'family': 'FiraCode Nerd Font Mono',
'style': 'Regular',
'full_name': 'Fira Code Regular Nerd Font Complete Mono',
'postscript_name': 'FiraCodeNerdFontCompleteM-Regular',
'weight': 80,
'width': 100,
'slant': 0,
'index': 0,
'scalable': True,
'outline': True,
'color': False,
'spacing': 'MONO'
}
You also can't trick it by using an alias or something, since it checks the family of the aliased font against the fc-list output (Also fc_match only checks the family name I think? So it wouldn't even work with variants like "Medium)
I think the ideal solution would be to have an exact specifier for fonts that lets you specify a pattern that can be passed to fc_match and the result used verbatim (Probably using the full_name of the font instead of family at least, or setting the style parameters)
I think this used to work at some point? I previously had a config that basically did this, but I'm not sure
I dont follow why do you need to "generate" an italic variant. Just use an actual italic font. You can specify one independently from the main font using italic_family in kitty.conf.
So the problem is that using a completely different font for italics looks quite out of place, size it'll have different metrics and appearance. Although using the generated italics obviously won't look as good as a purpose built italic font (since it's literally just the regular font but slanted), at the very least it will match the appearance and metrics of the regular font, including the available ligatures. I'm currently using Fira Code with Iosevka for italics, and while it looks okay, I personally would prefer to have the option to just naively slant the main font to have more consistency
This is not worth the effort to me. Use a fontforge script to generate a slanted variant of Iosevka with a modified family name so you can use it with italic_family