Пример #1
0
        public override bool TransformOne(GlyphLine line)
        {
            if (line.idx >= line.end)
            {
                return(false);
            }
            Glyph g       = line.Get(line.idx);
            bool  changed = false;

            if (!openReader.IsSkip(g.GetCode(), lookupFlag))
            {
                int[] substSequence = substMap.Get(g.GetCode());
                if (substSequence != null)
                {
                    // The use of multiple substitution for deletion of an input glyph is prohibited. GlyphCount should always be greater than 0.
                    if (substSequence.Length > 0)
                    {
                        line.SubstituteOneToMany(openReader, substSequence);
                        changed = true;
                    }
                }
            }
            line.idx++;
            return(changed);
        }
Пример #2
0
            public override bool TransformOne(GlyphLine line)
            {
                if (line.idx >= line.end || line.idx < line.start)
                {
                    return(false);
                }
                bool  changed = false;
                Glyph g1      = line.Get(line.idx);
                IDictionary <int, GposLookupType2.PairValueFormat> m = gposMap.Get(g1.GetCode());

                if (m != null)
                {
                    OpenTableLookup.GlyphIndexer gi = new OpenTableLookup.GlyphIndexer();
                    gi.line = line;
                    gi.idx  = line.idx;
                    gi.NextGlyph(openReader, lookupFlag);
                    if (gi.glyph != null)
                    {
                        GposLookupType2.PairValueFormat pv = m.Get(gi.glyph.GetCode());
                        if (pv != null)
                        {
                            Glyph g2 = gi.glyph;
                            line.Set(line.idx, new Glyph(g1, 0, 0, pv.first.XAdvance, pv.first.YAdvance, 0));
                            line.Set(gi.idx, new Glyph(g2, 0, 0, pv.second.XAdvance, pv.second.YAdvance, 0));
                            line.idx = gi.idx;
                            changed  = true;
                        }
                    }
                }
                return(changed);
            }
Пример #3
0
 public override bool TransformOne(GlyphLine line) {
     if (line.idx >= line.end) {
         return false;
     }
     Glyph g = line.Get(line.idx);
     bool changed = false;
     if (!openReader.IsSkip(g.GetCode(), lookupFlag)) {
         int substCode = substMap.Get(g.GetCode());
         // there is no need to substitute a symbol with itself
         if (substCode != 0 && substCode != g.GetCode()) {
             line.SubstituteOneToOne(openReader, substCode);
             changed = true;
         }
     }
     line.idx++;
     return changed;
 }
Пример #4
0
        public override bool TransformOne(GlyphLine line)
        {
            //TODO >
            if (line.idx >= line.end)
            {
                return(false);
            }
            bool  changed = false;
            Glyph g       = line.Get(line.idx);
            bool  match   = false;

            if (ligatures.ContainsKey(g.GetCode()) && !openReader.IsSkip(g.GetCode(), lookupFlag))
            {
                OpenTableLookup.GlyphIndexer gidx = new OpenTableLookup.GlyphIndexer();
                gidx.line = line;
                IList <int[]> ligs = ligatures.Get(g.GetCode());
                foreach (int[] lig in ligs)
                {
                    match    = true;
                    gidx.idx = line.idx;
                    for (int j = 1; j < lig.Length; ++j)
                    {
                        gidx.NextGlyph(openReader, lookupFlag);
                        if (gidx.glyph == null || gidx.glyph.GetCode() != lig[j])
                        {
                            match = false;
                            break;
                        }
                    }
                    if (match)
                    {
                        line.SubstituteManyToOne(openReader, lookupFlag, lig.Length - 1, lig[0]);
                        break;
                    }
                }
            }
            if (match)
            {
                changed = true;
            }
            line.idx++;
            return(changed);
        }
Пример #5
0
        public override bool TransformOne(GlyphLine line)
        {
            if (line.idx >= line.end)
            {
                return(false);
            }
            Glyph g       = line.Get(line.idx);
            bool  changed = false;

            if (!openReader.IsSkip(g.GetCode(), lookupFlag))
            {
                int substCode = substMap.Get(g.GetCode());
                if (substCode != 0)
                {
                    line.SubstituteOneToOne(openReader, substCode);
                    changed = true;
                }
            }
            line.idx++;
            return(changed);
        }
Пример #6
0
            public override bool TransformOne(GlyphLine line)
            {
                if (line.idx >= line.end || line.idx < line.start)
                {
                    return(false);
                }
                Glyph g1 = line.Get(line.idx);

                if (!coverageSet.Contains(g1.GetCode()))
                {
                    return(false);
                }
                int c1 = classDef1.GetOtfClass(g1.GetCode());

                GposLookupType2.PairValueFormat[] pvs = posSubs.Get(c1);
                if (pvs == null)
                {
                    return(false);
                }
                OpenTableLookup.GlyphIndexer gi = new OpenTableLookup.GlyphIndexer();
                gi.line = line;
                gi.idx  = line.idx;
                gi.NextGlyph(openReader, lookupFlag);
                if (gi.glyph == null)
                {
                    return(false);
                }
                Glyph g2 = gi.glyph;
                int   c2 = classDef2.GetOtfClass(g2.GetCode());

                if (c2 >= pvs.Length)
                {
                    return(false);
                }
                GposLookupType2.PairValueFormat pv = pvs[c2];
                line.Set(line.idx, new Glyph(g1, 0, 0, pv.first.XAdvance, pv.first.YAdvance, 0));
                line.Set(gi.idx, new Glyph(g2, 0, 0, pv.second.XAdvance, pv.second.YAdvance, 0));
                line.idx = gi.idx;
                return(true);
            }
Пример #7
0
        /// <summary>Gets a most preferable context rule that matches the line at current position.</summary>
        /// <remarks>
        /// Gets a most preferable context rule that matches the line at current position. If no matching context rule is found,
        /// it returns null.
        /// <br /><br />
        /// NOTE: if matching context rule is found, the <code>GlyphLine.start</code> and <code>GlyphLine.end</code> will be
        /// changed in such way, that they will point at start and end of the matching context glyph sequence inside the glyph line.
        /// </remarks>
        /// <param name="line">a line, which is to be checked if it matches some context.</param>
        /// <returns>matching context rule or null, if none was found.</returns>
        public virtual ContextualSubstRule GetMatchingContextRule(GlyphLine line)
        {
            if (line.idx >= line.end)
            {
                return(null);
            }
            Glyph g = line.Get(line.idx);
            IList <ContextualSubstRule> rules = GetSetOfRulesForStartGlyph(g.GetCode());

            foreach (ContextualSubstRule rule in rules)
            {
                int lastGlyphIndex = CheckIfContextMatch(line, rule);
                if (lastGlyphIndex != -1)
                {
                    line.start = line.idx;
                    line.end   = lastGlyphIndex + 1;
                    return(rule);
                }
            }
            return(null);
        }