private static string[] GetGlyphNamesByFormat(TrueTypeDataBytes data, BasicMaximumProfileTable maximumProfileTable, float formatType) { string[] glyphNames; if (Math.Abs(formatType - 1) < float.Epsilon) { glyphNames = new string[WindowsGlyphList4.NumberOfMacGlyphs]; for (var i = 0; i < WindowsGlyphList4.MacGlyphNames.Count; i++) { glyphNames[i] = WindowsGlyphList4.MacGlyphNames[i]; } } else if (Math.Abs(formatType - 2) < float.Epsilon) { glyphNames = GetFormat2GlyphNames(data); } else if (Math.Abs(formatType - 2.5) < float.Epsilon) { var glyphNameIndex = new int[maximumProfileTable?.NumberOfGlyphs ?? 0]; for (var i = 0; i < glyphNameIndex.Length; i++) { var offset = data.ReadSignedByte(); glyphNameIndex[i] = i + 1 + offset; } glyphNames = new string[glyphNameIndex.Length]; for (var i = 0; i < glyphNames.Length; i++) { var name = WindowsGlyphList4.MacGlyphNames[glyphNameIndex[i]]; if (name != null) { glyphNames[i] = name; } } } else if (Math.Abs(formatType - 3) < float.Epsilon) { glyphNames = new string[0]; } else { throw new InvalidOperationException($"Format type {formatType} is not supported for the PostScript table."); } return(glyphNames); }
private static string[] GetGlyphNamesByFormat(TrueTypeDataBytes data, BasicMaximumProfileTable maximumProfileTable, float formatType) { string[] glyphNames; if (Math.Abs(formatType - 1) < float.Epsilon) { glyphNames = new string[WindowsGlyphList4.NumberOfMacGlyphs]; for (var i = 0; i < WindowsGlyphList4.MacGlyphNames.Count; i++) { glyphNames[i] = WindowsGlyphList4.MacGlyphNames[i]; } } else if (Math.Abs(formatType - 2) < float.Epsilon) { glyphNames = GetFormat2GlyphNames(data); } else if (Math.Abs(formatType - 2.5) < float.Epsilon) { var glyphNameIndex = new int[maximumProfileTable?.NumberOfGlyphs ?? 0]; for (var i = 0; i < glyphNameIndex.Length; i++) { var offset = data.ReadSignedByte(); glyphNameIndex[i] = i + 1 + offset; } glyphNames = new string[glyphNameIndex.Length]; for (var i = 0; i < glyphNames.Length; i++) { var name = WindowsGlyphList4.MacGlyphNames[glyphNameIndex[i]]; if (name != null) { glyphNames[i] = name; } } } else if (Math.Abs(formatType - 3) < float.Epsilon) { glyphNames = EmptyArray <string> .Instance; } else { glyphNames = EmptyArray <string> .Instance; } return(glyphNames); }