blackears / svgSalamander

155 stars 56 forks source link

Embedded SVG fonts don't seem to register correctly #20

Open arlith opened 7 years ago

arlith commented 7 years ago

Font.loaderEndElement calls Universe.registerFont. Universe keeps a map of font face names that map to Font instances. However, at the time Font.loader.EndElement is called, FontFace.build has not been called, which means that FontFace.fontFamily will be null. This means that any <font> tags in the SVG will get registered in the Universe with a key value of null.

As far as I can tell, this makes it so no <font> tags will ever get used properly.

mgiorgino commented 7 years ago

Same problem for me. Did you find a workaround ?

arlith commented 7 years ago

I did not find a way to get embedded SVG fonts to work (the <font> tag). I ended up using SVGSalamander's FontSystem class. If you look at line 283 of Text.java, if the Universe doesn't know about the requested font-family, it will call FontSystem.createFont(4). Ultimately, this can end up using a java.awt.Font that the JVM knows about.

However, I did find that SVGSalamander uses ints in the MissingGlyph class to store the bounding volume of the glyph for an individual character. Depending on the font you use, this can cause kerning issues. I created a PR to fix this issue (#21).