Class OTFAdvancedTypographicTableReader


  • public final class OTFAdvancedTypographicTableReader
    extends java.lang.Object

    OpenType Font (OTF) advanced typographic table reader. Used by @{Link org.apache.fop.fonts.truetype.TTFFile} to read advanced typographic tables (GDEF, GSUB, GPOS).

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

    • Field Detail

      • log

        private static org.apache.commons.logging.Log log
      • seScripts

        private transient java.util.Map<java.lang.String,​java.lang.Object> seScripts
      • seLanguages

        private transient java.util.Map<java.lang.String,​java.lang.Object> seLanguages
      • seFeatures

        private transient java.util.Map<java.lang.String,​java.lang.Object> seFeatures
      • seEntries

        private transient java.util.List seEntries
      • seSubtables

        private transient java.util.List seSubtables
      • processors

        private java.util.Map<java.lang.String,​ScriptProcessor> processors
      • defaultTag

        private static java.lang.String defaultTag
    • Constructor Detail

      • OTFAdvancedTypographicTableReader

        public OTFAdvancedTypographicTableReader​(OpenFont otf,
                                                 FontFileReader in)
        Construct an OTFAdvancedTypographicTableReader instance.
        Parameters:
        otf - parent font file reader (must be non-null)
        in - font file reader (must be non-null)
    • Method Detail

      • hasAdvancedTable

        public boolean hasAdvancedTable()
        Determine if advanced (typographic) table is present.
        Returns:
        true if advanced (typographic) table is present
      • getGDEF

        public GlyphDefinitionTable getGDEF()
        Returns the GDEF table or null if none present.
        Returns:
        the GDEF table
      • getGSUB

        public GlyphSubstitutionTable getGSUB()
        Returns the GSUB table or null if none present.
        Returns:
        the GSUB table
      • getGPOS

        public GlyphPositioningTable getGPOS()
        Returns the GPOS table or null if none present.
        Returns:
        the GPOS table
      • readLangSysTable

        private void readLangSysTable​(OFTableName tableTag,
                                      long langSysTable,
                                      java.lang.String langSysTag)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readScriptTable

        private void readScriptTable​(OFTableName tableTag,
                                     long scriptTable,
                                     java.lang.String scriptTag)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readScriptList

        private void readScriptList​(OFTableName tableTag,
                                    long scriptList)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • readFeatureTable

        private void readFeatureTable​(OFTableName tableTag,
                                      long featureTable,
                                      java.lang.String featureTag,
                                      int featureIndex)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readFeatureList

        private void readFeatureList​(OFTableName tableTag,
                                     long featureList)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readCoverageTableFormat1

        private GlyphCoverageTable readCoverageTableFormat1​(java.lang.String label,
                                                            long tableOffset,
                                                            int coverageFormat)
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readCoverageTableFormat2

        private GlyphCoverageTable readCoverageTableFormat2​(java.lang.String label,
                                                            long tableOffset,
                                                            int coverageFormat)
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readCoverageTable

        private GlyphCoverageTable readCoverageTable​(java.lang.String label,
                                                     long tableOffset)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readClassDefTableFormat1

        private GlyphClassTable readClassDefTableFormat1​(java.lang.String label,
                                                         long tableOffset,
                                                         int classFormat)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • readClassDefTableFormat2

        private GlyphClassTable readClassDefTableFormat2​(java.lang.String label,
                                                         long tableOffset,
                                                         int classFormat)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • readClassDefTable

        private GlyphClassTable readClassDefTable​(java.lang.String label,
                                                  long tableOffset)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readSingleSubTableFormat1

        private void readSingleSubTableFormat1​(int lookupType,
                                               int lookupFlags,
                                               long subtableOffset,
                                               int subtableFormat)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readSingleSubTableFormat2

        private void readSingleSubTableFormat2​(int lookupType,
                                               int lookupFlags,
                                               long subtableOffset,
                                               int subtableFormat)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readSingleSubTable

        private int readSingleSubTable​(int lookupType,
                                       int lookupFlags,
                                       long subtableOffset)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • readMultipleSubTableFormat1

        private void readMultipleSubTableFormat1​(int lookupType,
                                                 int lookupFlags,
                                                 long subtableOffset,
                                                 int subtableFormat)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readMultipleSubTable

        private int readMultipleSubTable​(int lookupType,
                                         int lookupFlags,
                                         long subtableOffset)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • readAlternateSubTableFormat1

        private void readAlternateSubTableFormat1​(int lookupType,
                                                  int lookupFlags,
                                                  long subtableOffset,
                                                  int subtableFormat)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readAlternateSubTable

        private int readAlternateSubTable​(int lookupType,
                                          int lookupFlags,
                                          long subtableOffset)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readLigatureSubTableFormat1

        private void readLigatureSubTableFormat1​(int lookupType,
                                                 int lookupFlags,
                                                 long subtableOffset,
                                                 int subtableFormat)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readLigatureSubTable

        private int readLigatureSubTable​(int lookupType,
                                         int lookupFlags,
                                         long subtableOffset)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • readRuleLookups

        private GlyphTable.RuleLookup[] readRuleLookups​(int numLookups,
                                                        java.lang.String header)
                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • readContextualSubTableFormat1

        private void readContextualSubTableFormat1​(int lookupType,
                                                   int lookupFlags,
                                                   long subtableOffset,
                                                   int subtableFormat)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • readContextualSubTableFormat2

        private void readContextualSubTableFormat2​(int lookupType,
                                                   int lookupFlags,
                                                   long subtableOffset,
                                                   int subtableFormat)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • readContextualSubTableFormat3

        private void readContextualSubTableFormat3​(int lookupType,
                                                   int lookupFlags,
                                                   long subtableOffset,
                                                   int subtableFormat)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • readContextualSubTable

        private int readContextualSubTable​(int lookupType,
                                           int lookupFlags,
                                           long subtableOffset)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • readChainedContextualSubTableFormat1

        private void readChainedContextualSubTableFormat1​(int lookupType,
                                                          int lookupFlags,
                                                          long subtableOffset,
                                                          int subtableFormat)
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readChainedContextualSubTableFormat2

        private void readChainedContextualSubTableFormat2​(int lookupType,
                                                          int lookupFlags,
                                                          long subtableOffset,
                                                          int subtableFormat)
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readChainedContextualSubTableFormat3

        private void readChainedContextualSubTableFormat3​(int lookupType,
                                                          int lookupFlags,
                                                          long subtableOffset,
                                                          int subtableFormat)
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readChainedContextualSubTable

        private int readChainedContextualSubTable​(int lookupType,
                                                  int lookupFlags,
                                                  long subtableOffset)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readExtensionSubTableFormat1

        private void readExtensionSubTableFormat1​(int lookupType,
                                                  int lookupFlags,
                                                  int lookupSequence,
                                                  int subtableSequence,
                                                  long subtableOffset,
                                                  int subtableFormat)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readExtensionSubTable

        private int readExtensionSubTable​(int lookupType,
                                          int lookupFlags,
                                          int lookupSequence,
                                          int subtableSequence,
                                          long subtableOffset)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readReverseChainedSingleSubTableFormat1

        private void readReverseChainedSingleSubTableFormat1​(int lookupType,
                                                             int lookupFlags,
                                                             long subtableOffset,
                                                             int subtableFormat)
                                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • readReverseChainedSingleSubTable

        private int readReverseChainedSingleSubTable​(int lookupType,
                                                     int lookupFlags,
                                                     long subtableOffset)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readGSUBSubtable

        private void readGSUBSubtable​(int lookupType,
                                      int lookupFlags,
                                      int lookupSequence,
                                      int subtableSequence,
                                      long subtableOffset)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readPosDeviceTable

        private GlyphPositioningTable.DeviceTable readPosDeviceTable​(long subtableOffset,
                                                                     long deviceTableOffset)
                                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readPosValue

        private GlyphPositioningTable.Value readPosValue​(long subtableOffset,
                                                         int valueFormat)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • readSinglePosTableFormat1

        private void readSinglePosTableFormat1​(int lookupType,
                                               int lookupFlags,
                                               long subtableOffset,
                                               int subtableFormat)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readSinglePosTableFormat2

        private void readSinglePosTableFormat2​(int lookupType,
                                               int lookupFlags,
                                               long subtableOffset,
                                               int subtableFormat)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readSinglePosTable

        private int readSinglePosTable​(int lookupType,
                                       int lookupFlags,
                                       long subtableOffset)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • readPosPairValues

        private GlyphPositioningTable.PairValues readPosPairValues​(long subtableOffset,
                                                                   boolean hasGlyph,
                                                                   int vf1,
                                                                   int vf2)
                                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • readPosPairSetTable

        private GlyphPositioningTable.PairValues[] readPosPairSetTable​(long subtableOffset,
                                                                       int pairSetTableOffset,
                                                                       int vf1,
                                                                       int vf2)
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • readPairPosTableFormat1

        private void readPairPosTableFormat1​(int lookupType,
                                             int lookupFlags,
                                             long subtableOffset,
                                             int subtableFormat)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • readPairPosTableFormat2

        private void readPairPosTableFormat2​(int lookupType,
                                             int lookupFlags,
                                             long subtableOffset,
                                             int subtableFormat)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • readPairPosTable

        private int readPairPosTable​(int lookupType,
                                     int lookupFlags,
                                     long subtableOffset)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readPosAnchor

        private GlyphPositioningTable.Anchor readPosAnchor​(long anchorTableOffset)
                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • readCursivePosTableFormat1

        private void readCursivePosTableFormat1​(int lookupType,
                                                int lookupFlags,
                                                long subtableOffset,
                                                int subtableFormat)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • readCursivePosTable

        private int readCursivePosTable​(int lookupType,
                                        int lookupFlags,
                                        long subtableOffset)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • readMarkToBasePosTableFormat1

        private void readMarkToBasePosTableFormat1​(int lookupType,
                                                   int lookupFlags,
                                                   long subtableOffset,
                                                   int subtableFormat)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • readMarkToBasePosTable

        private int readMarkToBasePosTable​(int lookupType,
                                           int lookupFlags,
                                           long subtableOffset)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • readMarkToLigaturePosTableFormat1

        private void readMarkToLigaturePosTableFormat1​(int lookupType,
                                                       int lookupFlags,
                                                       long subtableOffset,
                                                       int subtableFormat)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • readMarkToLigaturePosTable

        private int readMarkToLigaturePosTable​(int lookupType,
                                               int lookupFlags,
                                               long subtableOffset)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readMarkToMarkPosTableFormat1

        private void readMarkToMarkPosTableFormat1​(int lookupType,
                                                   int lookupFlags,
                                                   long subtableOffset,
                                                   int subtableFormat)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • readMarkToMarkPosTable

        private int readMarkToMarkPosTable​(int lookupType,
                                           int lookupFlags,
                                           long subtableOffset)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • readContextualPosTableFormat1

        private void readContextualPosTableFormat1​(int lookupType,
                                                   int lookupFlags,
                                                   long subtableOffset,
                                                   int subtableFormat)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • readContextualPosTableFormat2

        private void readContextualPosTableFormat2​(int lookupType,
                                                   int lookupFlags,
                                                   long subtableOffset,
                                                   int subtableFormat)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • readContextualPosTableFormat3

        private void readContextualPosTableFormat3​(int lookupType,
                                                   int lookupFlags,
                                                   long subtableOffset,
                                                   int subtableFormat)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • readContextualPosTable

        private int readContextualPosTable​(int lookupType,
                                           int lookupFlags,
                                           long subtableOffset)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • readChainedContextualPosTableFormat1

        private void readChainedContextualPosTableFormat1​(int lookupType,
                                                          int lookupFlags,
                                                          long subtableOffset,
                                                          int subtableFormat)
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readChainedContextualPosTableFormat2

        private void readChainedContextualPosTableFormat2​(int lookupType,
                                                          int lookupFlags,
                                                          long subtableOffset,
                                                          int subtableFormat)
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readChainedContextualPosTableFormat3

        private void readChainedContextualPosTableFormat3​(int lookupType,
                                                          int lookupFlags,
                                                          long subtableOffset,
                                                          int subtableFormat)
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readChainedContextualPosTable

        private int readChainedContextualPosTable​(int lookupType,
                                                  int lookupFlags,
                                                  long subtableOffset)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readExtensionPosTableFormat1

        private void readExtensionPosTableFormat1​(int lookupType,
                                                  int lookupFlags,
                                                  int lookupSequence,
                                                  int subtableSequence,
                                                  long subtableOffset,
                                                  int subtableFormat)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readExtensionPosTable

        private int readExtensionPosTable​(int lookupType,
                                          int lookupFlags,
                                          int lookupSequence,
                                          int subtableSequence,
                                          long subtableOffset)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readGPOSSubtable

        private void readGPOSSubtable​(int lookupType,
                                      int lookupFlags,
                                      int lookupSequence,
                                      int subtableSequence,
                                      long subtableOffset)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readLookupTable

        private void readLookupTable​(OFTableName tableTag,
                                     int lookupSequence,
                                     long lookupTable)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readLookupList

        private void readLookupList​(OFTableName tableTag,
                                    long lookupList)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • readCommonLayoutTables

        private void readCommonLayoutTables​(OFTableName tableTag,
                                            long scriptList,
                                            long featureList,
                                            long lookupList)
                                     throws java.io.IOException
        Read the common layout tables (used by GSUB and GPOS).
        Parameters:
        tableTag - tag of table being read
        scriptList - offset to script list from beginning of font file
        featureList - offset to feature list from beginning of font file
        lookupList - offset to lookup list from beginning of font file
        Throws:
        java.io.IOException - In case of a I/O problem
      • readGDEFClassDefTable

        private void readGDEFClassDefTable​(OFTableName tableTag,
                                           int lookupSequence,
                                           long subtableOffset)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • readGDEFAttachmentTable

        private void readGDEFAttachmentTable​(OFTableName tableTag,
                                             int lookupSequence,
                                             long subtableOffset)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • readGDEFLigatureCaretTable

        private void readGDEFLigatureCaretTable​(OFTableName tableTag,
                                                int lookupSequence,
                                                long subtableOffset)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • readGDEFMarkAttachmentTable

        private void readGDEFMarkAttachmentTable​(OFTableName tableTag,
                                                 int lookupSequence,
                                                 long subtableOffset)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readGDEFMarkGlyphsTableFormat1

        private void readGDEFMarkGlyphsTableFormat1​(OFTableName tableTag,
                                                    int lookupSequence,
                                                    long subtableOffset,
                                                    int subtableFormat)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • readGDEFMarkGlyphsTable

        private void readGDEFMarkGlyphsTable​(OFTableName tableTag,
                                             int lookupSequence,
                                             long subtableOffset)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • readGDEF

        private void readGDEF()
                       throws java.io.IOException
        Read the GDEF table.
        Throws:
        java.io.IOException - In case of a I/O problem
      • readGSUB

        private void readGSUB()
                       throws java.io.IOException
        Read the GSUB table.
        Throws:
        java.io.IOException - In case of a I/O problem
      • readGPOS

        private void readGPOS()
                       throws java.io.IOException
        Read the GPOS table.
        Throws:
        java.io.IOException - In case of a I/O problem
      • constructGDEF

        private GlyphDefinitionTable constructGDEF()
        Construct the (internal representation of the) GDEF table based on previously parsed state.
      • constructGSUB

        private GlyphSubstitutionTable constructGSUB()
        Construct the (internal representation of the) GSUB table based on previously parsed state.
      • constructGPOS

        private GlyphPositioningTable constructGPOS()
        Construct the (internal representation of the) GPOS table based on previously parsed state.
      • constructLookupsFeature

        private void constructLookupsFeature​(java.util.Map lookups,
                                             java.lang.String st,
                                             java.lang.String lt,
                                             java.lang.String fid)
      • constructLookupsFeatures

        private void constructLookupsFeatures​(java.util.Map lookups,
                                              java.lang.String st,
                                              java.lang.String lt,
                                              java.util.List<java.lang.String> fids)
      • constructLookupsLanguage

        private void constructLookupsLanguage​(java.util.Map lookups,
                                              java.lang.String st,
                                              java.lang.String lt,
                                              java.util.Map<java.lang.String,​java.lang.Object> languages)
      • constructLookupsLanguages

        private void constructLookupsLanguages​(java.util.Map lookups,
                                               java.lang.String st,
                                               java.util.List<java.lang.String> ll,
                                               java.util.Map<java.lang.String,​java.lang.Object> languages)
      • constructLookups

        private java.util.Map constructLookups()
      • constructGDEFSubtables

        private java.util.List constructGDEFSubtables()
      • constructGDEFSubtable

        private GlyphSubtable constructGDEFSubtable​(java.lang.Object[] stp)
      • constructGSUBSubtables

        private java.util.List constructGSUBSubtables()
      • constructGSUBSubtable

        private GlyphSubtable constructGSUBSubtable​(java.lang.Object[] stp)
      • constructGPOSSubtables

        private java.util.List constructGPOSSubtables()
      • constructGPOSSubtable

        private GlyphSubtable constructGPOSSubtable​(java.lang.Object[] stp)
      • initATState

        private void initATState()
      • resetATState

        private void resetATState()
      • initATSubState

        private void initATSubState()
      • extractSESubState

        private void extractSESubState​(int tableType,
                                       int lookupType,
                                       int lookupFlags,
                                       int lookupSequence,
                                       int subtableSequence,
                                       int subtableFormat)
      • resetATSubState

        private void resetATSubState()
      • resetATStateAll

        private void resetATStateAll()
      • toString

        private java.lang.String toString​(int[] ia)
        helper method for formatting an integer array for output