Element el = getElement(); AttributeSet atts = el.getAttributes(); String family = StyleConstants.getFontFamily(atts); int size = StyleConstants.getFontSize(atts); int style = Font.PLAIN; if (StyleConstants.isBold(atts)) style |= Font.BOLD; if (StyleConstants.isItalic(atts)) style |= Font.ITALIC; Font font = new Font(family, style, size);
Document doc = getDocument(); Font font = null; if (doc instanceof StyledDocument) { StyledDocument styledDoc = (StyledDocument) doc; font = styledDoc.getFont(getAttributes()); } else { Container c = getContainer(); if (c != null) font = c.getFont(); }
  public Font getFont()  {    Element el = getElement();    AttributeSet atts = el.getAttributes();    String family = StyleConstants.getFontFamily(atts);    int size = StyleConstants.getFontSize(atts);    int style = Font.PLAIN;    if (StyleConstants.isBold(atts))        style |= Font.BOLD;    if (StyleConstants.isItalic(atts))      style |= Font.ITALIC;    Font font = new Font(family, style, size);    return font;  }