public static void addFont(String fontKey,Font font){
  if (fontKey != null) {
    fontKey=fontKey.toLowerCase();
  }
 else {
    if (font.getCharset() != null) {
      throw new IllegalArgumentException("Font key must be non-null for bitmap fonts");
    }
  }
  fonts.put(fontKey,new HTMLFont(fontKey,font));
}

public static void addFont ( String fontKey , Font font ) { if ( fontKey != null ) { fontKey = fontKey . toLowerCase ( ) ; } else { if ( font . getCharset ( ) != null ) { throw new IllegalArgumentException ( "Font key must be non-null for bitmap fonts" ) ; } } fonts . put ( fontKey , new HTMLFont ( fontKey , font ) ) ; }
sets the given codename one font for use with htmlcomponents . the font key can contain information about the following attributes : * the font family - i . e . arial , times new roman etc . * the font size - in pixels ( i . e . 12 , 14 etc . ) * the font style - bold , italic or both ( no need to specify plain ) * the font tag assignments - if this font should be used for any html specific tags they should be specified - i . e . h1 , kbd etc . the key is just a concatenation of all attributes seperated with a dot . examples for valid keys : arial . 12 - describes a plain font from the arial family in size 12 arial . 16 . bold - a bold arial font in size 16 courier . italic . bold . 20 - a bold and italic courier font in size 20 arial . 20 . h1 - a plain arial font , size 20 , that should be used for contents of the h1 tag code . kbd . samp - a font that should be used for the code , kbd and samp tags note that the order of the attributes is not important and also that the case is ignored . this means that arial . 12 . bold . italic . h3 is equivalent to italic . h3 . arial . bold . 12 also note that while you do not have to provide all the info for the font , but the info helps the rendering engine to reuse fonts when suitable . for example , if you have a 16px arial bold font which you want to use for h2 , you can simply add it as " h2 " , but if you add it as " arial . 16 . bold . h2 " then if the current font is arial . 16 and the renderer encounters a b tag , it will know it can use the font you added as the bold counterpart of the current font . when adding system fonts there is no need to describe the font , the usage of setfont with system fonts is usually just to assign them for tags . the rendering engine knows to derive bold / italic / bigger / smaller fonts from other system fonts ( default or tag fonts ) even if not added .
