public class GlyphSequence extends Object implements Cloneable
A GlyphSequence encapsulates a sequence of character codes, a sequence of glyph codes, and a sequence of character associations, where, for each glyph in the sequence of glyph codes, there is a corresponding character association. Character associations server to relate the glyph codes in a glyph sequence to the specific characters in an original character code sequence with which the glyph codes are associated.
This work was originally authored by Glenn Adams (gadams@apache.org).
Modifier and Type | Field and Description |
---|---|
protected GlyphSequence |
unprocessedGS |
Constructor and Description |
---|
GlyphSequence(GlyphSequence gs)
Instantiate a glyph sequence using an existing glyph sequence, where the new glyph sequence shares
the character array of the existing sequence (but not the buffer object), and creates new copies
of glyphs buffer and association list.
|
GlyphSequence(GlyphSequence gs,
int[] bga,
int[] iga,
int[] lga,
CharAssociation[] bal,
CharAssociation[] ial,
CharAssociation[] lal)
Instantiate a glyph sequence using an existing glyph sequence, where the new glyph sequence shares
the character array of the existing sequence (but not the buffer object), but uses the specified
backtrack, input, and lookahead glyph arrays to populate the glyphs, and uses the specified
of glyphs buffer and association list.
|
GlyphSequence(IntBuffer characters,
IntBuffer glyphs,
List associations)
Instantiate a glyph sequence, reusing (i.e., not copying) the referenced
character and glyph buffers and associations.
|
GlyphSequence(IntBuffer characters,
IntBuffer glyphs,
List associations,
boolean predications)
Instantiate a glyph sequence, reusing (i.e., not copying) the referenced
character and glyph buffers and associations.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
int |
compareGlyphs(IntBuffer gb)
Compare glyphs.
|
static List |
concatAssociations(CharAssociation[] baa,
CharAssociation[] iaa,
CharAssociation[] laa)
Concatenante association arrays.
|
static IntBuffer |
concatGlyphs(int[] bga,
int[] iga,
int[] lga)
Concatenante glyph arrays.
|
CharAssociation |
getAssociation(int index)
Obtain association at specified index.
|
List |
getAssociations()
Obtain reference to underlying associations list.
|
CharAssociation[] |
getAssociations(int offset,
int count)
Obtain count associations starting at offset.
|
int[] |
getCharacterArray(boolean copy)
Obtain array of characters.
|
int |
getCharacterCount()
Obtain the number of characters in character array, where
each character constitutes a unicode scalar value.
|
IntBuffer |
getCharacters()
Obtain reference to underlying character buffer.
|
int |
getGlyph(int index)
Obtain glyph id at specified index.
|
int[] |
getGlyphArray(boolean copy)
Obtain array of glyphs.
|
int |
getGlyphCount()
Obtain the number of glyphs in glyphs array, where
each glyph constitutes a font specific glyph index.
|
IntBuffer |
getGlyphs()
Obtain reference to underlying glyph buffer.
|
int[] |
getGlyphs(int offset,
int count)
Obtain count glyphs starting at offset.
|
Object |
getPredication(int offset,
String key)
Get predication KEY at glyph sequence OFFSET.
|
boolean |
getPredications()
Obtain predications state.
|
int |
getUnprocessedGlyph(int index) |
int |
getUTF16CharacterCount()
Obtain the number of characters in character array, where
each character constitutes a UTF-16 character.
|
static GlyphSequence |
join(GlyphSequence gs,
GlyphSequence[] sa)
Join (concatenate) glyph sequences.
|
static GlyphSequence |
reorder(GlyphSequence gs,
int source,
int count,
int target)
Reorder sequence such that [SOURCE,SOURCE+COUNT) is moved just prior to TARGET.
|
static boolean |
sameGlyphs(int[] ga1,
int[] ga2)
Determine if two arrays of glyphs are identical.
|
void |
setGlyph(int index,
int gi)
Set glyph id at specified index.
|
void |
setPredication(int offset,
String key,
Object value)
Set predication <KEY,VALUE> at glyph sequence OFFSET.
|
void |
setPredications(boolean enable)
Enable or disable predications.
|
void |
setUnprocessedGS(GlyphSequence glyphSequence) |
String |
toString() |
protected GlyphSequence unprocessedGS
public GlyphSequence(IntBuffer characters, IntBuffer glyphs, List associations, boolean predications)
characters
- a (possibly null) buffer of associated (originating) charactersglyphs
- a (possibly null) buffer of glyphsassociations
- a (possibly null) array of glyph to character associationspredications
- true if predications are enabledpublic GlyphSequence(IntBuffer characters, IntBuffer glyphs, List associations)
characters
- a (possibly null) buffer of associated (originating) charactersglyphs
- a (possibly null) buffer of glyphsassociations
- a (possibly null) array of glyph to character associationspublic GlyphSequence(GlyphSequence gs)
gs
- an existing glyph sequencepublic GlyphSequence(GlyphSequence gs, int[] bga, int[] iga, int[] lga, CharAssociation[] bal, CharAssociation[] ial, CharAssociation[] lal)
gs
- an existing glyph sequencebga
- backtrack glyph arrayiga
- input glyph arraylga
- lookahead glyph arraybal
- backtrack association listial
- input association listlal
- lookahead association listpublic IntBuffer getCharacters()
public int[] getCharacterArray(boolean copy)
copy
is true, then
a newly instantiated array is returned, otherwise a reference to
the underlying buffer's array is returned. N.B. in case a reference
to the undelying buffer's array is returned, the length
of the array is not necessarily the number of characters in array.
To determine the number of characters, use getCharacterCount()
.copy
- true if to return a newly instantiated array of characterspublic int getCharacterCount()
public int getUTF16CharacterCount()
public int getGlyph(int index) throws IndexOutOfBoundsException
index
- to obtain glyphIndexOutOfBoundsException
- if index is less than zero
or exceeds last valid positionpublic int getUnprocessedGlyph(int index) throws IndexOutOfBoundsException
IndexOutOfBoundsException
public void setUnprocessedGS(GlyphSequence glyphSequence)
public void setGlyph(int index, int gi) throws IndexOutOfBoundsException
index
- to set glyphgi
- glyph indexIndexOutOfBoundsException
- if index is greater or equal to
the limit of the underlying glyph bufferpublic IntBuffer getGlyphs()
public int[] getGlyphs(int offset, int count)
count
is
negative, then it is treated as if the number of available glyphs
were specified.offset
- into glyph sequencecount
- of glyphs to obtain starting at offset, or negative,
indicating all avaialble glyphs starting at offsetpublic int[] getGlyphArray(boolean copy)
copy
is true, then
a newly instantiated array is returned, otherwise a reference to
the underlying buffer's array is returned. N.B. in case a reference
to the undelying buffer's array is returned, the length
of the array is not necessarily the number of glyphs in array.
To determine the number of glyphs, use getGlyphCount()
.copy
- true if to return a newly instantiated array of glyphspublic int getGlyphCount()
public CharAssociation getAssociation(int index) throws IndexOutOfBoundsException
index
- into associations arrayIndexOutOfBoundsException
- if index is less than zero
or exceeds last valid positionpublic List getAssociations()
public CharAssociation[] getAssociations(int offset, int count)
offset
- into glyph sequencecount
- of associations to obtain starting at offset, or negative,
indicating all avaialble associations starting at offsetpublic void setPredications(boolean enable)
enable
- true if predications are to be enabled; otherwise false to disablepublic boolean getPredications()
public void setPredication(int offset, String key, Object value)
offset
- offset (index) into glyph sequencekey
- predication keyvalue
- predication valuepublic Object getPredication(int offset, String key)
offset
- offset (index) into glyph sequencekey
- predication keypublic int compareGlyphs(IntBuffer gb)
gb
- buffer containing glyph indices with which this glyph sequence's glyphs are to be comparedpublic static boolean sameGlyphs(int[] ga1, int[] ga2)
ga1
- first glyph arrayga2
- second glyph arraypublic static IntBuffer concatGlyphs(int[] bga, int[] iga, int[] lga)
bga
- backtrack glyph arrayiga
- input glyph arraylga
- lookahead glyph arraypublic static List concatAssociations(CharAssociation[] baa, CharAssociation[] iaa, CharAssociation[] laa)
baa
- backtrack association arrayiaa
- input association arraylaa
- lookahead association arraypublic static GlyphSequence join(GlyphSequence gs, GlyphSequence[] sa)
gs
- original glyph sequence from which to reuse character array referencesa
- array of glyph sequences, whose glyph arrays and association lists are to be concatenatedpublic static GlyphSequence reorder(GlyphSequence gs, int source, int count, int target)
gs
- input sequencesource
- index of sub-sequence to reordercount
- length of sub-sequence to reordertarget
- index to which source sub-sequence is to be movedCopyright © 2025 Apache Software Foundation. All rights reserved.