phelps.awt.font

Class Encoding

public class Encoding extends Object

An encoding maps between character codes (numbers) and character names (strings).

Version: $Revision: 1.8 $ $Date: 2003/12/19 12:50:57 $

Field Summary
static EncodingADOBE_STANDARD
static EncodingIDENTITY
static EncodingMAC_EXPERT
static EncodingMAC_ROMAN
static EncodingPDF_DOC
static EncodingSYMBOL
static EncodingUNICODE
static EncodingWIN_ANSI
static EncodingZAPF_DINGBATS
Constructor Summary
Encoding(String name, String[] map)
Creates Encoding out of array of character names such that cnames[ch] = cname.
Encoding(Encoding en, Object[] diff)
Method Summary
booleanequals(Object o)
chargetChar(String name)
Returns character associated with name.
static EncodinggetInstance(String name)
Returns a predefined encoding by name, or null if no encoding by that name.
StringgetName()
Returns name of encoding.
StringgetName(char ch)
Returns character name in encoding.
CMapguessToUnicode()
Estimates the Unicode mapping based on matching glyph names with standard Unicode names.
booleanhasUnicode()
Returns true iff encoding has full Unicode mappings, and so is invertible from this encoding to Unicode and back.
CMapmapTo(Encoding to)
Returns CMap that maps characters to another encoding's.
StringtoString()

Field Detail

ADOBE_STANDARD

public static final Encoding ADOBE_STANDARD

IDENTITY

public static final Encoding IDENTITY

MAC_EXPERT

public static final Encoding MAC_EXPERT

MAC_ROMAN

public static final Encoding MAC_ROMAN

PDF_DOC

public static final Encoding PDF_DOC

SYMBOL

public static final Encoding SYMBOL

UNICODE

public static final Encoding UNICODE

WIN_ANSI

public static final Encoding WIN_ANSI

ZAPF_DINGBATS

public static final Encoding ZAPF_DINGBATS

Constructor Detail

Encoding

public Encoding(String name, String[] map)
Creates Encoding out of array of character names such that cnames[ch] = cname.

Encoding

public Encoding(Encoding en, Object[] diff)

Method Detail

equals

public boolean equals(Object o)

getChar

public char getChar(String name)
Returns character associated with name.

getInstance

public static Encoding getInstance(String name)
Returns a predefined encoding by name, or null if no encoding by that name. Valid names are: Identity, MacRomanEncoding, MacExpertEncoding, WinAnsiEncoding, PDFDocEncoding, ZapfDingbatsEncoding, SymbolEncoding.

getName

public String getName()
Returns name of encoding.

getName

public String getName(char ch)
Returns character name in encoding. For example, for many encodings getName((char)65).equals("A").

guessToUnicode

public CMap guessToUnicode()
Estimates the Unicode mapping based on matching glyph names with standard Unicode names. The computation is an estimate because an encoding/font may use a Unicode name for a non-Unicode character and because an encoding/font may use character names that do not have Unicode equivalents. If there is no Unicode name for a character in the string, then that character maps to NFont#NOTDEF_CHAR. Java2D's string drawing interprets strings as Unicode.

See Also: "Unicode and Glyph Names"

hasUnicode

public boolean hasUnicode()
Returns true iff encoding has full Unicode mappings, and so is invertible from this encoding to Unicode and back.

mapTo

public CMap mapTo(Encoding to)
Returns CMap that maps characters to another encoding's.

toString

public String toString()