phelps.awt

Class Fonts

public abstract class Fonts extends Object

Extensions to java.awt.Font.

Version: $Revision: 1.1 $ $Date: 2003/11/07 04:44:59 $

Method Summary
static FontcreateFont(String family, int flags, float size)
A more flexible version of Font#Font(String, int, int) that tries harder to find a good substitute by relying on Fonts.
static List<String>getAvailableFamilies()
static StringgetAvailableFamily(String family, int flags)
Given a family name, return closest font family available as java.awt.Font.
static StringgetCanonicalPDF(String family)
Given alternative (or canonical) name for core font, return canonical name.

Method Detail

createFont

public static Font createFont(String family, int flags, float size)
A more flexible version of Font#Font(String, int, int) that tries harder to find a good substitute by relying on Fonts.

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

getAvailableFamilies

public static List<String> getAvailableFamilies()

getAvailableFamily

public static String getAvailableFamily(String family, int flags)
Given a family name, return closest font family available as java.awt.Font.

Sequence to choose font:

  1. exact font family name as given
  2. URW/Ghostscript facsimile, if installed
  3. (when Java supports dynamic loading of Type 1, search for TeX font)
  4. name normalization such as removing spaces ("Times New Roman" ⇒ "TimesNewRoman")
  5. name without style information ("Times-Bold" or "Arial,BoldItalic"), Ghostscript facsimile
  6. family mapped to core PDF 14 family
  7. renaming by stripping trailing caps ("ArialMT" ⇒ "Arial") or foundary/company ("Apple Chancery" ⇒ "Chancery")
  8. family with similar properties to flags

Returns: null iff no close match to family and flags set to FLAG_DO_NOT_USE

getCanonicalPDF

public static String getCanonicalPDF(String family)
Given alternative (or canonical) name for core font, return canonical name. Returns null if not a canonical or alternative name.