phelps.awt

Class NFont

public abstract class NFont extends Object

Superclass for new fonts.

Unicode vs font encoding. Sometimes font has characters that do not have Unicode mappings. xxxString vs xxxEstring

Version: $Revision: 1.20 $ $Date: 2004/01/30 15:02:45 $

Field Summary
protected AffineTransformat_
static FileFilterFILTER
java.io.FileFilter that matches font files of supported formats (Type 1 PFA and PFB, TrueType, OpenType, OS X .dfont, TrueType Collection).
static intFLAG_ALLCAP
static intFLAG_CONDENSED
Condensed (narrow) (non-Adobe).
static intFLAG_DEFAULT
static intFLAG_FIXEDPITCH
static intFLAG_FORCEBOLD
Force boldface even at small point sizes.
static intFLAG_ITALIC
static intFLAG_NONE
static intFLAG_NONSYMBOLIC
Standard Latin character set.
static intFLAG_SCRIPT
static intFLAG_SERIF
static intFLAG_SMALLCAP
static intFLAG_SYMBOLIC
Not exactly standard Latin; though could be close.
static intMODE_ADD
static intMODE_FILL
static intMODE_FILL_ADD
static intMODE_FILL_STROKE
static intMODE_FILL_STROKE_ADD
static intMODE_INVISIBLE
static intMODE_STROKE
static intMODE_STROKE_ADD
static StringNOTDEF
static charNOTDEF_CHAR
static charNOTVALID_CHAR
protected floatsize_
static StringSUBFORMAT_NONE
protected CMaptouni_
static intWEIGHT_BLACK
Black (Heavy)
static intWEIGHT_BOLD
Bold
static intWEIGHT_EXTRABOLD
Extra-Bold (Ultra-bold)
static intWEIGHT_EXTRALIGHT
Extra-light (Ultra-light)
static intWEIGHT_LIGHT
Light
static intWEIGHT_MEDIUM
Medium
static intWEIGHT_NORMAL
Normal (Regular)
static intWEIGHT_SEMIBOLD
Semi-bold (Demi-bold)
static intWEIGHT_THIN
Thin
static doubleWIDTHS_SCALEX
Method Summary
booleancanDisplay(char uni)
Can the Unicode character uni be rendered?
abstract booleancanDisplayEchar(char ech)
Can the character ch in the font's encoding be rendered?
Point2DcharAdvance(char ch)
abstract NFontderiveFont(float pointsize)
Creates font a new pointsize, assuming 72 ppi.
NFontderiveFont(AffineTransform at)
Transform all glyphs by arbitrary affine transform.
abstract voiddrawEstring(Graphics2D g, String estr, float x, float y, int mode)
Draw string str in font's encoding at (x,y) in drawing mode mode.
voiddrawString(Graphics2D g, String uni, float x, float y)
Convenience method for drawing string in fill mode.
voiddrawString(Graphics2D g, String uni, float x, float y, int mode)
Translate Unicode string str to this font's encoding and invoke NFont.
abstract Point2DecharAdvance(char ech)
Point2DestringAdvance(String estr, int beginIndex, int limit)
StringfromUnicode(String unicode)
Translates Unicode characters into current encoding.
StringgetCopyright()
StringgetDesigner()
Rectangle2DgetEstringBounds(String estr, int beginIndex, int limit)
abstract StringgetFamily()
intgetFlags()
static NFontManagergetFontManager()
Returns standard system font manager.
abstract StringgetFormat()
static NFontgetInstance(String family, int weight, int flags, float size)
Given family and flags, returns best matching font, at point size size.
abstract Rectangle2DgetMaxCharBounds()
left, ascent, width, height.
intgetMaxGlyphNum()
Returns highest glyph index + 1, which may be larger than getNumGlyphs.
abstract StringgetName()
abstract intgetNumGlyphs()
floatgetSize()
abstract chargetSpaceChar()
Returns the character that seems to be used as a space in the current encoding, or NOTDEF_CHAR if no such character.
Rectangle2DgetStringBounds(String str)
Logical origin, ascent, advance, and height (includes leading).
Rectangle2DgetStringBounds(String str, int beginIndex, int limit)
StringgetSubformat()
AffineTransformgetTransform()
Returns a copy of the transform associated with this NFont.
intgetWeight()
booleanisTransformed()
static StringstrFlags(int flags)
Decode flag bit positions into slightly more readable string.
Point2DstringAdvance(String str)
Point2DstringAdvance(String str, int beginIndex, int limit)
StringtoString()
StringtoUnicode(String encoded)
Translates characters in current encoding into Unicode.

Field Detail

at_

protected AffineTransform at_

FILTER

public static final FileFilter FILTER
java.io.FileFilter that matches font files of supported formats (Type 1 PFA and PFB, TrueType, OpenType, OS X .dfont, TrueType Collection).

FLAG_ALLCAP

public static final int FLAG_ALLCAP

FLAG_CONDENSED

public static final int FLAG_CONDENSED
Condensed (narrow) (non-Adobe).

FLAG_DEFAULT

public static final int FLAG_DEFAULT

FLAG_FIXEDPITCH

public static final int FLAG_FIXEDPITCH

FLAG_FORCEBOLD

public static final int FLAG_FORCEBOLD
Force boldface even at small point sizes.

FLAG_ITALIC

public static final int FLAG_ITALIC

FLAG_NONE

public static final int FLAG_NONE

FLAG_NONSYMBOLIC

public static final int FLAG_NONSYMBOLIC
Standard Latin character set.

FLAG_SCRIPT

public static final int FLAG_SCRIPT

FLAG_SERIF

public static final int FLAG_SERIF

FLAG_SMALLCAP

public static final int FLAG_SMALLCAP

FLAG_SYMBOLIC

public static final int FLAG_SYMBOLIC
Not exactly standard Latin; though could be close. This follows the Adobe definition and does NOT mean dingbat glyphs as in Symbol or Zapf Dingbats. And it's redundant with NFont.

MODE_ADD

public static final int MODE_ADD

MODE_FILL

public static final int MODE_FILL

MODE_FILL_ADD

public static final int MODE_FILL_ADD

MODE_FILL_STROKE

public static final int MODE_FILL_STROKE

MODE_FILL_STROKE_ADD

public static final int MODE_FILL_STROKE_ADD

MODE_INVISIBLE

public static final int MODE_INVISIBLE

MODE_STROKE

public static final int MODE_STROKE

MODE_STROKE_ADD

public static final int MODE_STROKE_ADD

NOTDEF

public static final String NOTDEF

NOTDEF_CHAR

public static final char NOTDEF_CHAR

NOTVALID_CHAR

public static final char NOTVALID_CHAR

size_

protected float size_

SUBFORMAT_NONE

public static final String SUBFORMAT_NONE

touni_

protected CMap touni_

WEIGHT_BLACK

public static final int WEIGHT_BLACK
Black (Heavy)

WEIGHT_BOLD

public static final int WEIGHT_BOLD
Bold

WEIGHT_EXTRABOLD

public static final int WEIGHT_EXTRABOLD
Extra-Bold (Ultra-bold)

WEIGHT_EXTRALIGHT

public static final int WEIGHT_EXTRALIGHT
Extra-light (Ultra-light)

WEIGHT_LIGHT

public static final int WEIGHT_LIGHT
Light

WEIGHT_MEDIUM

public static final int WEIGHT_MEDIUM
Medium

WEIGHT_NORMAL

public static final int WEIGHT_NORMAL
Normal (Regular)

WEIGHT_SEMIBOLD

public static final int WEIGHT_SEMIBOLD
Semi-bold (Demi-bold)

WEIGHT_THIN

public static final int WEIGHT_THIN
Thin

WIDTHS_SCALEX

public static final double WIDTHS_SCALEX

Method Detail

canDisplay

public boolean canDisplay(char uni)
Can the Unicode character uni be rendered?

canDisplayEchar

public abstract boolean canDisplayEchar(char ech)
Can the character ch in the font's encoding be rendered?

charAdvance

public Point2D charAdvance(char ch)

deriveFont

public abstract NFont deriveFont(float pointsize)
Creates font a new pointsize, assuming 72 ppi. Note to subclassers: you must make a complete independent instance of the font here, even if pointsize and everything else is the same, as other deriveFont methods use this to make a clone and might make subsequent changes.

deriveFont

public NFont deriveFont(AffineTransform at)
Transform all glyphs by arbitrary affine transform. Note that this sets the absolute transform -- as in java.awt.Font transforms do not concatenate together.

drawEstring

public abstract void drawEstring(Graphics2D g, String estr, float x, float y, int mode)
Draw string str in font's encoding at (x,y) in drawing mode mode. For good results, set the java.awt.RenderingHints#KEY_ANTIALIASING hint on the Graphics2D.

drawString

public void drawString(Graphics2D g, String uni, float x, float y)
Convenience method for drawing string in fill mode.

drawString

public void drawString(Graphics2D g, String uni, float x, float y, int mode)
Translate Unicode string str to this font's encoding and invoke NFont. Note that some fonts contain chars with idiosyncratic names that are not Unicode and therefore cannot be shown with this method, only with NFont.

If some characters are not appearing, it may be that those characters do not have Unicode mappings. In that case, try NFont.

echarAdvance

public abstract Point2D echarAdvance(char ech)

estringAdvance

public Point2D estringAdvance(String estr, int beginIndex, int limit)

fromUnicode

public String fromUnicode(String unicode)
Translates Unicode characters into current encoding. If there is no Unicode mapping for the character, the character NOTDEF_CHAR is returned.

getCopyright

public String getCopyright()

getDesigner

public String getDesigner()

getEstringBounds

public Rectangle2D getEstringBounds(String estr, int beginIndex, int limit)

getFamily

public abstract String getFamily()

getFlags

public int getFlags()

getFontManager

public static NFontManager getFontManager()
Returns standard system font manager. This font manager is intialized with the fonts from the OS and ${java.home}/lib/fonts, holes in the Adobe core 35 set filled in with the URW equivalent (if available), and requests for missing Macintosh font families mapped to Windows equivalents and vice-versa..

getFormat

public abstract String getFormat()

getInstance

public static NFont getInstance(String family, int weight, int flags, float size)
Given family and flags, returns best matching font, at point size size.

getMaxCharBounds

public abstract Rectangle2D getMaxCharBounds()
left, ascent, width, height.

getMaxGlyphNum

public int getMaxGlyphNum()
Returns highest glyph index + 1, which may be larger than getNumGlyphs.

getName

public abstract String getName()

getNumGlyphs

public abstract int getNumGlyphs()

getSize

public float getSize()

getSpaceChar

public abstract char getSpaceChar()
Returns the character that seems to be used as a space in the current encoding, or NOTDEF_CHAR if no such character.

getStringBounds

public Rectangle2D getStringBounds(String str)
Logical origin, ascent, advance, and height (includes leading).

getStringBounds

public Rectangle2D getStringBounds(String str, int beginIndex, int limit)

getSubformat

public String getSubformat()

getTransform

public AffineTransform getTransform()
Returns a copy of the transform associated with this NFont.

getWeight

public int getWeight()

isTransformed

public boolean isTransformed()

strFlags

public static String strFlags(int flags)
Decode flag bit positions into slightly more readable string.

stringAdvance

public Point2D stringAdvance(String str)

stringAdvance

public Point2D stringAdvance(String str, int beginIndex, int limit)

toString

public String toString()

toUnicode

public String toUnicode(String encoded)
Translates characters in current encoding into Unicode.