// TODO: read code page from "MstnFontConfig.xml": FontConfig/Fonts/ShxFontInfo/Name|CodePage internal override ShxGlyphCommandData Load(ByteReader reader) { var commandData = new ShxGlyphCommandData(); var twoByteRangePrefixes = new HashSet <Tuple <byte, byte> >(); reader.TryReadUInt16LittleEndian(out var estimatedItemCount); reader.TryReadUInt16LittleEndian(out var characterCount); reader.TryReadUInt16LittleEndian(out var rangeCount); for (int i = 0; i < rangeCount; i++) { reader.TryReadUInt16LittleEndian(out var rangeStart); reader.TryReadUInt16LittleEndian(out var rangeEnd); twoByteRangePrefixes.Add(Tuple.Create((byte)rangeStart, (byte)rangeEnd)); var rangeStartHex = rangeStart.ToString("X"); var rangeEndHex = rangeEnd.ToString("X"); } for (int i = 0; i < characterCount; i++) { if (reader.TryReadUInt16LittleEndian(out var characterCode) && reader.TryReadUInt16LittleEndian(out var characterByteCount) && reader.TryReadUInt32LittleEndian(out var characterOffset)) { if (characterCode == 0 && characterByteCount == 0 && characterOffset == 0) { // occasional null entries continue; } var characterReader = reader.FromOffset((int)characterOffset); var startPos = characterReader.Offset; var expectedEnd = startPos + characterByteCount; if (characterCode == 0) { TryReadFontData(characterReader, characterByteCount); } else { var glyphName = characterReader.ReadNullTerminatedString(); var glyphCommands = ShxGlyph.ParseCommands(characterReader, FontEncoding, isBigFont: true); commandData.AddGlyphCommands(characterCode, glyphName, glyphCommands); } var remainingBytes = expectedEnd - characterReader.Offset; Debug.Assert(remainingBytes == 0); } } return(commandData); }
internal override ShxGlyphCommandData Load(ByteReader reader) { var commandData = new ShxGlyphCommandData(); if (reader.TryReadUInt16LittleEndian(out var characterCount)) { for (int i = 0; i < characterCount; i++) { if (reader.TryReadUInt16LittleEndian(out var characterCode) && reader.TryReadUInt16LittleEndian(out var characterByteCount)) { var startPos = reader.Offset; var expectedEnd = startPos + characterByteCount; if (characterCode == 0) { TryReadFontData(reader); } else { var character = (char)characterCode; var glyphName = reader.ReadNullTerminatedString(); if (string.IsNullOrEmpty(glyphName)) { glyphName = character.ToString(); } var glyphCommands = ShxGlyph.ParseCommands(reader, FontEncoding, isBigFont: false); commandData.AddGlyphCommands(characterCode, glyphName, glyphCommands); } var remainingBytes = Math.Max(0, expectedEnd - reader.Offset); Debug.Assert(remainingBytes == 0); } } } return(commandData); }
private void AddGlyph(ushort code, ShxGlyph glyph) => _glyphs.Add(code, glyph);
public ShxGlyph CreateGlyph(string name) { var glyph = new ShxGlyph(name, Paths, Width, Height); return(glyph); }