/**
   * creates a font based on the parameter. The size will be {@link SVGGlyph#FONT_SIZE} and
   * transformation will be removed. Example:<br>
   * <code>java.awt.Font[family=SansSerif,name=SansSerif,style=plain,size=30]</code><br>
   * will result to:<br>
   * <code>java.awt.Font[family=SansSerif,name=SansSerif,style=plain,size=100]</code><br>
   * <br>
   * This method does not substitute font name or family.
   *
   * @param font
   * @return font based on the parameter
   */
  private Font untransform(Font font) {
    // replace font family
    Map<Attribute, Object> attributes = FontUtilities.getAttributes(font);

    // set default font size
    attributes.put(TextAttribute.SIZE, new Float(SVGGlyph.FONT_SIZE));

    // remove font transformation
    attributes.remove(TextAttribute.TRANSFORM);
    attributes.remove(TextAttribute.SUPERSCRIPT);

    return FontMap.getFont(attributes);
  }
  /**
   * creates the font entry:
   *
   * <PRE>
   * <font>
   * <glyph ... />
   * ...
   * </font>
   * </PRE>
   *
   * @return string representing the entry
   */
  @Override
  public String toString() {
    StringBuffer result = new StringBuffer();

    Enumeration<Font> fonts = this.glyphs.keys();
    while (fonts.hasMoreElements()) {
      Font font = fonts.nextElement();

      // replace font family for svg
      Map<Attribute, Object> attributes = FontUtilities.getAttributes(font);

      // familiy
      result.append("<font id=\"");
      result.append(FontIncluder.getFontPSName(font));
      result.append("\">\n");

      // font-face
      result.append("<font-face font-family=\"");
      result.append(
          FontUtilities.getWindowsFontFamily((String) 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");

      // regular glyphs
      Iterator<SVGGlyph> glyphs = getGlyphs(font).values().iterator();
      while (glyphs.hasNext()) {
        result.append(glyphs.next().toString());
        result.append("\n");
      }

      // close "<font>"
      result.append("</font>\n");
    }

    return result.toString();
  }