-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fontconfig does not recognize Cascadia as 'monospace' #118
Comments
You might be stumbling over resolution order or something. Insert Cascadia Code as the first entry for |
@nobeh I've always used <?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="pattern">
<test qual="any" name="family">
<string>monospace</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>Cascadia Code</string>
</edit>
</match>
</fontconfig> Maybe give it a try and see if it works for you. |
@nobeh yeah it's a bit baffling to me, though as mentioned I've always used this config (minus |
Not because we're malicious (edit: I said this not because anybody implied it, but because I wanted to be cheeky. Sorry :P), just because we don't know exactly what font metrics we need to ask for to make sure it works with freetype/xft/fontcache. |
(If you know what we need to change, we'd love to try it!) |
@DHowett-MSFT I know you guys aren't malicious, otherwise there wouldn't even be this repo lol |
A quick look at https://gitlab.freedesktop.org/fontconfig/fontconfig/blob/master/src/fcfreetype.c#L2382-2450 shows that it may be looking at the number of different advance widths. The ligatures will derail that logic. Maybe one needs to trick fontconfig into accepting it as a monospace font, but I find fontconfig configuration too obscure to know how :) The |
I think our ligature advance widths are actually the same as normal characters -- they all hang off to the left so they render in the right place.
The LIG glyphs have the same advances as the rest of the font to make sure there's space for the overhang on the left. |
Yeah I don't think it's the ligatures either since Fira Code works fine without the extra config. |
OK, so I took a look at the Glyphs source for Fira Code and the only thing that stood out to me as a possible reason why you're running into this issue is that Cascadia Code has a partial PANOSE set, whereas Fira Code has a complete one. PANOSE is an older system intended to help OS find a fallback font when a given font is not available. So if it knew it was looking for a black weight font with bracketed serifs, in normal width, PANOSE could tell them if XXX font has those characteristics. However, IIRC very few applications actually implemented this functionality and so font foundries kind of stopped bothering to implement it. Maybe GNU fontconfig cares about that? For fun I also looked at DejaVu Sans Mono and it also has a full PANOSE. No idea if it'll actually solve the issue, but we can give it a go. |
I believe I may have tracked down the reason for this issue. Per this discussion, older implementations of Freetype (and Windows??) can have issues is not every glyph in a font is the same width. Cascadia Code includes Combining Diacritical Marks that are zero width. As such, Freetype does not interpret these fonts as monospaced. Deja Vu Sans Mono, on the other hand, does not include these characters at all which may help it with being recognized by fontconfig. By using the "binding" attribute, you're essentially telling the system, "don't try to interpret anything or change anything, just use this font". That is probably bypassing Freetype's normal process. So that is why the font does work. The above aside, I note that the latest version of Fira Code also has zero width characters, but per @nobeh that font worked ok? So there might be another issue still. |
Hi @nobeh, can you try the latest version and let me know if the situation is improved? Else I'll close this issue. Thanks! |
@aaronbell Thanks a lot for all the details and nice work on this ticket. I just tried the latest version of the font. I confirm that with the initial
and $ fc-match monospace
Cascadia.ttf: "Cascadia Code" "Regular" ❤️ your attention and work on this! |
So glad it is working for you now! |
Environment
Steps to reproduce
I am using
fonts.conf
as:after updating the fontconfig and running
fc-cache -rfv
, Cascadia Code is listed as a new font however fc-query does not match the font withmonospace
:where trying to query the font file:
The expected behavior as common with fontconfig is that when
monospace
is replaced with a specific font, any application usingmonospace
would getCascadia Code
as the actual font.The expected behavior is there for example with
Fira Code
. In addition, if I manually set the monospace font to Cascadia Code, it works. So, maybe an issue with fontconfig or how to set the name infonts.conf
?The text was updated successfully, but these errors were encountered: