public class GlyphProcessingState
extends java.lang.Object
The GlyphProcessingState
implements a common, base state object used during glyph substitution
and positioning processing.
This work was originally authored by Glenn Adams (gadams@apache.org).
Modifier and Type | Field and Description |
---|---|
protected int |
classMatchSet
class match set
|
protected int |
consumed
consumed, updated after each successful subtable application
|
protected java.lang.String |
feature
governing feature
|
protected GlyphContextTester |
gct
glyph context tester or null
|
protected GlyphDefinitionTable |
gdef
governing glyph definition table
|
protected GlyphTester |
ignoreBase
ignore base glyph tester
|
protected GlyphTester |
ignoreDefault
default ignore glyph tester
|
protected GlyphTester |
ignoreLigature
ignore ligature glyph tester
|
protected GlyphTester |
ignoreMark
ignore mark glyph tester
|
protected GlyphSequence |
igs
current input glyph sequence
|
protected int |
index
current index in input sequence
|
protected int |
indexLast
last (maximum) index of input sequence (exclusive)
|
protected java.lang.String |
language
governing language
|
protected int |
lookupFlags
lookup flags
|
protected java.lang.String |
script
governing script
|
protected ScriptContextTester |
sct
script specific context tester or null
|
Modifier | Constructor and Description |
---|---|
|
GlyphProcessingState()
Construct default (reset) glyph processing state.
|
protected |
GlyphProcessingState(GlyphProcessingState s)
Construct glyph processing state using an existing state object using shallow copy
except as follows: input glyph sequence is copied deep except for its characters array.
|
protected |
GlyphProcessingState(GlyphSequence gs,
java.lang.String script,
java.lang.String language,
java.lang.String feature,
ScriptContextTester sct)
Construct glyph processing state.
|
Modifier and Type | Method and Description |
---|---|
void |
applyDefault()
Apply default application semantices; namely, consume one glyph.
|
int |
consume(int count)
Record the consumption of
count glyphs such that
this consumption never exceeds the number of glyphs in the input glyph
sequence. |
boolean |
didConsume()
Determine if any consumption has occurred.
|
int |
erase(int offset,
int[] glyphs)
Erase glyphs in input glyph sequence starting at specified offset from current position, where each glyph
in the specified
glyphs array is matched, one at a time, and when a (forward searching) match is found
in the input glyph sequence, the matching glyph is replaced with the glyph index 65535. |
CharAssociation |
getAssociation()
Obtain character association of glyph at current position.
|
CharAssociation |
getAssociation(int offset)
Obtain character association of glyph at specified offset from current position.
|
CharAssociation[] |
getAssociations(int offset,
int count)
Obtain
count character associations of glyphs starting at specified offset from current position. |
CharAssociation[] |
getAssociations(int offset,
int count,
boolean reverseOrder,
GlyphTester ignoreTester,
CharAssociation[] associations,
int[] counts)
Obtain
count character associations of glyphs starting at specified offset from current position. |
int |
getClassMatchSet(int gi)
Obtain governing class match set.
|
GlyphTester |
getCombinedAndTester(GlyphTester[] gta,
int ngt)
Obtain an combined AND glyph tester.
|
GlyphTester |
getCombinedIgnoreTester(int flags)
Obtain an ignored glyph tester that corresponds to the specified multiple (combined) lookup flags.
|
GlyphTester |
getCombinedOrTester(GlyphTester[] gta,
int ngt)
Obtain an combined OR glyph tester.
|
GlyphDefinitionTable |
getGDEF()
Obtain governing glyph definition table.
|
int |
getGlyph()
Obtain glyph at current position.
|
int |
getGlyph(int offset)
Obtain glyph at specified offset from current position.
|
int[] |
getGlyphs()
Obtain all glyphs starting from current position to end of input glyph sequence.
|
int[] |
getGlyphs(int offset,
int count,
boolean reverseOrder,
GlyphTester ignoreTester,
int[] glyphs,
int[] counts)
Obtain
count glyphs starting at specified offset from current position. |
int[] |
getGlyphs(int offset,
int count,
int[] glyphs,
int[] counts)
Obtain
count glyphs starting at specified offset from current position. |
int[] |
getGlyphsAvailable(int offset)
Determine number of glyphs available starting at specified offset from current position.
|
int[] |
getGlyphsAvailable(int offset,
boolean reverseOrder)
Determine number of glyphs available starting at specified offset from current position.
|
int[] |
getGlyphsAvailable(int offset,
boolean reverseOrder,
GlyphTester ignoreTester)
Determine number of glyphs available starting at specified offset from current position.
|
CharAssociation[] |
getIgnoredAssociations(int offset,
int count)
Obtain
count character associations of ignored glyphs starting at specified offset from current position. |
CharAssociation[] |
getIgnoredAssociations(int offset,
int count,
boolean reverseOrder,
GlyphTester ignoreTester,
CharAssociation[] associations,
int[] counts)
Obtain
count character associations of ignored glyphs starting at specified offset from current position. |
GlyphTester |
getIgnoreDefault()
Obtain governing default ignores tester.
|
int[] |
getIgnoredGlyphs(int offset,
int count)
Obtain
count ignored glyphs starting at specified offset from current position. |
int[] |
getIgnoredGlyphs(int offset,
int count,
boolean reverseOrder,
GlyphTester ignoreTester,
int[] glyphs,
int[] counts)
Obtain
count ignored glyphs starting at specified offset from current position. |
GlyphTester |
getIgnoreTester(int flags)
Obtain an ignored glyph tester that corresponds to the specified lookup flags.
|
GlyphSequence |
getInput()
Obtain reference to input glyph sequence, which must not be modified.
|
int |
getLastPosition()
Obtain last valid position index in input glyph sequence.
|
int |
getLookupFlags()
Obtain governing lookup flags.
|
int |
getPosition()
Obtain current position index in input glyph sequence.
|
boolean |
hasNext()
Determine if at least one glyph remains in
input sequence.
|
boolean |
hasNext(int count)
Determine if at least
count glyphs remain in
input sequence. |
boolean |
hasPrev()
Determine if at least one backtrack (previous) glyph is present
in input sequence.
|
boolean |
hasPrev(int count)
Determine if at least
count backtrack (previous) glyphs
are present in input sequence. |
boolean |
isBase(int gi)
Determine if specified glyph is a base glyph according to the governing
glyph definition table.
|
boolean |
isIgnoredBase(int gi,
int flags)
Determine if specified glyph is an ignored base glyph according to the governing
glyph definition table.
|
boolean |
isIgnoredGlyph()
Determine if glyph at current position is ignored.
|
boolean |
isIgnoredGlyph(int offset)
Determine if glyph at specified offset from current position is ignored.
|
boolean |
isIgnoredGlyph(int offset,
GlyphTester ignoreTester)
Determine if glyph at specified offset from current position is ignored.
|
boolean |
isIgnoredLigature(int gi,
int flags)
Determine if specified glyph is an ignored ligature glyph according to the governing
glyph definition table.
|
boolean |
isIgnoredMark(int gi,
int flags)
Determine if specified glyph is an ignored ligature glyph according to the governing
glyph definition table.
|
boolean |
isLigature(int gi)
Determine if specified glyph is an ligature glyph according to the governing
glyph definition table.
|
boolean |
isMark(int gi)
Determine if specified glyph is a mark glyph according to the governing
glyph definition table.
|
boolean |
maybeApplicable()
Determine if is possible that the current input sequence satisfies a script specific
context testing predicate.
|
int |
next()
Update the current position index based upon previously consumed
glyphs, i.e., add the consuemd count to the current position index.
|
int |
prev()
Update the current position index based upon previously consumed
glyphs, i.e., subtract the consuemd count from the current position index.
|
boolean |
replaceInput(int offset,
int count,
GlyphSequence gs)
Replace subsequence of input glyph sequence starting at specified offset from current position and of
length
count glyphs with all glyphs in the replacement sequence gs . |
boolean |
replaceInput(int offset,
int count,
GlyphSequence gs,
int gsOffset,
int gsCount)
Replace subsequence of input glyph sequence starting at specified offset from current position and of
length
count glyphs with a subsequence of the sequence gs starting from the specified
offset gsOffset of length gsCount glyphs. |
protected GlyphProcessingState |
reset(GlyphSequence gs,
java.lang.String script,
java.lang.String language,
java.lang.String feature,
ScriptContextTester sct)
Reset glyph processing state.
|
void |
setGDEF(GlyphDefinitionTable gdef)
Set governing glyph definition table.
|
void |
setGlyph(int offset,
int glyph)
Set (replace) glyph at specified offset from current position.
|
void |
setIgnoreDefault(GlyphTester ignoreDefault)
Set default ignore tester.
|
void |
setLookupFlags(int flags)
Set governing lookup flags
|
void |
setPosition(int index)
Set (seek to) position index in input glyph sequence.
|
void |
updateSubtableState(GlyphSubtable st)
Update glyph subtable specific state.
|
protected GlyphDefinitionTable gdef
protected java.lang.String script
protected java.lang.String language
protected java.lang.String feature
protected GlyphSequence igs
protected int index
protected int indexLast
protected int consumed
protected int lookupFlags
protected int classMatchSet
protected ScriptContextTester sct
protected GlyphContextTester gct
protected GlyphTester ignoreBase
protected GlyphTester ignoreLigature
protected GlyphTester ignoreMark
protected GlyphTester ignoreDefault
public GlyphProcessingState()
protected GlyphProcessingState(GlyphSequence gs, java.lang.String script, java.lang.String language, java.lang.String feature, ScriptContextTester sct)
gs
- input glyph sequencescript
- script identifierlanguage
- language identifierfeature
- feature identifiersct
- script context tester (or null)protected GlyphProcessingState(GlyphProcessingState s)
s
- existing processing state to copy fromprotected GlyphProcessingState reset(GlyphSequence gs, java.lang.String script, java.lang.String language, java.lang.String feature, ScriptContextTester sct)
gs
- input glyph sequencescript
- script identifierlanguage
- language identifierfeature
- feature identifiersct
- script context tester (or null)public void setGDEF(GlyphDefinitionTable gdef)
gdef
- glyph definition table (or null, to unset)public GlyphDefinitionTable getGDEF()
public void setLookupFlags(int flags)
flags
- lookup flags (or zero, to unset)public int getLookupFlags()
public int getClassMatchSet(int gi)
gi
- glyph index that may be used to determine which match set appliespublic void setIgnoreDefault(GlyphTester ignoreDefault)
ignoreDefault
- glyph tester (or null, to unset)public GlyphTester getIgnoreDefault()
public void updateSubtableState(GlyphSubtable st)
st
- glyph subtable to use for updatepublic int getPosition()
public void setPosition(int index) throws java.lang.IndexOutOfBoundsException
index
- to seek tojava.lang.IndexOutOfBoundsException
- if index is less than zero
or exceeds last valid positionpublic int getLastPosition()
public boolean hasNext()
public boolean hasNext(int count)
count
glyphs remain in
input sequence.count
- of glyphs to testcount
glyphs are availablepublic int next()
public boolean hasPrev()
public boolean hasPrev(int count)
count
backtrack (previous) glyphs
are present in input sequence.count
- of glyphs to testcount
glyphs are availablepublic int prev()
public int consume(int count) throws java.lang.IndexOutOfBoundsException
count
glyphs such that
this consumption never exceeds the number of glyphs in the input glyph
sequence.count
- of glyphs to consumejava.lang.IndexOutOfBoundsException
- if count would cause consumption
to exceed count of glyphs in input glyph sequencepublic boolean didConsume()
public GlyphSequence getInput()
public int getGlyph(int offset) throws java.lang.IndexOutOfBoundsException
offset
- from current positionjava.lang.IndexOutOfBoundsException
- if no glyph available at offsetpublic int getGlyph() throws java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsException
- if no glyph availablepublic void setGlyph(int offset, int glyph) throws java.lang.IndexOutOfBoundsException
offset
- from current positionglyph
- to set at specified offset from current positionjava.lang.IndexOutOfBoundsException
- if specified offset is not valid positionpublic CharAssociation getAssociation(int offset) throws java.lang.IndexOutOfBoundsException
offset
- from current positionjava.lang.IndexOutOfBoundsException
- if offset results in an invalid index into input glyph sequencepublic CharAssociation getAssociation() throws java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsException
- if no glyph availablepublic int[] getGlyphs(int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, int[] glyphs, int[] counts) throws java.lang.IndexOutOfBoundsException
count
glyphs starting at specified offset from current position. If
reverseOrder
is true, then glyphs are returned in reverse order starting at specified offset
and going in reverse towards beginning of input glyph sequence.offset
- from current positioncount
- number of glyphs to obtainreverseOrder
- true if to obtain in reverse orderignoreTester
- glyph tester to use to determine which glyphs are ignored (or null, in which case none are ignored)glyphs
- array to use to fetch glyphscounts
- int[2] array to receive fetched glyph counts, where counts[0] will
receive the number of glyphs obtained, and counts[1] will receive the number of glyphs
ignoredjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic int[] getGlyphs(int offset, int count, int[] glyphs, int[] counts) throws java.lang.IndexOutOfBoundsException
count
glyphs starting at specified offset from current position. If
offset is negative, then glyphs are returned in reverse order starting at specified offset
and going in reverse towards beginning of input glyph sequence.offset
- from current positioncount
- number of glyphs to obtainglyphs
- array to use to fetch glyphscounts
- int[2] array to receive fetched glyph counts, where counts[0] will
receive the number of glyphs obtained, and counts[1] will receive the number of glyphs
ignoredjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic int[] getGlyphs() throws java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsException
- if no glyph availablepublic int[] getIgnoredGlyphs(int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, int[] glyphs, int[] counts) throws java.lang.IndexOutOfBoundsException
count
ignored glyphs starting at specified offset from current position. If
reverseOrder
is true, then glyphs are returned in reverse order starting at specified offset
and going in reverse towards beginning of input glyph sequence.offset
- from current positioncount
- number of glyphs to obtainreverseOrder
- true if to obtain in reverse orderignoreTester
- glyph tester to use to determine which glyphs are ignored (or null, in which case none are ignored)glyphs
- array to use to fetch glyphscounts
- int[2] array to receive fetched glyph counts, where counts[0] will
receive the number of glyphs obtained, and counts[1] will receive the number of glyphs
ignoredjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic int[] getIgnoredGlyphs(int offset, int count) throws java.lang.IndexOutOfBoundsException
count
ignored glyphs starting at specified offset from current position. If offset
is
negative, then fetch in reverse order.offset
- from current positioncount
- number of glyphs to obtainjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic boolean isIgnoredGlyph(int offset, GlyphTester ignoreTester) throws java.lang.IndexOutOfBoundsException
offset
is
negative, then test in reverse order.offset
- from current positionignoreTester
- glyph tester to use to determine which glyphs are ignored (or null, in which case none are ignored)java.lang.IndexOutOfBoundsException
- if offset results in an
invalid index into input glyph sequencepublic boolean isIgnoredGlyph(int offset) throws java.lang.IndexOutOfBoundsException
offset
is
negative, then test in reverse order.offset
- from current positionjava.lang.IndexOutOfBoundsException
- if offset results in an
invalid index into input glyph sequencepublic boolean isIgnoredGlyph() throws java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsException
- if offset results in an
invalid index into input glyph sequencepublic int[] getGlyphsAvailable(int offset, boolean reverseOrder, GlyphTester ignoreTester) throws java.lang.IndexOutOfBoundsException
reverseOrder
is true, then search backwards in input glyph sequence.offset
- from current positionreverseOrder
- true if to obtain in reverse orderignoreTester
- glyph tester to use to determine which glyphs to count (or null, in which case none are ignored)java.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic int[] getGlyphsAvailable(int offset, boolean reverseOrder) throws java.lang.IndexOutOfBoundsException
reverseOrder
is true, then search backwards in input glyph sequence. Uses the
default ignores tester.offset
- from current positionreverseOrder
- true if to obtain in reverse orderjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic int[] getGlyphsAvailable(int offset) throws java.lang.IndexOutOfBoundsException
offset
- from current positionjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic CharAssociation[] getAssociations(int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, CharAssociation[] associations, int[] counts) throws java.lang.IndexOutOfBoundsException
count
character associations of glyphs starting at specified offset from current position. If
reverseOrder
is true, then associations are returned in reverse order starting at specified offset
and going in reverse towards beginning of input glyph sequence.offset
- from current positioncount
- number of associations to obtainreverseOrder
- true if to obtain in reverse orderignoreTester
- glyph tester to use to determine which glyphs are ignored (or null, in which case none are ignored)associations
- array to use to fetch associationscounts
- int[2] array to receive fetched association counts, where counts[0] will
receive the number of associations obtained, and counts[1] will receive the number of glyphs whose
associations were ignoredjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic CharAssociation[] getAssociations(int offset, int count) throws java.lang.IndexOutOfBoundsException
count
character associations of glyphs starting at specified offset from current position. If
offset is negative, then search backwards in input glyph sequence. Uses the
default ignores tester.offset
- from current positioncount
- number of associations to obtainjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic CharAssociation[] getIgnoredAssociations(int offset, int count, boolean reverseOrder, GlyphTester ignoreTester, CharAssociation[] associations, int[] counts) throws java.lang.IndexOutOfBoundsException
count
character associations of ignored glyphs starting at specified offset from current position. If
reverseOrder
is true, then glyphs are returned in reverse order starting at specified offset
and going in reverse towards beginning of input glyph sequence.offset
- from current positioncount
- number of character associations to obtainreverseOrder
- true if to obtain in reverse orderignoreTester
- glyph tester to use to determine which glyphs are ignored (or null, in which case none are ignored)associations
- array to use to fetch associationscounts
- int[2] array to receive fetched association counts, where counts[0] will
receive the number of associations obtained, and counts[1] will receive the number of glyphs whose
associations were ignoredjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic CharAssociation[] getIgnoredAssociations(int offset, int count) throws java.lang.IndexOutOfBoundsException
count
character associations of ignored glyphs starting at specified offset from current position. If
offset is negative, then search backwards in input glyph sequence. Uses the
default ignores tester.offset
- from current positioncount
- number of character associations to obtainjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic boolean replaceInput(int offset, int count, GlyphSequence gs, int gsOffset, int gsCount) throws java.lang.IndexOutOfBoundsException
count
glyphs with a subsequence of the sequence gs
starting from the specified
offset gsOffset
of length gsCount
glyphs.offset
- from current positioncount
- number of glyphs to replace, which, if negative means all glyphs from offset to end of input sequencegs
- glyph sequence from which to obtain replacement glyphsgsOffset
- offset of first glyph in replacement sequencegsCount
- count of glyphs in replacement sequence starting at gsOffset
java.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic boolean replaceInput(int offset, int count, GlyphSequence gs) throws java.lang.IndexOutOfBoundsException
count
glyphs with all glyphs in the replacement sequence gs
.offset
- from current positioncount
- number of glyphs to replace, which, if negative means all glyphs from offset to end of input sequencegs
- glyph sequence from which to obtain replacement glyphsjava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic int erase(int offset, int[] glyphs) throws java.lang.IndexOutOfBoundsException
glyphs
array is matched, one at a time, and when a (forward searching) match is found
in the input glyph sequence, the matching glyph is replaced with the glyph index 65535.offset
- from current positionglyphs
- array of glyphs to erasejava.lang.IndexOutOfBoundsException
- if offset or count results in an
invalid index into input glyph sequencepublic boolean maybeApplicable()
public void applyDefault()
public boolean isBase(int gi)
gi
- glyph index to testpublic boolean isIgnoredBase(int gi, int flags)
gi
- glyph index to testflags
- that apply to lookup in scopepublic boolean isLigature(int gi)
gi
- glyph index to testpublic boolean isIgnoredLigature(int gi, int flags)
gi
- glyph index to testflags
- that apply to lookup in scopepublic boolean isMark(int gi)
gi
- glyph index to testpublic boolean isIgnoredMark(int gi, int flags)
gi
- glyph index to testflags
- that apply to lookup in scopepublic GlyphTester getIgnoreTester(int flags)
flags
- lookup flagspublic GlyphTester getCombinedIgnoreTester(int flags)
flags
- lookup flagspublic GlyphTester getCombinedOrTester(GlyphTester[] gta, int ngt)
gta
- an array of glyph testersngt
- number of glyph testers present in specified arraypublic GlyphTester getCombinedAndTester(GlyphTester[] gta, int ngt)
gta
- an array of glyph testersngt
- number of glyph testers present in specified arrayCopyright 1999-2017 The Apache Software Foundation. All Rights Reserved.