public static uint[] ReadTTCHeader(DataReader reader) { // read the file header; if we have a collection, we want to // figure out where all the different faces are in the file // if we don't have a collection, there's just one font in the file var tag = reader.ReadUInt32(); if (tag != FourCC.Ttcf) return new[] { 0u }; // font file is a TrueType collection; read the TTC header reader.Skip(4); // version number var count = reader.ReadUInt32BE(); if (count == 0 || count > MaxFontsInCollection) throw new InvalidFontException("Invalid TTC header"); var offsets = new uint[count]; for (int i = 0; i < count; i++) offsets[i] = reader.ReadUInt32BE(); return offsets; }
public static TableRecord[] ReadFaceHeader(DataReader reader) { var tag = reader.ReadUInt32BE(); if (tag != TTFv1 && tag != TTFv2 && tag != FourCC.True) throw new InvalidFontException("Unknown or unsupported sfnt version."); var tableCount = reader.ReadUInt16BE(); reader.Skip(6); // skip the rest of the header // read each font table descriptor var tables = new TableRecord[tableCount]; for (int i = 0; i < tableCount; i++) { tables[i] = new TableRecord { Tag = reader.ReadUInt32(), CheckSum = reader.ReadUInt32BE(), Offset = reader.ReadUInt32BE(), Length = reader.ReadUInt32BE(), }; } return tables; }