Class GlyphPositioningState


  • public class GlyphPositioningState
    extends GlyphProcessingState

    The GlyphPositioningState implements an state object used during glyph positioning processing.

    This work was originally authored by Glenn Adams (gadams@apache.org).

    • Constructor Detail

      • GlyphPositioningState

        public GlyphPositioningState()
        Construct default (reset) glyph positioning state.
      • GlyphPositioningState

        public GlyphPositioningState​(GlyphSequence gs,
                                     java.lang.String script,
                                     java.lang.String language,
                                     java.lang.String feature,
                                     int fontSize,
                                     int[] widths,
                                     int[][] adjustments,
                                     ScriptContextTester sct)
        Construct glyph positioning state.
        Parameters:
        gs - input glyph sequence
        script - script identifier
        language - language identifier
        feature - feature identifier
        fontSize - font size (in micropoints)
        widths - array of design advancements (in glyph index order)
        adjustments - positioning adjustments to which positioning is applied
        sct - script context tester (or null)
      • GlyphPositioningState

        public GlyphPositioningState​(GlyphPositioningState ps)
        Construct glyph positioning state using an existing state object using shallow copy except as follows: input glyph sequence is copied deep except for its characters array.
        Parameters:
        ps - existing positioning state to copy from
    • Method Detail

      • reset

        public GlyphPositioningState reset​(GlyphSequence gs,
                                           java.lang.String script,
                                           java.lang.String language,
                                           java.lang.String feature,
                                           int fontSize,
                                           int[] widths,
                                           int[][] adjustments,
                                           ScriptContextTester sct)
        Reset glyph positioning state.
        Parameters:
        gs - input glyph sequence
        script - script identifier
        language - language identifier
        feature - feature identifier
        fontSize - font size (in micropoints)
        widths - array of design advancements (in glyph index order)
        adjustments - positioning adjustments to which positioning is applied
        sct - script context tester (or null)
      • getWidth

        public int getWidth​(int gi)
        Obtain design advancement (width) of glyph at specified index.
        Parameters:
        gi - glyph index
        Returns:
        design advancement, or zero if glyph index is not present
      • adjust

        public boolean adjust​(GlyphPositioningTable.Value v)
        Perform adjustments at current position index.
        Parameters:
        v - value containing adjustments
        Returns:
        true if a non-zero adjustment was made
      • adjust

        public boolean adjust​(GlyphPositioningTable.Value v,
                              int offset)
        Perform adjustments at specified offset from current position index.
        Parameters:
        v - value containing adjustments
        offset - from current position index
        Returns:
        true if a non-zero adjustment was made
      • getAdjustment

        public int[] getAdjustment()
        Obtain current adjustments at current position index.
        Returns:
        array of adjustments (int[4]) at current position
      • getAdjustment

        public int[] getAdjustment​(int offset)
                            throws java.lang.IndexOutOfBoundsException
        Obtain current adjustments at specified offset from current position index.
        Parameters:
        offset - from current position index
        Returns:
        array of adjustments (int[4]) at specified offset
        Throws:
        java.lang.IndexOutOfBoundsException - if offset is invalid
      • apply

        public boolean apply​(GlyphPositioningSubtable st)
        Apply positioning subtable to current state at current position (only), resulting in the consumption of zero or more input glyphs.
        Parameters:
        st - the glyph positioning subtable to apply
        Returns:
        true if subtable applied, or false if it did not (e.g., its input coverage table did not match current input context)
      • apply

        public boolean apply​(GlyphTable.RuleLookup[] lookups,
                             int nig)
        Apply a sequence of matched rule lookups to the nig input glyphs starting at the current position. If lookups are non-null and non-empty, then all input glyphs specified by nig are consumed irregardless of whether any specified lookup applied.
        Parameters:
        lookups - array of matched lookups (or null)
        nig - number of glyphs in input sequence, starting at current position, to which the lookups are to apply, and to be consumed once the application has finished
        Returns:
        true if lookups are non-null and non-empty; otherwise, false
      • applyDefault

        public void applyDefault()
        Apply default application semantices; namely, consume one input glyph.
        Overrides:
        applyDefault in class GlyphProcessingState
      • setAdjusted

        public void setAdjusted​(boolean adjusted)
        Set adjusted state, used to record effect of non-zero adjustment.
        Parameters:
        adjusted - true if to set adjusted state, otherwise false to clear adjusted state
      • getAdjusted

        public boolean getAdjusted()
        Get adjusted state.
        Returns:
        adjusted true if some non-zero adjustment occurred and was recorded by setAdjusted(boolean); otherwise, false.