Class OTFAdvancedTypographicTableReader

java.lang.Object
org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader

public final class OTFAdvancedTypographicTableReader extends 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 Details

  • Constructor Details

    • 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 Details

    • readAll

      public void readAll() throws AdvancedTypographicTableFormatException
      Read all advanced typographic tables.
      Throws:
      AdvancedTypographicTableFormatException - if ATT table has invalid format
    • 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, String langSysTag) throws IOException
      Throws:
      IOException
    • readScriptTable

      private void readScriptTable(OFTableName tableTag, long scriptTable, String scriptTag) throws IOException
      Throws:
      IOException
    • readScriptList

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

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

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

      private GlyphCoverageTable readCoverageTableFormat1(String label, long tableOffset, int coverageFormat) throws IOException
      Throws:
      IOException
    • readCoverageTableFormat2

      private GlyphCoverageTable readCoverageTableFormat2(String label, long tableOffset, int coverageFormat) throws IOException
      Throws:
      IOException
    • readCoverageTable

      private GlyphCoverageTable readCoverageTable(String label, long tableOffset) throws IOException
      Throws:
      IOException
    • readClassDefTableFormat1

      private GlyphClassTable readClassDefTableFormat1(String label, long tableOffset, int classFormat) throws IOException
      Throws:
      IOException
    • readClassDefTableFormat2

      private GlyphClassTable readClassDefTableFormat2(String label, long tableOffset, int classFormat) throws IOException
      Throws:
      IOException
    • readClassDefTable

      private GlyphClassTable readClassDefTable(String label, long tableOffset) throws IOException
      Throws:
      IOException
    • readSingleSubTableFormat1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      private void readCommonLayoutTables(OFTableName tableTag, long scriptList, long featureList, long lookupList) throws 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:
      IOException - In case of a I/O problem
    • readGDEFClassDefTable

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

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

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

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

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

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

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

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

      private void readGPOS() throws IOException
      Read the GPOS table.
      Throws:
      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(Map lookups, String st, String lt, String fid)
    • constructLookupsFeatures

      private void constructLookupsFeatures(Map lookups, String st, String lt, List<String> fids)
    • constructLookupsLanguage

      private void constructLookupsLanguage(Map lookups, String st, String lt, Map<String,Object> languages)
    • constructLookupsLanguages

      private void constructLookupsLanguages(Map lookups, String st, List<String> ll, Map<String,Object> languages)
    • constructLookups

      private Map constructLookups()
    • constructGDEFSubtables

      private List constructGDEFSubtables()
    • constructGDEFSubtable

      private GlyphSubtable constructGDEFSubtable(Object[] stp)
    • constructGSUBSubtables

      private List constructGSUBSubtables()
    • constructGSUBSubtable

      private GlyphSubtable constructGSUBSubtable(Object[] stp)
    • constructGPOSSubtables

      private List constructGPOSSubtables()
    • constructGPOSSubtable

      private GlyphSubtable constructGPOSSubtable(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 String toString(int[] ia)
      helper method for formatting an integer array for output