Beispiel #1
0
        public static NameTable Read(BinaryReaderFont reader)
        {
            NameTable value = new NameTable {
                format       = reader.ReadUInt16(),
                count        = reader.ReadUInt16(),
                stringOffset = reader.ReadUInt16(),
            };

            value.nameRecord = NameRecord.ReadArray(reader, value.count);
            if (value.format >= 1)
            {
                value.langTagCount  = reader.ReadUInt16();
                value.langTagRecord = LangTagRecord.ReadArray(reader, value.langTagCount);
            }
            long start = reader.Position;

            for (int i = 0; i < value.count; i++)
            {
                NameRecord record = value.nameRecord[i];
                reader.Position = start + record.offset;
                record.text     = reader.ReadString(record.length, GetEncoding(record));
            }
            if (value.format >= 1)
            {
                for (int i = 0; i < value.langTagCount; i++)
                {
                    LangTagRecord record = value.langTagRecord[i];
                    reader.Position = start + record.offset;
                    record.text     = reader.ReadString(record.length, Encoding.BigEndianUnicode);
                }
            }
            return(value);
        }
Beispiel #2
0
        protected void ReadName(BinaryReaderFont reader)
        {
            CFFIndex index = CFFIndex.Read(reader);

            int[] offset = index.ReadAllOffsets(reader);
            names = new string[index.count];
            int length = offset.Length - 1;

            for (int i = 0; i < length; i++)
            {
                int byteSize = offset[i + 1] - offset[i];
                names[i] = reader.ReadString(byteSize);
            }
        }
Beispiel #3
0
        protected void ReadString(BinaryReaderFont reader)
        {
            CFFIndex index = CFFIndex.Read(reader);

            int[] offset = index.ReadAllOffsets(reader);
            //Console.WriteLine("string index: {0}", index);
            strings = new string[index.count];
            int length = offset.Length - 1;

            for (int i = 0; i < length; i++)
            {
                int byteSize = offset[i + 1] - offset[i];
                //value.strings[i] = value.ConvertString(reader.ReadBytes(length));
                strings[i] = reader.ReadString(byteSize);
            }
        }
Beispiel #4
0
        public static PostTable Read(BinaryReaderFont reader, TableRecord record)
        {
            PostTable value = new PostTable {
                version            = reader.ReadFixed(),
                italicAngle        = reader.ReadFixed(),
                underlinePosition  = reader.ReadFWORD(),
                underlineThickness = reader.ReadFWORD(),
                isFixedPitch       = reader.ReadUInt32(),
                minMemType42       = reader.ReadUInt32(),
                maxMemType42       = reader.ReadUInt32(),
                minMemType1        = reader.ReadUInt32(),
                maxMemType1        = reader.ReadUInt32(),
            };

            if (value.version == 0x20000)
            {
                value.numGlyphs      = reader.ReadUInt16();
                value.glyphNameIndex = reader.ReadUInt16Array(value.numGlyphs);
                int remain = (int)record.length - 34;
                remain -= value.numGlyphs * 2;
                List <string> names = new List <string>();
                while (remain > 0)
                {
                    byte nameLength = reader.ReadByte();
                    if (nameLength == 0)
                    {
                        break;
                    }
                    string name = reader.ReadString(nameLength);
                    remain -= nameLength + 1;
                    names.Add(name);
                }
                value.names = names.ToArray();
            }
            return(value);
        }