gzz.util
Class ScalableFont

java.lang.Object
  |
  +--gzz.util.ScalableFont

public final class ScalableFont
extends java.lang.Object

A font object from which it is easy to obtain instances and metrics scaled to requested multiplications. This exists because our target, the Java API 1.1.8 does not contain scaling functionality.

Scale is used in units of one thousand, i.e. 1000 = "normal" size.


Field Summary
static boolean dbg
           
static boolean dontCache
          If set, font metrics will not be cached.
static java.awt.Component fmComp
          Used to get FontMetrics for a Font.
static java.lang.String rcsid
           
 
Constructor Summary
ScalableFont(java.lang.String family, int style, int pointsize)
          Constructor similar to Java's Font(f,s,p).
 
Method Summary
 java.awt.Font getFont(float scale)
          Get a scaled instance of the font.
 java.awt.FontMetrics getFontMetrics(float scale)
          Get font metrics for a scaled instance of the font.
 float getScale(float height)
          Gets the scale for the point size which is nearest the given height.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rcsid

public static final java.lang.String rcsid
See Also:
Constant Field Values

dbg

public static boolean dbg

dontCache

public static boolean dontCache
If set, font metrics will not be cached.


fmComp

public static java.awt.Component fmComp
Used to get FontMetrics for a Font. Should be set in e.g. main().

Constructor Detail

ScalableFont

public ScalableFont(java.lang.String family,
                    int style,
                    int pointsize)
Constructor similar to Java's Font(f,s,p).

Parameters:
pointsize - Point size when scaling factor is 1.
Method Detail

getFont

public java.awt.Font getFont(float scale)
Get a scaled instance of the font.

Parameters:
scale - Scaling factor is (scale/1000).
Returns:
May not return null.

getFontMetrics

public java.awt.FontMetrics getFontMetrics(float scale)
Get font metrics for a scaled instance of the font.

Parameters:
scale - Scaling factor is (scale/1000).
Returns:
May not return null.

getScale

public float getScale(float height)
Gets the scale for the point size which is nearest the given height.