lapisx.swing
Class FontUtil

java.lang.Object
  extended bylapisx.swing.FontUtil

public abstract class FontUtil
extends Object


Constructor Summary
FontUtil()
           
 
Method Summary
static int getHeight(Font f, Component c)
          Get height of a font.
static MetalTheme makeResizedMetalTheme(int size)
          Makes a Metal theme with resized fonts.
static void resizeFont(Component c, int size)
          Sets the size of a component's font.
static Font resizeFont(Font f, int size)
          Enlarges or shrinks a font.
static void resizeHTMLFont(JEditorPane c, int size)
          Sets the size of a JEditorPane's HTML fonts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FontUtil

public FontUtil()
Method Detail

getHeight

public static int getHeight(Font f,
                            Component c)
Get height of a font.

Parameters:
f - Font
c - Component that will display the font. Must be showing on the screen, otherwise we can't get its Graphics context.
Returns:
height of font (leading + ascent + descent)
Throws:
IllegalArgumentException - if c is not showing on the screen.

resizeFont

public static void resizeFont(Component c,
                              int size)
Sets the size of a component's font.

Parameters:
c - Component to change
size - font size in points
Effects:
calls c.setFont() to change c's font to a font with the same font family and style, but the given font size.

resizeFont

public static Font resizeFont(Font f,
                              int size)
Enlarges or shrinks a font.

Parameters:
f - Font to use
size - new font size in points
Returns:
font with same family and style as f, but the given size

resizeHTMLFont

public static void resizeHTMLFont(JEditorPane c,
                                  int size)
Sets the size of a JEditorPane's HTML fonts.

Parameters:
c - JEditorPane to change
size - font size in points
Effects:
sets the size of body and paragraph fonts in c's HTML stylesheet

makeResizedMetalTheme

public static MetalTheme makeResizedMetalTheme(int size)
Makes a Metal theme with resized fonts.

Parameters:
size - font size in points
Returns:
MetalTheme that uses the given font size for all fonts. Use MetalLookAndFeel.setCurrentTheme(javax.swing.plaf.metal.MetalTheme) to install it.