private static CompactFontFormatFormat1Encoding ReadFormat1Encoding(CompactFontFormatData data, ICompactFontFormatCharset charset, IReadOnlyList <string> stringIndex, byte format) { var numberOfRanges = data.ReadCard8(); var fromRanges = new List <(int code, int sid, string str)>(); var gid = 1; for (var i = 0; i < numberOfRanges; i++) { int rangeFirst = data.ReadCard8(); int rangeLeft = data.ReadCard8(); for (var j = 0; j < 1 + rangeLeft; j++) { var sid = charset.GetStringIdByGlyphId(gid); var code = rangeFirst + j; var str = ReadString(sid, stringIndex); fromRanges.Add((code, sid, str)); gid++; } } IReadOnlyList <CompactFontFormatBuiltInEncoding.Supplement> supplements = new List <CompactFontFormatBuiltInEncoding.Supplement>(); if (HasSupplement(format)) { supplements = ReadSupplement(data, stringIndex); } return(new CompactFontFormatFormat1Encoding(numberOfRanges, fromRanges, supplements)); }
private static CompactFontFormatFormat0Encoding ReadFormat0Encoding(CompactFontFormatData data, ICompactFontFormatCharset charset, IReadOnlyList <string> stringIndex, byte format) { var numberOfCodes = data.ReadCard8(); var values = new List <(int code, int sid, string str)>(); for (var i = 1; i <= numberOfCodes; i++) { var code = data.ReadCard8(); var sid = charset.GetStringIdByGlyphId(i); var str = ReadString(sid, stringIndex); values.Add((code, sid, str)); } IReadOnlyList <CompactFontFormatBuiltInEncoding.Supplement> supplements = new List <CompactFontFormatBuiltInEncoding.Supplement>(); if (HasSupplement(format)) { supplements = ReadSupplement(data, stringIndex); } return(new CompactFontFormatFormat0Encoding(values, supplements)); }