https://issues.apache.org/bugzilla/show_bug.cgi?id=46374
--- Comment #4 from Alexis Andre <[email protected]> 2009-05-13 23:47:10 PST --- I found at least one issue with font embedding. The way Batik is storing the font usage information is storing the wrong font name, so it generates the glyphs using a default Dialog font when the desired font is not available system-wide. In svggen.SVGFont.java: ############ private static Font createCommonSizeFont(Font font) { Map attributes = new HashMap(font.getAttributes()); attributes.put(TextAttribute.SIZE, new Float(COMMON_FONT_SIZE)); // Remove Transform from font otherwise it will be applied twice. attributes.remove(TextAttribute.TRANSFORM); return new Font(attributes); } ############ The last line that is calling the Font constructor actually fails silently if the "font" object is not a system font. This is called when creating the map of which characters are used by which font, so the String used to store the font family and weight correspond to the Dialog font used as a fallback. A simple way to solve this problem would be to use the deriveFont method instead: ############ private static Font createCommonSizeFont(Font font) { Map attributes = new HashMap(font.getAttributes()); attributes.put(TextAttribute.SIZE, new Float(COMMON_FONT_SIZE)); // Remove Transform from font otherwise it will be applied twice. attributes.remove(TextAttribute.TRANSFORM); return font.deriveFont(attributes); } ############ (or maybe just a ############ private static Font createCommonSizeFont(Font font) { return font.deriveFont(new Float(COMMON_FONT_SIZE)); } ############ but I am not sure about the transform you are removing) Since any generated SVG file contains the non-system font name and family, but uses the default shapes (see the previous attachment), I guess the fonts are stored in a different place, but the toSVG method is calling anyway createCommonSizeFont before generating the glyphs. Why I am not commiting a patch is because I have not found yet where the xmlwriter is calling the toSVG method of SVGFont that is actually writing the glyph shapes. I am wondering when the method is actually called (non system fonts might be destroyed between the drawString call and the stream call). I hope this helps. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
