Beispiel #1
0
        public static TrueTypeFont FromFile(string path)
        {
            using (var reader = new FontReader(File.OpenRead(path)))
            {
                var offsetTable = OffsetTable.FromReader(reader);
                var entries     = ReadTableRecords(reader, offsetTable);

                var cmap = ReadCmapTable(path, reader, entries);
                var name = ReadNameTable(path, reader, entries);
                var kern = ReadKernTable(reader, entries);

                return(new TrueTypeFont(path, offsetTable, entries, cmap, name, kern));
            }
        }
Beispiel #2
0
        public static TrueTypeFont FromStream(Stream stream)
        {
            using (var reader = new FontReader(stream))
            {
                var offsetTable = OffsetTable.FromReader(reader);
                var entries     = ReadTableRecords(reader, offsetTable);

                var cmap = ReadCmapTable(string.Empty, reader, entries);
                var name = ReadNameTable(string.Empty, reader, entries);
                var kern = ReadKernTable(reader, entries);

                return(new TrueTypeFont(string.Empty, offsetTable, entries, cmap, name, kern));
            }
        }
Beispiel #3
0
        public static bool TryGetTablePosition(FontReader reader, string tableName, out long offset)
        {
            reader.Seek(0);
            var offsetTable = OffsetTable.FromReader(reader);
            var entries     = ReadTableRecords(reader, offsetTable);

            if (entries.TryGetValue(tableName, out var cmapEntry))
            {
                offset = cmapEntry.Offset;
                return(true);
            }

            offset = 0;
            return(false);
        }