Example #1
0
        /// <summary>
        ///     Reads the contents of the "kern" table from the current position
        ///     in the supplied stream.
        /// </summary>
        /// <param name="reader"></param>
        protected internal override void Read(FontFileReader reader)
        {
            FontFileStream stream = reader.Stream;

            // Skip version field
            stream.Skip(PrimitiveSizes.UShort);

            // Number of subtables
            int numTables = stream.ReadUShort();

            for (int i = 0; i < numTables; i++)
            {
                // Another pesky version field
                stream.Skip(PrimitiveSizes.UShort);

                // Length of the subtable, in bytes (including header).
                ushort length = stream.ReadUShort();

                // Type of information is contained in this table.
                ushort coverage = stream.ReadUShort();

                // Only interested in horiztonal kerning values in format 0
                if ((coverage & HoriztonalMask) == 1 &&
                    (coverage & MinimumMask) == 0 &&
                    ((coverage >> 8) == 0))
                {
                    // The number of kerning pairs in the table.
                    int numPairs = stream.ReadUShort();

                    hasKerningInfo = true;
                    pairs          = new KerningPairs(numPairs);

                    // Skip pointless shit
                    stream.Skip(3 * PrimitiveSizes.UShort);

                    for (int j = 0; j < numPairs; j++)
                    {
                        pairs.Add(
                            stream.ReadUShort(), // Left glyph index
                            stream.ReadUShort(), // Right glyph index
                            stream.ReadFWord()); // Kerning amount
                    }
                }
                else
                {
                    stream.Skip(length - 3 * PrimitiveSizes.UShort);
                }
            }
        }
Example #2
0
        /// <summary>
        ///     Reads the contents of the "kern" table from the current position 
        ///     in the supplied stream.
        /// </summary>
        /// <param name="reader"></param>
        protected internal override void Read(FontFileReader reader) {
            FontFileStream stream = reader.Stream;

            // Skip version field
            stream.Skip(PrimitiveSizes.UShort);

            // Number of subtables
            int numTables = stream.ReadUShort();

            for (int i = 0; i < numTables; i++) {
                // Another pesky version field
                stream.Skip(PrimitiveSizes.UShort);

                // Length of the subtable, in bytes (including header). 
                ushort length = stream.ReadUShort();

                // Type of information is contained in this table.
                ushort coverage = stream.ReadUShort();

                // Only interested in horiztonal kerning values in format 0
                if ((coverage & HoriztonalMask) == 1 &&
                    (coverage & MinimumMask) == 0 &&
                    ((coverage >> 8) == 0)) {
                    // The number of kerning pairs in the table.
                    int numPairs = stream.ReadUShort();

                    hasKerningInfo = true;
                    pairs = new KerningPairs(numPairs);

                    // Skip pointless shit
                    stream.Skip(3*PrimitiveSizes.UShort);

                    for (int j = 0; j < numPairs; j++) {
                        pairs.Add(
                            stream.ReadUShort(), // Left glyph index
                            stream.ReadUShort(), // Right glyph index
                            stream.ReadFWord()); // Kerning amount
                    }

                }
                else {
                    stream.Skip(length - 3*PrimitiveSizes.UShort);
                }
            }
        }
Example #3
0
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="pairs">Kerning pairs read from the TrueType font file.</param>
 /// <param name="converter">Class to convert from TTF to PDF units.</param>
 internal GdiKerningPairs(KerningPairs pairs, PdfUnitConverter converter) {
     this.pairs = pairs;
     this.converter = converter;
 }