Exemplo n.º 1
0
        public override void Process(TrueTypeFont font)
        {
            var reader = new TrueTypeReader(Data);

            var version  = reader.ReadUShort();
            var length   = reader.ReadUShort();
            var coverage = reader.ReadUShort();

            NumberOfPairs = reader.ReadUShort();
            SearchRange   = reader.ReadUShort();
            EntrySelector = reader.ReadUShort();
            RangeShift    = reader.ReadUShort();

            Kernpairs = new Dictionary <uint, short>(NumberOfPairs);

            for (var i = 0; i < NumberOfPairs; i++)
            {
                var glyphPair = reader.ReadULong();
                var kernUnits = reader.ReadFWord();

                Kernpairs[glyphPair] = kernUnits;
            }

            reader.Dispose();
        }
Exemplo n.º 2
0
        public override void Process(TrueTypeFont font)
        {
            var reader = new TrueTypeReader(Data);

            Version            = reader.ReadFixed();
            Revision           = reader.ReadFixed();
            ChecksumAdjustment = reader.ReadULong();
            Magic                 = reader.ReadULong();
            Flags                 = reader.ReadUShort();
            UnitsPerEm            = reader.ReadUShort();
            DateCreated           = reader.ReadLongDateTime();
            DateModified          = reader.ReadLongDateTime();
            XMin                  = reader.ReadFWord();
            YMin                  = reader.ReadFWord();
            XMax                  = reader.ReadFWord();
            YMax                  = reader.ReadFWord();
            MacStyle              = reader.ReadUShort();
            LowestRecommendedPPEM = reader.ReadUShort();
            FontDirectionHint     = reader.ReadShort();
            IndexToLocFormat      = reader.ReadShort();
            GlyphDataFormat       = reader.ReadShort();

            reader.Dispose();
        }
Exemplo n.º 3
0
        public override void Process(TrueTypeFont font)
        {
            var reader = new TrueTypeReader(Data);

            Version            = reader.ReadUShort();
            EncodingTableCount = reader.ReadUShort();

            EncodingTables = new List <EncodingTableEntry>(EncodingTableCount);
            for (var i = 0; i < EncodingTableCount; i++)
            {
                EncodingTables.Add(new EncodingTableEntry()
                {
                    Platform = (Platform)reader.ReadUShort(),
                    Encoding = (Encoding)reader.ReadUShort(),
                    Offset   = reader.ReadULong()
                });
            }

            foreach (var encodingTable in EncodingTables)
            {
                reader.Seek(encodingTable.Offset);

                var format = (CmapSubtableType)reader.ReadUShort();
                var length = reader.ReadUShort();

                var subtableProcessorType = ImplementationTypeAttribute.GetTypeFromEnumValue(typeof(CmapSubtableType), format);

                if (subtableProcessorType == null)
                {
                    continue;
                }

                var subtableProcessor = Activator.CreateInstance(subtableProcessorType) as CharacterToGlyphSubtableBase;
                subtableProcessor.EncodingTableEntry = encodingTable;
                subtableProcessor.ReadData(reader, encodingTable.Offset, length);

                Subtables.Add(subtableProcessor);
            }

            ProcessSubtables(font);

            reader.Dispose();
        }
Exemplo n.º 4
0
        public override void Process(TrueTypeFont font)
        {
            var offsetFormat   = font.head.IndexToLocFormat;
            var numberOfGlyphs = Data.Length / ((offsetFormat + 1) * 2);

            Offsets = new Dictionary <ushort, uint>(numberOfGlyphs);

            var reader = new TrueTypeReader(Data);

            for (ushort i = 0; i < numberOfGlyphs; i++)
            {
                if ((LocationOffsetFormat)offsetFormat == LocationOffsetFormat.Short)
                {
                    Offsets[i] = reader.ReadUShort();
                }
                else
                {
                    Offsets[i] = reader.ReadULong();
                }
            }

            reader.Dispose();
        }