Reputation: 1779
I'm developing a simple web application that provides an URL for rendering an SVG image. I use Apache Batik library for SVG rendering and I have a problem with setting font-family
. I would like the resulting SVG to look identical (as it can) when viewed from any browser (mainly Chrome, FF and Edge) and any OS (mainly Linux and Windows). The problem is, that as I see, Batik uses some internal logic that loads fonts from the local system, and this prevents cross-platform behaviour.
To be more precise: my webapp runs on Ubuntu Linux, and I set font-family:'DejaVu Sans'
to my graphics. This works perfectly when the client uses Linux, but on Windows, obviously this font does not exist. I tried to set font-family
according to the User-Agent
header in the request, but when I set font-family:'Verdana'
for Windows clients, Batik tries to load the 'Verdana' font, and it obviously fails.
I tried to set the attribute like this: font-family:'DejaVu Sans',Verdana
but Batik can not handle comma-separated list of valid font families. Is there any way to resolve this besides installing the Verdana font on the server?
Upvotes: 2
Views: 774
Reputation: 1779
Finally I achieved it by including the font in my app and register it with GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font);
. This way Batik properly keeps the 'Verdana'
string in the font-family
attribute. Thanks for mike-pomax-kamermans for the helpful advice!
Upvotes: 2