Package org.apache.fop.fonts
Class SimpleSingleByteEncoding
java.lang.Object
org.apache.fop.fonts.SimpleSingleByteEncoding
- All Implemented Interfaces:
SingleByteEncoding
A simple implementation of the OneByteEncoding mostly used for encodings that are constructed
on-the-fly.
-
Field Summary
Fields inherited from interface org.apache.fop.fonts.SingleByteEncoding
NOT_FOUND_CODE_POINT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionchar
Adds a new character to the encoding.getCharacterForIndex
(int codePoint) Returns the named character at a given code point in the encoding.String[]
Returns the array of character names for this encoding.int
Returns the index of the first defined character.int
Returns the index of the last defined character.getName()
Returns the encoding's name.int
getSize()
Returns the number of characters defined by this encoding.char[]
Returns a character array with Unicode scalar values which can be used to map encoding code points to Unicode values.boolean
isFull()
Indicates whether the encoding is full (with 256 code points).char
mapChar
(char c) Maps a Unicode character to a code point in the encoding.toString()
-
Constructor Details
-
SimpleSingleByteEncoding
Main constructor.- Parameters:
name
- the encoding's name
-
-
Method Details
-
getName
Returns the encoding's name.- Specified by:
getName
in interfaceSingleByteEncoding
- Returns:
- the name of the encoding
-
mapChar
public char mapChar(char c) Maps a Unicode character to a code point in the encoding.- Specified by:
mapChar
in interfaceSingleByteEncoding
- Parameters:
c
- the Unicode character to map- Returns:
- the code point in the encoding or 0 (=.notdef) if not found
-
getCharNameMap
Returns the array of character names for this encoding.- Specified by:
getCharNameMap
in interfaceSingleByteEncoding
- Returns:
- the array of character names (unmapped code points are represented by a ".notdef" value)
-
getFirstChar
public int getFirstChar()Returns the index of the first defined character.- Returns:
- the index of the first defined character (always 1 for this class)
-
getLastChar
public int getLastChar()Returns the index of the last defined character.- Returns:
- the index of the last defined character
-
getSize
public int getSize()Returns the number of characters defined by this encoding.- Returns:
- the number of characters
-
isFull
public boolean isFull()Indicates whether the encoding is full (with 256 code points).- Returns:
- true if the encoding is full
-
addCharacter
Adds a new character to the encoding.- Parameters:
ch
- the named character- Returns:
- the code point assigned to the character
-
getCharacterForIndex
Returns the named character at a given code point in the encoding.- Parameters:
codePoint
- the code point of the character- Returns:
- the NamedCharacter (or null if no character is at this position)
-
getUnicodeCharMap
public char[] getUnicodeCharMap()Returns a character array with Unicode scalar values which can be used to map encoding code points to Unicode values. Note that this does not return all possible Unicode values that the encoding maps.- Specified by:
getUnicodeCharMap
in interfaceSingleByteEncoding
- Returns:
- a character array with Unicode scalar values
-
toString
-