예제 #1
0
        private IGlyphTransformationTable ParseMarkToMarkPositioningTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type   = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.MarkToMarkPositioningSubtable");
            dynamic table  = new AccessPrivateWrapper(type.Instantiate(subTableOffset));
            ushort  format = table.Format(fontTable.Wrapped);

            if (format != 1)
            {
                throw new UnknownTableFormatException(type, format);
            }

            dynamic mark1ArrayTable = new AccessPrivateWrapper(table.Mark1Array(fontTable.Wrapped));
            dynamic base2ArrayTable = new AccessPrivateWrapper(table.Marks2(fontTable.Wrapped));

            // MarkToMark is functionally identical to MarkToBase -> compiler can treat MTM as MTB
            return(new MarkToBasePositioningTable
            {
                MarkCoverage = (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Mark1Coverage(fontTable.Wrapped))),
                BaseCoverage = (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Mark2Coverage(fontTable.Wrapped))),
                MarkAnchorPoints = this.GetEnumerableFromInternalList(
                    () => fontTable.GetUShort(mark1ArrayTable.offset),
                    i =>
                    new Tuple <ushort, AnchorPoint>(
                        (ushort)mark1ArrayTable.Class(fontTable.Wrapped, i),
                        (AnchorPoint)this.ParseAnchor(fontTable, new AccessPrivateWrapper(mark1ArrayTable.MarkAnchor(fontTable.Wrapped, i)))
                        )).ToList(),
                BaseAnchorPoints = this.GetEnumerableFromInternalList(
                    () => fontTable.GetUShort(base2ArrayTable.offset),
                    i => this.GetEnumerableFromInternalList(
                        () => table.Mark1ClassCount(fontTable.Wrapped),
                        j => (AnchorPoint)this.ParseAnchor(fontTable, new AccessPrivateWrapper(base2ArrayTable.Anchor(fontTable.Wrapped, i, table.Mark1ClassCount(fontTable.Wrapped), j)))
                        ).ToList()
                    ).ToList(),
                LookupFlags = lookupFlags
            });
        }