Esempio n. 1
0
        private IGlyphTransformationTable ParseCoverageChainingSubstitutionTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type  = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.CoverageChainingSubtable");
            dynamic table = new AccessPrivateWrapper(TypeExtensions.Instantiate(type, fontTable.Wrapped, subTableOffset));

            dynamic contextualLookupTable = new AccessPrivateWrapper(table.ContextualLookups(fontTable.Wrapped));

            return(new ChainingCoverageContextSubstitutionTable
            {
                LookbackCoverages = this.GetEnumerableFromInternalList(
                    () => table.BacktrackGlyphCount(fontTable.Wrapped),
                    i => (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.BacktrackCoverage(fontTable.Wrapped, i)))).ToList(),
                ContextCoverages = this.GetEnumerableFromInternalList(
                    () => table.InputGlyphCount(fontTable.Wrapped),
                    i => (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.InputCoverage(fontTable.Wrapped, i)))).ToList(),
                LookaheadCoverages = this.GetEnumerableFromInternalList(
                    () => table.LookaheadGlyphCount(fontTable.Wrapped),
                    i => (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.LookaheadCoverage(fontTable.Wrapped, i)))).ToList(),
                TransformationSets = this.GetEnumerableFromInternalList(
                    () => contextualLookupTable.recordCount,
                    i => new ContextTransformationSet
                {
                    FirstGlyphIndex = contextualLookupTable.SequenceIndex(fontTable.Wrapped, i),
                    Transformations = this.GetTransformationTablesByLookupIndex(fontTable, contextualLookupTable.LookupIndex(fontTable.Wrapped, i))
                }).ToList(),
                LookupFlags = lookupFlags
            });
        }
Esempio n. 2
0
        private ChainingContextTransformationRule ParseChainingTransformationRule(dynamic fontTable, dynamic rule, Func <dynamic, int, ushort> idProjection, ushort firstInputId)
        {
            const int GlyphIdSize = 2;

            // Load the lookback
            var lookBackCount = rule.GlyphCount(fontTable.Wrapped, rule.offset);
            int currentOffset = rule.offset + rule.sizeCount;

            var lookBackGlyphIds = this.GetEnumerableFromInternalList(
                () => lookBackCount,
                i => (ushort)idProjection(rule, (i * GlyphIdSize) + currentOffset)).ToList();

            currentOffset += lookBackCount * GlyphIdSize;

            // Load the context
            var contextCount = rule.GlyphCount(fontTable.Wrapped, currentOffset);

            currentOffset += rule.sizeCount;

            // The first element of the context comes from index of the rule set
            var contextGlyphIds = this.GetEnumerableFromInternalList(
                () => (ushort)(contextCount - 1),
                i => (ushort)idProjection(rule, (i * GlyphIdSize) + currentOffset)).Prepend(firstInputId).ToList();

            currentOffset += (contextCount - 1) * GlyphIdSize;

            // Load the context
            var lookAheadCount = rule.GlyphCount(fontTable.Wrapped, currentOffset);

            currentOffset += rule.sizeCount;

            var lookAheadGlyphIds = this.GetEnumerableFromInternalList(
                () => lookAheadCount,
                i => (ushort)idProjection(rule, (i * GlyphIdSize) + currentOffset)).ToList();

            currentOffset += lookAheadCount * GlyphIdSize;

            // Load the substitution lookup records
            var lookupSubstitutionRecordCount = fontTable.GetUShort(currentOffset);

            dynamic contextualLookupsTable = new AccessPrivateWrapper(rule.ContextualLookups(fontTable.Wrapped, currentOffset));

            return(new ChainingContextTransformationRule
            {
                Lookback = lookBackGlyphIds,
                Context = contextGlyphIds,
                Lookahead = lookAheadGlyphIds,
                TransformationSets = this.GetEnumerableFromInternalList(
                    () => lookupSubstitutionRecordCount,
                    i => new ContextTransformationSet
                {
                    FirstGlyphIndex = contextualLookupsTable.SequenceIndex(fontTable.Wrapped, i),
                    Transformations = this.GetTransformationTablesByLookupIndex(fontTable, contextualLookupsTable.LookupIndex(fontTable.Wrapped, i))
                }).ToList()
            });
        }
Esempio n. 3
0
        private ContextTransformationRule ParseContextTransformationRule(dynamic fontTable, dynamic rule, Func <dynamic, int, ushort> idProjection)
        {
            dynamic contextualLookupsTable = new AccessPrivateWrapper(rule.ContextualLookups(fontTable.Wrapped));

            return(new ContextTransformationRule
            {
                Context = this.GetEnumerableFromInternalList(
                    () => rule.GlyphCount(fontTable.Wrapped),
                    i => (ushort)idProjection(rule, i)).ToList(),
                TransformationSets = this.GetEnumerableFromInternalList(
                    () => rule.SubstCount(fontTable.Wrapped),
                    i => new ContextTransformationSet
                {
                    FirstGlyphIndex = contextualLookupsTable.SequenceIndex(fontTable.Wrapped, i),
                    Transformations = this.GetTransformationTablesByLookupIndex(fontTable, contextualLookupsTable.LookupIndex(fontTable.Wrapped, i))
                }).ToList()
            });
        }