private void PopulateGsubData(Dictionary <string, Dictionary <List <int>, int> > gsubData,
                               LangSysTable langSysTable, FeatureListTable featureListTable,
                               LookupListTable lookupListTable)
 {
     FeatureRecord[] featureRecords = featureListTable.FeatureRecords;
     foreach (int featureIndex in langSysTable.FeatureIndices)
     {
         if (featureIndex < featureRecords.Length)
         {
             PopulateGsubData(gsubData, featureRecords[featureIndex], lookupListTable);
         }
     }
 }
        internal static GPosTable Load(BigEndianBinaryReader reader)
        {
            // GPOS Header, Version 1.0
            // +----------+-------------------+-----------------------------------------------------------+
            // | Type     | Name              | Description                                               |
            // +==========+===================+===========================================================+
            // | uint16   | majorVersion      | Major version of the GPOS table, = 1                      |
            // +----------+-------------------+-----------------------------------------------------------+
            // | uint16   | minorVersion      | Minor version of the GPOS table, = 0                      |
            // +----------+-------------------+-----------------------------------------------------------+
            // | Offset16 | scriptListOffset  | Offset to ScriptList table, from beginning of GPOS table  |
            // +----------+-------------------+-----------------------------------------------------------+
            // | Offset16 | featureListOffset | Offset to FeatureList table, from beginning of GPOS table |
            // +----------+-------------------+-----------------------------------------------------------+
            // | Offset16 | lookupListOffset  | Offset to LookupList table, from beginning of GPOS table  |
            // +----------+-------------------+-----------------------------------------------------------+

            // GPOS Header, Version 1.1
            // +----------+-------------------------+-------------------------------------------------------------------------------+
            // | Type     | Name                    | Description                                                                   |
            // +==========+=========================+===============================================================================+
            // | uint16   | majorVersion            | Major version of the GPOS table, = 1                                          |
            // +----------+-------------------------+-------------------------------------------------------------------------------+
            // | uint16   | minorVersion            | Minor version of the GPOS table, = 1                                          |
            // +----------+-------------------------+-------------------------------------------------------------------------------+
            // | Offset16 | scriptListOffset        | Offset to ScriptList table, from beginning of GPOS table                      |
            // +----------+-------------------------+-------------------------------------------------------------------------------+
            // | Offset16 | featureListOffset       | Offset to FeatureList table, from beginning of GPOS table                     |
            // +----------+-------------------------+-------------------------------------------------------------------------------+
            // | Offset16 | lookupListOffset        | Offset to LookupList table, from beginning of GPOS table                      |
            // +----------+-------------------------+-------------------------------------------------------------------------------+
            // | Offset32 | featureVariationsOffset | Offset to FeatureVariations table, from beginning of GPOS table (may be NULL) |
            // +----------+-------------------------+-------------------------------------------------------------------------------+
            ushort majorVersion = reader.ReadUInt16();
            ushort minorVersion = reader.ReadUInt16();

            ushort scriptListOffset        = reader.ReadOffset16();
            ushort featureListOffset       = reader.ReadOffset16();
            ushort lookupListOffset        = reader.ReadOffset16();
            uint   featureVariationsOffset = (minorVersion == 1) ? reader.ReadOffset32() : 0;

            // TODO: Optimization. Allow only reading the scriptList.
            var scriptList = ScriptList.Load(reader, scriptListOffset);

            var featureList = FeatureListTable.Load(reader, featureListOffset);

            var lookupList = LookupListTable.Load(reader, lookupListOffset);

            // TODO: Feature Variations.
            return(new GPosTable(scriptList, featureList, lookupList));
        }
        private void PopulateGsubData(Dictionary <string, Dictionary <List <int>, int> > gsubData,
                                      FeatureRecord featureRecord, LookupListTable lookupListTable)
        {
            LookupTable[] lookups = lookupListTable.Lookups;
            Dictionary <List <int>, int> glyphSubstitutionMap = new Dictionary <List <int>, int>();

            foreach (int lookupIndex in featureRecord.FeatureTable.LookupListIndices)
            {
                if (lookupIndex < lookups.Length)
                {
                    ExtractData(glyphSubstitutionMap, lookups[lookupIndex]);
                }
            }

            Debug.WriteLine("debug: *********** extracting GSUB data for the feature: "
                            + featureRecord.FeatureTag + ", glyphSubstitutionMap: "
                            + glyphSubstitutionMap);

            gsubData[featureRecord.FeatureTag] = glyphSubstitutionMap;
        }
 public GPosTable(ScriptList scriptList, FeatureListTable featureList, LookupListTable lookupList)
 {
     this.ScriptList  = scriptList;
     this.FeatureList = featureList;
     this.LookupList  = lookupList;
 }
        //private static readonly Log LOG = LogFactory.getLog(GlyphSubstitutionDataExtractor.class);

        public GsubData GetGsubData(Dictionary <string, ScriptTable> scriptList, FeatureListTable featureListTable, LookupListTable lookupListTable)
        {
            ScriptTableDetails scriptTableDetails = GetSupportedLanguage(scriptList);

            if (scriptTableDetails == null)
            {
                return(DefaultGsubData.NO_DATA_FOUND);
            }

            ScriptTable scriptTable = scriptTableDetails.ScriptTable;

            Dictionary <string, Dictionary <List <int>, int> > gsubData = new Dictionary <string, Dictionary <List <int>, int> >(StringComparer.Ordinal);

            // the starting point is really the scriptTags
            if (scriptTable.DefaultLangSysTable != null)
            {
                PopulateGsubData(gsubData, scriptTable.DefaultLangSysTable, featureListTable,
                                 lookupListTable);
            }
            foreach (LangSysTable langSysTable in scriptTable.LangSysTables.Values)
            {
                PopulateGsubData(gsubData, langSysTable, featureListTable, lookupListTable);
            }

            return(new MapBackedGsubData(scriptTableDetails.Language, scriptTableDetails.FeatureName, gsubData));
        }