phelps.awt

Class Fonts

public class Fonts extends Object

Font-related utilities.

Version: $Revision$ $Date$

Field Summary
static String[]FAMILIES
Shared, one-time result of java.awt.GraphicsEnvironment#getAvailableFontFamilyNames().
static intFLAG_ALLCAP
Font flags in font dictionary.
static intFLAG_DEFAULT
Font flags in font dictionary.
static intFLAG_FIXEDPITCH
Font flags in font dictionary.
static intFLAG_FORCEBOLD
Font flags in font dictionary.
static intFLAG_ITALIC
Font flags in font dictionary.
static intFLAG_NOFLAG
Font flags in font dictionary.
static intFLAG_NONSYMBOLIC
Font flags in font dictionary.
static intFLAG_SCRIPT
Font flags in font dictionary.
static intFLAG_SERIF
Font flags in font dictionary.
static intFLAG_SMALLCAP
Font flags in font dictionary.
static intFLAG_SYMBOLIC
Font flags in font dictionary.
static String[]NORMALFAMILIES
FAMILIES, normalized to lowercase and no spaces.
Method Summary
static FontcreateFont(String family, String altfamily, float size, int flags)
A more flexible version of Font#Font(String, int, int) that tries harder to find a good substitute.
static StringgetNormalFamily(String family)
Given a family name, return closest existing name.

Field Detail

FAMILIES

public static final String[] FAMILIES
Shared, one-time result of java.awt.GraphicsEnvironment#getAvailableFontFamilyNames().

FLAG_ALLCAP

public static final int FLAG_ALLCAP
Font flags in font dictionary.

FLAG_DEFAULT

public static final int FLAG_DEFAULT
Font flags in font dictionary.

FLAG_FIXEDPITCH

public static final int FLAG_FIXEDPITCH
Font flags in font dictionary.

FLAG_FORCEBOLD

public static final int FLAG_FORCEBOLD
Font flags in font dictionary.

FLAG_ITALIC

public static final int FLAG_ITALIC
Font flags in font dictionary.

FLAG_NOFLAG

public static final int FLAG_NOFLAG
Font flags in font dictionary.

FLAG_NONSYMBOLIC

public static final int FLAG_NONSYMBOLIC
Font flags in font dictionary.

FLAG_SCRIPT

public static final int FLAG_SCRIPT
Font flags in font dictionary.

FLAG_SERIF

public static final int FLAG_SERIF
Font flags in font dictionary.

FLAG_SMALLCAP

public static final int FLAG_SMALLCAP
Font flags in font dictionary.

FLAG_SYMBOLIC

public static final int FLAG_SYMBOLIC
Font flags in font dictionary.

NORMALFAMILIES

public static final String[] NORMALFAMILIES
FAMILIES, normalized to lowercase and no spaces.

Method Detail

createFont

public static Font createFont(String family, String altfamily, float size, int flags)
A more flexible version of Font#Font(String, int, int) that tries harder to find a good substitute. It tries parsing a PostScript font name (like "Times-Bold"), and searching for TeX fonts.

Sequence to choose font:

  1. exact font family name as given
  2. try URW/Ghostscript version
  3. family mapped to core PDF 14 family
  4. name mangling such as stripping caps (e.g., "ArialMT" ⇒ "Arial")
  5. (when Java supports dynamic loading of Type 1, search kpathsea for TeX font)a
  6. based on flags, pick a good substition from core 14

Returns: Font (never null) that best matches desired attributes.

getNormalFamily

public static String getNormalFamily(String family)
Given a family name, return closest existing name. Tries converting to lowercase and stripping spaces. Should probably put this in phelps.Utility