ScriptProcessor (Apache FOP Core 2.11 API)
Date: 2025-04-24

org.apache.fop.complexscripts.scripts

## Class ScriptProcessor

- java.lang.Object
- - org.apache.fop.complexscripts.scripts.ScriptProcessor

- Direct Known Subclasses:
    DefaultScriptProcessor

      public abstract class ScriptProcessor
      extends 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).

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ScriptProcessor(String script)` Instantiate a script processor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `GlyphTable.UseSpec[]` | `assembleLookups(GlyphTable table, String[] features, Map<GlyphTable.LookupSpec,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.
    `static ScriptProcessor` | `getInstance(String script, Map<String,ScriptProcessor> processors)` Obtain script processor instance associated with specified script.
    `String[]` | `getOptionalPositioningFeatures()` Obtain script specific optional positioning features.
    `String[]` | `getOptionalSubstitutionFeatures()` Obtain script specific optional substitution features.
    `abstract ScriptContextTester` | `getPositioningContextTester()` Obtain script specific positioning context tester.
    `abstract String[]` | `getPositioningFeatures()` Obtain script specific required positioning features.
    `String` | `getScript()`
    `abstract ScriptContextTester` | `getSubstitutionContextTester()` Obtain script specific substitution context tester.
    `abstract String[]` | `getSubstitutionFeatures()` Obtain script specific required substitution features.
    `boolean` | `position(GlyphPositioningTable gpos, GlyphSequence gs, String script, String language, int fontSize, Map<GlyphTable.LookupSpec,List<GlyphTable.LookupTable>> lookups, int[] widths, int[][] adjustments)` Perform positioning processing using a specific set of lookup tables.
    `boolean` | `position(GlyphSequence gs, String script, 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.
    `CharSequence` | `preProcess(CharSequence charSequence, MultiByteFont font, List associations)`
    `GlyphSequence` | `reorderCombiningMarks(GlyphDefinitionTable gdef, GlyphSequence gs, int[] unscaledWidths, int[][] gpa, String script, 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(GlyphSequence gs, String script, String language, GlyphTable.UseSpec[] usa, ScriptContextTester sct)` Perform substitution processing using a specific set of ordered glyph table use specifications.
    `GlyphSequence` | `substitute(GlyphSubstitutionTable gsub, GlyphSequence gs, String script, String language, Map<GlyphTable.LookupSpec,List<GlyphTable.LookupTable>> lookups)` Perform substitution processing using a specific set of lookup tables.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ScriptProcessor

          protected ScriptProcessor(String script)

      Instantiate a script processor.
      Parameters:
        `script` - a script identifier

  - ### Method Detail

    - #### getScript

          public final String getScript()

      Returns:
        script identifier

    - #### getSubstitutionFeatures

          public abstract String[] getSubstitutionFeatures()

      Obtain script specific required substitution features.
      Returns:
        array of suppported substitution features or null

    - #### getOptionalSubstitutionFeatures

          public 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,
                                                String script,
                                                String language,
                                                Map<GlyphTable.LookupSpec,List<GlyphTable.LookupTable>> lookups)

      Perform substitution processing using a specific set of lookup tables.
      Parameters:
        `gsub` - the glyph substitution table that applies
        `gs` - an input glyph sequence
        `script` - a script identifier
        `language` - a language identifier
        `lookups` - 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,
                                          String script,
                                          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 sequence
        `script` - a script identifier
        `language` - a language identifier
        `usa` - an ordered array of glyph table use specs
        `sct` - 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,
                                                     String script,
                                                     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 applies
        `gs` - an input glyph sequence
        `unscaledWidths` - associated unscaled advance widths (also reordered)
        `gpa` - associated glyph position adjustments (also reordered)
        `script` - a script identifier
        `language` - a language identifier
      Returns:
        the reordered (output) glyph sequence

    - #### getPositioningFeatures

          public abstract String[] getPositioningFeatures()

      Obtain script specific required positioning features.
      Returns:
        array of suppported positioning features or null

    - #### getOptionalPositioningFeatures

          public 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,
                                        String script,
                                        String language,
                                        int fontSize,
                                        Map<GlyphTable.LookupSpec,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 applies
        `gs` - an input glyph sequence
        `script` - a script identifier
        `language` - a language identifier
        `fontSize` - size in device units
        `lookups` - a mapping from lookup specifications to glyph subtables to use for positioning processing
        `widths` - array of default advancements for each glyph
        `adjustments` - 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,
                                  String script,
                                  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 sequence
        `script` - a script identifier
        `language` - a language identifier
        `fontSize` - size in device units
        `usa` - an ordered array of glyph table use specs
        `widths` - array of default advancements for each glyph in font
        `adjustments` - 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
        `sct` - 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,
                                                            String[] features,
                                                            Map<GlyphTable.LookupSpec,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 table
        `features` - array of feature identifiers to apply
        `lookups` - 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

    - #### getInstance

          public static ScriptProcessor getInstance(String script,
                                                    Map<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

    - #### preProcess

          public CharSequence preProcess(CharSequence charSequence,
                                         MultiByteFont font,
                                         List associations)

Copyright © 2025 Apache Software Foundation. All rights reserved.