Class ScriptProcessor
- java.lang.Object
-
- org.apache.fop.complexscripts.scripts.ScriptProcessor
-
- Direct Known Subclasses:
DefaultScriptProcessor
public abstract class ScriptProcessor extends java.lang.Object
Abstract script processor base class for which an implementation of the substitution and positioning methods must be supplied.
This work was originally authored by Glenn Adams (gadams@apache.org).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ScriptProcessor.AssembledLookupsKey
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<ScriptProcessor.AssembledLookupsKey,GlyphTable.UseSpec[]>
assembledLookups
private java.lang.String
script
-
Constructor Summary
Constructors Modifier Constructor Description protected
ScriptProcessor(java.lang.String script)
Instantiate a script processor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private GlyphTable.UseSpec[]
assembledLookupsGet(ScriptProcessor.AssembledLookupsKey key)
private GlyphTable.UseSpec[]
assembledLookupsPut(ScriptProcessor.AssembledLookupsKey key, GlyphTable.UseSpec[] usa)
GlyphTable.UseSpec[]
assembleLookups(GlyphTable table, java.lang.String[] features, java.util.Map<GlyphTable.LookupSpec,java.util.List<GlyphTable.LookupTable>> lookups)
Assemble ordered array of lookup table use specifications according to the specified features and candidate lookups, where the order of the array is in accordance to the order of the applicable lookup list.private static ScriptProcessor
createProcessor(java.lang.String script)
static ScriptProcessor
getInstance(java.lang.String script, java.util.Map<java.lang.String,ScriptProcessor> processors)
Obtain script processor instance associated with specified script.java.lang.String[]
getOptionalPositioningFeatures()
Obtain script specific optional positioning features.java.lang.String[]
getOptionalSubstitutionFeatures()
Obtain script specific optional substitution features.abstract ScriptContextTester
getPositioningContextTester()
Obtain script specific positioning context tester.abstract java.lang.String[]
getPositioningFeatures()
Obtain script specific required positioning features.java.lang.String
getScript()
abstract ScriptContextTester
getSubstitutionContextTester()
Obtain script specific substitution context tester.abstract java.lang.String[]
getSubstitutionFeatures()
Obtain script specific required substitution features.boolean
position(GlyphPositioningTable gpos, GlyphSequence gs, java.lang.String script, java.lang.String language, int fontSize, java.util.Map<GlyphTable.LookupSpec,java.util.List<GlyphTable.LookupTable>> lookups, int[] widths, int[][] adjustments)
Perform positioning processing using a specific set of lookup tables.boolean
position(GlyphSequence gs, java.lang.String script, java.lang.String language, int fontSize, GlyphTable.UseSpec[] usa, int[] widths, int[][] adjustments, ScriptContextTester sct)
Perform positioning processing using a specific set of ordered glyph table use specifications.java.lang.CharSequence
preProcess(java.lang.CharSequence charSequence, MultiByteFont font, java.util.List associations)
GlyphSequence
reorderCombiningMarks(GlyphDefinitionTable gdef, GlyphSequence gs, int[] unscaledWidths, int[][] gpa, java.lang.String script, java.lang.String language)
Reorder combining marks in glyph sequence so that they precede (within the sequence) the base character to which they are applied.GlyphSequence
substitute(GlyphSubstitutionTable gsub, GlyphSequence gs, java.lang.String script, java.lang.String language, java.util.Map<GlyphTable.LookupSpec,java.util.List<GlyphTable.LookupTable>> lookups)
Perform substitution processing using a specific set of lookup tables.GlyphSequence
substitute(GlyphSequence gs, java.lang.String script, java.lang.String language, GlyphTable.UseSpec[] usa, ScriptContextTester sct)
Perform substitution processing using a specific set of ordered glyph table use specifications.
-
-
-
Field Detail
-
script
private final java.lang.String script
-
assembledLookups
private final java.util.Map<ScriptProcessor.AssembledLookupsKey,GlyphTable.UseSpec[]> assembledLookups
-
-
Method Detail
-
getScript
public final java.lang.String getScript()
- Returns:
- script identifier
-
getSubstitutionFeatures
public abstract java.lang.String[] getSubstitutionFeatures()
Obtain script specific required substitution features.- Returns:
- array of suppported substitution features or null
-
getOptionalSubstitutionFeatures
public java.lang.String[] getOptionalSubstitutionFeatures()
Obtain script specific optional substitution features.- Returns:
- array of suppported substitution features or null
-
getSubstitutionContextTester
public abstract ScriptContextTester getSubstitutionContextTester()
Obtain script specific substitution context tester.- Returns:
- substitution context tester or null
-
substitute
public final GlyphSequence substitute(GlyphSubstitutionTable gsub, GlyphSequence gs, java.lang.String script, java.lang.String language, java.util.Map<GlyphTable.LookupSpec,java.util.List<GlyphTable.LookupTable>> lookups)
Perform substitution processing using a specific set of lookup tables.- Parameters:
gsub
- the glyph substitution table that appliesgs
- an input glyph sequencescript
- a script identifierlanguage
- a language identifierlookups
- a mapping from lookup specifications to glyph subtables to use for substitution processing- Returns:
- the substituted (output) glyph sequence
-
substitute
public GlyphSequence substitute(GlyphSequence gs, java.lang.String script, java.lang.String language, GlyphTable.UseSpec[] usa, ScriptContextTester sct)
Perform substitution processing using a specific set of ordered glyph table use specifications.- Parameters:
gs
- an input glyph sequencescript
- a script identifierlanguage
- a language identifierusa
- an ordered array of glyph table use specssct
- a script specific context tester (or null)- Returns:
- the substituted (output) glyph sequence
-
reorderCombiningMarks
public GlyphSequence reorderCombiningMarks(GlyphDefinitionTable gdef, GlyphSequence gs, int[] unscaledWidths, int[][] gpa, java.lang.String script, java.lang.String language)
Reorder combining marks in glyph sequence so that they precede (within the sequence) the base character to which they are applied. N.B. In the case of RTL segments, marks are not reordered by this, method since when the segment is reversed by BIDI processing, marks are automatically reordered to precede their base glyph.- Parameters:
gdef
- the glyph definition table that appliesgs
- an input glyph sequenceunscaledWidths
- associated unscaled advance widths (also reordered)gpa
- associated glyph position adjustments (also reordered)script
- a script identifierlanguage
- a language identifier- Returns:
- the reordered (output) glyph sequence
-
getPositioningFeatures
public abstract java.lang.String[] getPositioningFeatures()
Obtain script specific required positioning features.- Returns:
- array of suppported positioning features or null
-
getOptionalPositioningFeatures
public java.lang.String[] getOptionalPositioningFeatures()
Obtain script specific optional positioning features.- Returns:
- array of suppported positioning features or null
-
getPositioningContextTester
public abstract ScriptContextTester getPositioningContextTester()
Obtain script specific positioning context tester.- Returns:
- positioning context tester or null
-
position
public final boolean position(GlyphPositioningTable gpos, GlyphSequence gs, java.lang.String script, java.lang.String language, int fontSize, java.util.Map<GlyphTable.LookupSpec,java.util.List<GlyphTable.LookupTable>> lookups, int[] widths, int[][] adjustments)
Perform positioning processing using a specific set of lookup tables.- Parameters:
gpos
- the glyph positioning table that appliesgs
- an input glyph sequencescript
- a script identifierlanguage
- a language identifierfontSize
- size in device unitslookups
- a mapping from lookup specifications to glyph subtables to use for positioning processingwidths
- array of default advancements for each glyphadjustments
- accumulated adjustments array (sequence) of 4-tuples of placement [PX,PY] and advance [AX,AY] adjustments, in that order, with one 4-tuple for each element of glyph sequence- Returns:
- true if some adjustment is not zero; otherwise, false
-
position
public boolean position(GlyphSequence gs, java.lang.String script, java.lang.String language, int fontSize, GlyphTable.UseSpec[] usa, int[] widths, int[][] adjustments, ScriptContextTester sct)
Perform positioning processing using a specific set of ordered glyph table use specifications.- Parameters:
gs
- an input glyph sequencescript
- a script identifierlanguage
- a language identifierfontSize
- size in device unitsusa
- an ordered array of glyph table use specswidths
- array of default advancements for each glyph in fontadjustments
- accumulated adjustments array (sequence) of 4-tuples of placement [PX,PY] and advance [AX,AY] adjustments, in that order, with one 4-tuple for each element of glyph sequencesct
- a script specific context tester (or null)- Returns:
- true if some adjustment is not zero; otherwise, false
-
assembleLookups
public final GlyphTable.UseSpec[] assembleLookups(GlyphTable table, java.lang.String[] features, java.util.Map<GlyphTable.LookupSpec,java.util.List<GlyphTable.LookupTable>> lookups)
Assemble ordered array of lookup table use specifications according to the specified features and candidate lookups, where the order of the array is in accordance to the order of the applicable lookup list.- Parameters:
table
- the governing glyph tablefeatures
- array of feature identifiers to applylookups
- a mapping from lookup specifications to lists of look tables from which to select lookup tables according to the specified features- Returns:
- ordered array of assembled lookup table use specifications
-
assembledLookupsGet
private GlyphTable.UseSpec[] assembledLookupsGet(ScriptProcessor.AssembledLookupsKey key)
-
assembledLookupsPut
private GlyphTable.UseSpec[] assembledLookupsPut(ScriptProcessor.AssembledLookupsKey key, GlyphTable.UseSpec[] usa)
-
getInstance
public static ScriptProcessor getInstance(java.lang.String script, java.util.Map<java.lang.String,ScriptProcessor> processors)
Obtain script processor instance associated with specified script.- Parameters:
script
- a script identifier- Returns:
- a script processor instance or null if none found
-
createProcessor
private static ScriptProcessor createProcessor(java.lang.String script)
-
preProcess
public java.lang.CharSequence preProcess(java.lang.CharSequence charSequence, MultiByteFont font, java.util.List associations)
-
-