예제 #1
0
        private Dictionary <string, OffsetEntry> ReadOffsetTables()
        {
            var tables = new Dictionary <string, OffsetEntry>();

            // DO NOT REARRANGE CALLS!
            _scalarType = _file.GetUint32();
            var numTables = _file.GetUint16();

            _searchRange   = _file.GetUint16();
            _entrySelector = _file.GetUint16();
            _rangeShift    = _file.GetUint16();

            for (int i = 0; i < numTables; i++)
            {
                var tag   = _file.GetString(4);
                var entry = new OffsetEntry {
                    Checksum = _file.GetUint32(),
                    Offset   = _file.GetUint32(),
                    Length   = _file.GetUint32()
                };
                tables.Add(tag, entry);

                /* if (tag != "head") {
                 *   if (CalculateTableChecksum(file, tables[tag].Offset, tables[tag].Length) != tables[tag].Checksum)
                 *       throw new Exception("Bad file format: checksum fail in offset tables");
                 * }*/
            }
            return(tables);
        }
예제 #2
0
        public TtfTableOS2(BinaryReader file, OffsetEntry table)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }
            file.Seek(table.Offset);

            // See https://docs.microsoft.com/en-gb/typography/opentype/spec/os2
            // See https://github.com/fontforge/fontforge/blob/master/fontforge/ttf.h#L467
            Version = file.GetUint16();

            switch (Version)
            {
            case 5:
                ReadVersion5(file);
                break;

            case 2:
            case 3:
            case 4:
                ReadVersion4(file);
                break;

            default: throw new Exception("OS/2 version not supported: " + Version);
            }
        }
예제 #3
0
        public TtfTableName(BinaryReader file, OffsetEntry table)
        {
            file.Seek(table.Offset);
            TableBase = table.Offset;

            // See https://docs.microsoft.com/en-gb/typography/opentype/spec/name
            Format = file.GetUint16();

            switch (Format)
            {
            case 0:
                ReadFormatZero(file);
                break;
            }
        }