private static uint ReadNextOffset(BinaryReader reader, LocaTableVersion version) { switch (version) { case LocaTableVersion.Long: return(DataTypeConverter.ReadULong(reader)); case LocaTableVersion.Short: return((uint)(DataTypeConverter.ReadUShort(reader) * 2)); default: throw new NotImplementedException(); } }
public static PostTable Deserialize(BinaryReader reader, long startOffset) { reader.BaseStream.Position = startOffset; return(new PostTable { Version = DataTypeConverter.ReadFixed(reader), ItalicAngle = DataTypeConverter.ReadFixed(reader), UnderlinePosition = DataTypeConverter.ReadShort(reader), UnderlineThickness = DataTypeConverter.ReadShort(reader), IsFixedPitch = DataTypeConverter.ReadULong(reader), MinMemType42 = DataTypeConverter.ReadULong(reader), MaxMemType42 = DataTypeConverter.ReadULong(reader), MinMemType1 = DataTypeConverter.ReadULong(reader), MaxMemType1 = DataTypeConverter.ReadULong(reader) }); }
public static Format12Subtable Deserialize(BinaryReader reader, long startOffset) { var table = new Format12Subtable(); reader.BaseStream.Position = startOffset + 2 * DataTypeLength.UShort + DataTypeLength.ULong; table.Language = DataTypeConverter.ReadULong(reader); var numberOfGroups = DataTypeConverter.ReadULong(reader); for (var i = 0; i < numberOfGroups; i++) { var startCharCode = DataTypeConverter.ReadULong(reader); var endCharCode = DataTypeConverter.ReadULong(reader); var startGlyphId = DataTypeConverter.ReadULong(reader); for (var j = startCharCode; j <= endCharCode; j++) { table.CharGlyphIdMap[j] = startGlyphId + j - startCharCode; } } return(table); }
public static CmapTable Deserialize(BinaryReader reader, long startOffset) { var table = new CmapTable(); reader.BaseStream.Position = startOffset; table.Version = DataTypeConverter.ReadUShort(reader); var numberOfSubtables = DataTypeConverter.ReadUShort(reader); var platformIds = new ushort[numberOfSubtables]; var encodingIds = new ushort[numberOfSubtables]; var offsets = new uint[numberOfSubtables]; for (var i = 0; i < numberOfSubtables; i++) { platformIds[i] = DataTypeConverter.ReadUShort(reader); encodingIds[i] = DataTypeConverter.ReadUShort(reader); offsets[i] = DataTypeConverter.ReadULong(reader); } var offsetSubtableMap = new Dictionary <uint, CmapSubtable>(); for (var i = 0; i < numberOfSubtables; i++) { if (offsetSubtableMap.ContainsKey(offsets[i])) // Multiple map { offsetSubtableMap[offsets[i]].Environments.Add(new Environment { EncodingId = encodingIds[i], PlatformId = platformIds[i], SubtableOffset = offsets[i] }); continue; } var subtableStartOffset = reader.BaseStream.Position = startOffset + offsets[i]; var format = DataTypeConverter.ReadUShort(reader); CmapSubtable subtable; switch (format) { case 0: subtable = Format0Subtable.Deserialize(reader, subtableStartOffset); break; case 4: subtable = Format4Subtable.Deserialize(reader, subtableStartOffset); break; case 6: subtable = Format6Subtable.Deserialize(reader, subtableStartOffset); break; case 12: subtable = Format12Subtable.Deserialize(reader, subtableStartOffset); break; default: throw new NotImplementedException(); } subtable.Environments.Add(new Environment { PlatformId = platformIds[i], EncodingId = encodingIds[i], SubtableOffset = offsets[i] }); offsetSubtableMap[offsets[i]] = subtable; table.Subtables.Add(subtable); } return(table); }