#SVG fonts not being respected in PDF

19 messages · Page 1 of 1 (latest)

balmy geode
#

Loading an SVG image with text disregards the fonts specified in the SVG and instead writes all text with the document's font.

#

Here's the SVG in question

#

Expected (as seen in Firefox or the system's image viewer) :

#

Especially, the monospaced text is lost

stark remnant
#

Was this created in the web app?

#

Probably means the font is somehow not available

balmy geode
#

Locally in vscode

#

Generated by PlantUML

#

The SVG specifies monospaceas the font, which should default to the defaut system monospace font

#

I guess changing it to a font that's actually installed on the system would work

#

Correctly rendered in Inkscape, the text box's font is, as suspected, the default monospace

#

Yeah, overwriting the font with a "real" font does works

#

Solved as follows :

let file = read("../figures/" + match.captures.first() +".svg")
if file != none {
    // set text(font: "Arial")
    file = file.replace("monospace", "Consolas")
    file = file.replace("sans-serif", "Arial")
    image.decode(file, width: width, height: height, alt: alt)
} else {
    panic("[eki] PlantUML : Rendered diagram not found: '../figures/" + match.captures.first() +".svg' Run PlantUML over the source document first.")
}
balmy geode
# stark remnant Probably means the font is somehow not available

To clarify, monospaceis a generic font family defined in the CSS specification, which also applies to SVG. It should fall back to a "default" monospace font installed on the system (I would assume the default font that rawuses)
https://www.w3.org/TR/SVG11/fonts.html#FontFaceElementFontFamilyAttribute
https://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#generic-font-families

The SVG file can be preprocessed as I've done above, so at least there's a way around the issue

stark remnant
#

👍 yeah it's possible that there are font fallback issues, but it's unfortunately not my "area of expertise" so I can't help much there. Feel free to open an issue about it in GitHub though.

mystic kiln
#

looks like one more case of typst not supporting generic families nor fontconfig

balmy geode
#

it's a fallback issue