-
Notifications
You must be signed in to change notification settings - Fork 228
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
Font family with number inside falls back to default font #804
Comments
Have you tried putting it in quotes? Aka By the CSS spec, a It might work in browsers, because they largely ignore the spec anyway for compatibility, but |
That makes sense and it works, though I'd say a bit counterintuitive 😓 Thanks! |
Maybe we should relax the rules a bit if it works in other browsers (and document it). |
I know, but that's the correct way.
Who knows how browsers parse |
Since I've also stumbled over this before #358 - perhaps the uncommonly (to most) strict font handling might be something that should be documented? Doesn't have to be that complex, just something along the lines of "resvg is very strict with fonts, so do make sure that you use exact matches in your font names and here is how you can figure out what the font names would be". |
Then I would have to write a whole document about all the possible edge cases. SVG spec is enormous. |
Hey @RazrFalcon how's it going?
There is weird bug that is happening from as long as I remember when handling texts. When providing
font-family
with number in its name for text elements (i.eNunito Sans 12pt
orSans Serif 4
) ReSVG fallbacks to default family (Times New Roman
forNunito Sans 12pt
) even though the family is present in the fontdb.It fails inside:
crates/usvg/src/parser/text.rs
onInside
svgtypes/src/stream.rs
on (I assume)parse_ident
function. I don't fully understand what is going on there, but the error isInvalidIdent
.I wouldn't bother with this, however some of the Google Fonts files (those I named) are parsed into fontdb with numbers inside family names. And basically it's not possible to use them because of the bug (or maybe numbers are not allowed by SVG specs?).
Example SVG (really any text element with specified font-family):
Example font: https://fonts.google.com/specimen/Nunito+Sans
(Yes it's called Nunito Sans but family name inside the file is with
{number}pt
)The text was updated successfully, but these errors were encountered: