public String toString() {
StringBuffer result = new StringBuffer();
Enumeration/*<Font>*/ fonts = this.glyphs.keys();
while (fonts.hasMoreElements()) {
Font font = (Font) fonts.nextElement();
// replace font family for svg
Map /*<TextAttribute, ?>*/ attributes = FontUtilities.getAttributes(font);
// Dialog -> Helvetica
normalize(attributes);
// familiy
result.append("<font id=\"");
result.append(attributes.get(TextAttribute.FAMILY));
result.append("\">\n");
// font-face
result.append("<font-face font-family=\"");
result.append(attributes.get(TextAttribute.FAMILY));
result.append("\" ");
// bold
if (TextAttribute.WEIGHT_BOLD.equals(attributes.get(TextAttribute.WEIGHT))) {
result.append("font-weight=\"bold\" ");
} else {
result.append("font-weight=\"normal\" ");
}
// italic
if (TextAttribute.POSTURE_OBLIQUE.equals(attributes.get(TextAttribute.POSTURE))) {
result.append("font-style=\"italic\" ");
} else {
result.append("font-style=\"normal\" ");
}
// size
Float size = (Float) attributes.get(TextAttribute.SIZE);
result.append("font-size=\"");
result.append(SVGGraphics2D.fixedPrecision(size.floatValue()));
result.append("\" ");
// number of coordinate units on the em square,
// the size of the design grid on which glyphs are laid out
result.append("units-per-em=\"");
result.append(SVGGraphics2D.fixedPrecision(SVGGlyph.FONT_SIZE));
result.append("\" ");
TextLayout tl = new TextLayout("By", font, new FontRenderContext(new AffineTransform(), true, true));
// The maximum unaccented height of the font within the font coordinate system.
// If the attribute is not specified, the effect is as if the attribute were set
// to the difference between the units-per-em value and the vert-origin-y value
// for the corresponding font.
result.append("ascent=\"");
result.append(tl.getAscent());
result.append("\" ");
// The maximum unaccented depth of the font within the font coordinate system.
// If the attribute is not specified, the effect is as if the attribute were set
// to the vert-origin-y value for the corresponding font.
result.append("desscent=\"");
result.append(tl.getDescent());
result.append("\" ");
// For horizontally oriented glyph layouts, indicates the alignment
// coordinate for glyphs to achieve alphabetic baseline alignment.
// result.append("alphabetic=\"0\"
// close "<font-face"
result.append("/>\n");
// missing glyph
SVGGlyph glyph = createGlyph(font.getMissingGlyphCode(), font);
result.append("<missing-glyph ");
result.append(glyph.getHorizontalAdvanceXString());
result.append(" ");
result.append(glyph.getPathString());
result.append("/>\n");