Beispiel #1
0
        private static bool Match <T>(
            int increment,
            T[] sequence,
            SkippingGlyphIterator iterator,
            Func <T, GlyphShapingData, bool> condition,
            Span <int> matches)
        {
            ushort position = iterator.Index;
            ushort offset   = iterator.Increment(increment);
            IGlyphShapingCollection collection = iterator.Collection;

            int i = 0;

            while (i < sequence.Length && i < MaxContextLength && offset < collection.Count)
            {
                if (!condition(sequence[i], collection.GetGlyphShapingData(offset)))
                {
                    break;
                }

                if (matches.Length == MaxContextLength)
                {
                    matches[i] = iterator.Index;
                }

                i++;
                offset = iterator.Next();
            }

            iterator.Index = position;
            return(i == sequence.Length);
        }
Beispiel #2
0
        public static bool ApplyChainedClassSequenceRule(
            SkippingGlyphIterator iterator,
            ChainedClassSequenceRuleTable rule,
            ClassDefinitionTable inputClassDefinitionTable,
            ClassDefinitionTable backtrackClassDefinitionTable,
            ClassDefinitionTable lookaheadClassDefinitionTable)
        {
            if (rule.BacktrackSequence.Length > 0 &&
                !MatchClassSequence(iterator, -rule.BacktrackSequence.Length, rule.BacktrackSequence, backtrackClassDefinitionTable))
            {
                return(false);
            }

            if (rule.InputSequence.Length > 0 &&
                !MatchClassSequence(iterator, 1, rule.InputSequence, inputClassDefinitionTable))
            {
                return(false);
            }

            if (rule.LookaheadSequence.Length > 0 &&
                !MatchClassSequence(iterator, 1 + rule.InputSequence.Length, rule.LookaheadSequence, lookaheadClassDefinitionTable))
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
 public static bool MatchSequence(SkippingGlyphIterator iterator, int increment, ushort[] sequence)
 => Match(
     increment,
     sequence,
     iterator,
     (component, data) => component == data.GlyphIds[0],
     default);
Beispiel #4
0
 public static bool MatchCoverageSequence(
     SkippingGlyphIterator iterator,
     CoverageTable[] coverageTable,
     int increment)
 => Match(
     increment,
     coverageTable,
     iterator,
     (component, data) => component.CoverageIndexOf(data.GlyphIds[0]) >= 0,
     default);
Beispiel #5
0
 public static bool MatchClassSequence(
     SkippingGlyphIterator iterator,
     int increment,
     ushort[] sequence,
     ClassDefinitionTable classDefinitionTable)
 => Match(
     increment,
     sequence,
     iterator,
     (component, data) => component == classDefinitionTable.ClassIndexOf(data.GlyphIds[0]),
     default);
Beispiel #6
0
        public static bool MatchInputSequence(SkippingGlyphIterator iterator, Tag feature, ushort increment, ushort[] sequence, Span <int> matches)
        => Match(
            increment,
            sequence,
            iterator,
            (component, data) =>
        {
            if (!ContainsFeatureTag(data.Features, feature))
            {
                return(false);
            }

            return(component == data.GlyphIds[0]);
        },
            matches);
Beispiel #7
0
        public static bool ApplyChainedSequenceRule(SkippingGlyphIterator iterator, ChainedSequenceRuleTable rule)
        {
            if (rule.BacktrackSequence.Length > 0 &&
                !MatchSequence(iterator, -rule.BacktrackSequence.Length, rule.BacktrackSequence))
            {
                return(false);
            }

            if (rule.InputSequence.Length > 0 &&
                !MatchSequence(iterator, 1, rule.InputSequence))
            {
                return(false);
            }

            if (rule.LookaheadSequence.Length > 0 &&
                !MatchSequence(iterator, 1 + rule.InputSequence.Length, rule.LookaheadSequence))
            {
                return(false);
            }

            return(true);
        }