|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.foray.ps.encode.EncodingVector4a
public abstract class EncodingVector4a
Encoding instances provide some standard encoding resources for PostScript. When a PostScript file is parsed, the characters in a string are really indices into an array of glyph names, which are in turn the keys to entries in a glyph dictionary. Input to a PostScript interpreter is not really characters, but rather character indexes. (The two might be the same, especially for ASCII characters).
So the PostScript interpreter uses a two-step process, as follows: 1. It conceptually maps character codes (integer values) to name objects like /A or /Uacute. This map is known as an "encoding". There are several standard encoding schemes defined in the PostScript standard that each interpreter must know how to handle. Those are provided as Encoding subclasses. 2. The name objects created in step 1 are then used as the key into a dictionary (contained in the Font dictionary) whose values contain the PostScript instructions needed to actually paint the glyph.
Nowhere in the above scheme is Unicode encoding contemplated or supported. Applications that create PostScript output from Unicode input need a way to convert from that Unicode input to the indexes that are expected for by the selected encoding. The closest resource that we have for this purpose is the standard glyph lists supplied by Adobe.
The canonical method for mapping a Unicode code point to a PostScript encoding index would be:
However, for efficiency, an Encoding combines the above two steps and provides a direct mapping from a Unicode code point to the encoded index. Two parallel arrays are used to make this process efficient. The first is a an array of all Unicode code points supported in the Encoding. This array is sorted for fast searching. The second array provides the encoded index for the Unicode code point in the first array. Methods are provided to encode and decode characters.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.axsl.ps.PsEncoding |
---|
org.axsl.ps.PsEncoding.Predefined |
Field Summary | |
---|---|
static String |
NOTDEF
The name of the undefined glyph. |
Fields inherited from interface org.axsl.ps.Encoding |
---|
INVALID_UNICODE_CHAR |
Constructor Summary | |
---|---|
EncodingVector4a(String name,
List<org.axsl.ps.GlyphList> sourceGlyphLists,
char[] codePoints,
char[] codePointIndexes)
Create a new Encoding instance. |
Method Summary | |
---|---|
String |
asPostScript(org.axsl.ps.Encoding baseEncoding)
|
org.axsl.ps.PsEncoding |
bestBaseEncodingPdf()
|
boolean |
canEncode(int codePoint)
|
int |
decodeCharacter(int encodedIndex)
|
int |
encodeCharacter(int codePoint)
|
int |
getFirstIndex()
|
String[] |
getGlyphNames()
|
int |
getLastIndex()
|
String |
getName()
|
boolean |
isPredefinedPdf()
|
boolean |
isPredefinedPs()
|
abstract boolean |
isStatic()
Indicates whether the data in this encoding vector is static, that is, tied entirely to the class itself and not built dynamically. |
boolean |
isSubsetOf(org.axsl.ps.PsEncoding otherVector)
|
String |
mapCodePointToGlyphName(int codePoint)
|
String |
mapCodePointToGlyphName(List<org.axsl.ps.GlyphList> glyphLists,
int codePoint)
Finds the glyph name for a given Unicode code point by searching an array of GlyphList instances for it. |
char |
mapGlyphNameToCodePoint(List<org.axsl.ps.GlyphList> glyphLists,
String glyphName)
Finds the Unicode code for a glyphName by searching an array of GlyphList instances for it. |
int |
size()
Returns the number of entries in this encoding. |
void |
sortCodePoints(char[] codePoints,
char[] codePointIndexes)
Sorts the codePoints array by its contents, and sorts the parallel codePointIndexes arrays in a parallel manner, keeping its elements synchronized with those in codePoints. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.axsl.ps.PsEncoding |
---|
getPredefinedType |
Field Detail |
---|
public static final String NOTDEF
Constructor Detail |
---|
public EncodingVector4a(String name, List<org.axsl.ps.GlyphList> sourceGlyphLists, char[] codePoints, char[] codePointIndexes)
name
- The name of this encoding.
This name is not used by the system, but may be useful for debugging.sourceGlyphLists
- The GlyphList instances that were used to create this encoding.codePoints
- The array of Unicode code points supported by this encoding.codePointIndexes
- The array of encoded indexes that is parallel to codePoints.
codePointIndexes[n] should contain the encoded index that corresponds to the Unicode code point at codePoints[n].Method Detail |
---|
public String getName()
getName
in interface org.axsl.ps.Encoding
public int encodeCharacter(int codePoint)
encodeCharacter
in interface org.axsl.ps.Encoding
public int decodeCharacter(int encodedIndex)
decodeCharacter
in interface org.axsl.ps.Encoding
public int size()
public String[] getGlyphNames()
getGlyphNames
in interface org.axsl.ps.PsEncoding
public int getFirstIndex()
getFirstIndex
in interface org.axsl.ps.Encoding
public int getLastIndex()
getLastIndex
in interface org.axsl.ps.Encoding
public void sortCodePoints(char[] codePoints, char[] codePointIndexes)
codePoints
- The array of Unicode code points to be sorted.codePointIndexes
- The array of encoding indexes that whose elements
correspond to elements in codePoints.public String asPostScript(org.axsl.ps.Encoding baseEncoding)
asPostScript
in interface org.axsl.ps.Encoding
public String mapCodePointToGlyphName(int codePoint)
mapCodePointToGlyphName
in interface org.axsl.ps.PsEncoding
public org.axsl.ps.PsEncoding bestBaseEncodingPdf()
bestBaseEncodingPdf
in interface org.axsl.ps.PsEncoding
public boolean isSubsetOf(org.axsl.ps.PsEncoding otherVector)
isSubsetOf
in interface org.axsl.ps.PsEncoding
public abstract boolean isStatic()
public boolean isPredefinedPs()
isPredefinedPs
in interface org.axsl.ps.Encoding
public boolean isPredefinedPdf()
isPredefinedPdf
in interface org.axsl.ps.Encoding
public boolean canEncode(int codePoint)
canEncode
in interface org.axsl.ps.Encoding
public String mapCodePointToGlyphName(List<org.axsl.ps.GlyphList> glyphLists, int codePoint)
glyphLists
- An array of GlyphList instances which should be
tried.codePoint
- The Unicode code point for which a glyph name is sought.
public char mapGlyphNameToCodePoint(List<org.axsl.ps.GlyphList> glyphLists, String glyphName)
glyphLists
- An array of GlyphList instances which should be
tried.glyphName
- The glyph name for which a Unicode code point is sought.
Encoding.INVALID_UNICODE_CHAR
if there is none.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |