public static OS2Data ReadOS2(DataReader reader, TableRecord[] tables) { SeekToTable(reader, tables, FourCC.OS_2, required: true); // skip over version, xAvgCharWidth reader.Skip(sizeof(short) * 2); var result = new OS2Data { Weight = (FontWeight)reader.ReadUInt16BE(), Stretch = (FontStretch)reader.ReadUInt16BE() }; // skip over fsType, ySubscriptXSize, ySubscriptYSize, ySubscriptXOffset, ySubscriptYOffset, // ySuperscriptXSize, ySuperscriptYSize, ySuperscriptXOffset, ySuperscriptXOffset reader.Skip(sizeof(short) * 9); result.StrikeoutSize = reader.ReadInt16BE(); result.StrikeoutPosition = reader.ReadInt16BE(); // skip over sFamilyClass, panose[10], ulUnicodeRange1-4, achVendID[4] reader.Skip(sizeof(short) + sizeof(int) * 4 + 14); // check various style flags var fsSelection = (FsSelectionFlags)reader.ReadUInt16BE(); result.Style = (fsSelection & FsSelectionFlags.Italic) != 0 ? FontStyle.Italic : (fsSelection & FsSelectionFlags.Bold) != 0 ? FontStyle.Bold : (fsSelection & FsSelectionFlags.Oblique) != 0 ? FontStyle.Oblique : FontStyle.Regular; result.IsWWSFont = (fsSelection & FsSelectionFlags.WWS) != 0; result.UseTypographicMetrics = (fsSelection & FsSelectionFlags.UseTypoMetrics) != 0; // skip over usFirstCharIndex, usLastCharIndex reader.Skip(sizeof(short) * 2); result.TypographicAscender = reader.ReadInt16BE(); result.TypographicDescender = reader.ReadInt16BE(); result.TypographicLineGap = reader.ReadInt16BE(); result.WinAscent = reader.ReadUInt16BE(); result.WinDescent = reader.ReadUInt16BE(); // skip over ulCodePageRange1-2 reader.Skip(sizeof(int) * 2); result.XHeight = reader.ReadInt16BE(); result.CapHeight = reader.ReadInt16BE(); return(result); }
public static OS2Data ReadOS2(DataReader reader, TableRecord[] tables) { SeekToTable(reader, tables, FourCC.OS_2, required: true); // skip over version, xAvgCharWidth reader.Skip(sizeof(short) * 2); var result = new OS2Data { Weight = (FontWeight)reader.ReadUInt16BE(), Stretch = (FontStretch)reader.ReadUInt16BE() }; // skip over fsType, ySubscriptXSize, ySubscriptYSize, ySubscriptXOffset, ySubscriptYOffset, // ySuperscriptXSize, ySuperscriptYSize, ySuperscriptXOffset, ySuperscriptXOffset reader.Skip(sizeof(short) * 9); result.StrikeoutSize = reader.ReadInt16BE(); result.StrikeoutPosition = reader.ReadInt16BE(); // skip over sFamilyClass, panose[10], ulUnicodeRange1-4, achVendID[4] reader.Skip(sizeof(short) + sizeof(int) * 4 + 14); // check various style flags var fsSelection = (FsSelectionFlags)reader.ReadUInt16BE(); result.Style = (fsSelection & FsSelectionFlags.Italic) != 0 ? FontStyle.Italic : (fsSelection & FsSelectionFlags.Bold) != 0 ? FontStyle.Bold : (fsSelection & FsSelectionFlags.Oblique) != 0 ? FontStyle.Oblique : FontStyle.Regular; result.IsWWSFont = (fsSelection & FsSelectionFlags.WWS) != 0; result.UseTypographicMetrics = (fsSelection & FsSelectionFlags.UseTypoMetrics) != 0; // skip over usFirstCharIndex, usLastCharIndex reader.Skip(sizeof(short) * 2); result.TypographicAscender = reader.ReadInt16BE(); result.TypographicDescender = reader.ReadInt16BE(); result.TypographicLineGap = reader.ReadInt16BE(); result.WinAscent = reader.ReadUInt16BE(); result.WinDescent = reader.ReadUInt16BE(); // skip over ulCodePageRange1-2 reader.Skip(sizeof(int) * 2); result.XHeight = reader.ReadInt16BE(); result.CapHeight = reader.ReadInt16BE(); return result; }