private List <int> ApplyGsubFeature(ScriptFeature scriptFeature, List <int> originalGlyphs)
        {
            GlyphArraySplitter glyphArraySplitter = new GlyphArraySplitterRegexImpl(scriptFeature.AllGlyphIdsForSubstitution);

            List <List <int> > tokens = glyphArraySplitter.Split(originalGlyphs);

            List <int> gsubProcessedGlyphs = new List <int>();

            foreach (List <int> chunk in tokens)
            {
                if (scriptFeature.CanReplaceGlyphs(chunk))
                {
                    // gsub system kicks in, you get the glyphId directly
                    int glyphId = scriptFeature.GetReplacementForGlyphs(chunk);
                    gsubProcessedGlyphs.Add(glyphId);
                }
                else
                {
                    gsubProcessedGlyphs.AddAll(chunk);
                }
            }

            Debug.WriteLine($"debug: originalGlyphs: {originalGlyphs}, gsubProcessedGlyphs: {gsubProcessedGlyphs}");

            return(gsubProcessedGlyphs);
        }
        private List <int> GetBeforeHalfGlyphIds()
        {
            List <int> glyphIds = new List <int>();

            foreach (char character in BEFORE_HALF_CHARS)
            {
                glyphIds.Add(GetGlyphId(character));
            }

            if (gsubData.IsFeatureSupported(INIT_FEATURE))
            {
                ScriptFeature feature = gsubData.GetFeature(INIT_FEATURE);
                foreach (List <int> glyphCluster in feature.AllGlyphIdsForSubstitution)
                {
                    glyphIds.Add(feature.GetReplacementForGlyphs(glyphCluster));
                }
            }

            return(glyphIds);
        }
        public List <int> ApplyTransforms(List <int> originalGlyphIds)
        {
            List <int> intermediateGlyphsFromGsub = originalGlyphIds;

            foreach (string feature in FEATURES_IN_ORDER)
            {
                if (!gsubData.IsFeatureSupported(feature))
                {
                    Debug.WriteLine("debug: the feature " + feature + " was not found");
                    continue;
                }

                Debug.WriteLine("debug: applying the feature " + feature);

                ScriptFeature scriptFeature = gsubData.GetFeature(feature);

                intermediateGlyphsFromGsub = ApplyGsubFeature(scriptFeature, intermediateGlyphsFromGsub);
            }

            return(RepositionGlyphs(intermediateGlyphsFromGsub));
        }