/// <summary> /// Read the Compact Font Format font from the input data. /// </summary> public static CompactFontFormatFontCollection Parse(CompactFontFormatData data) { var tag = ReadTag(data); switch (tag) { // An OpenType font containing CFF data. case TagOtto: throw new NotSupportedException("Currently tagged CFF data is not supported."); case TagTtcf: throw new NotSupportedException("True Type Collection fonts are not currently supported."); case TagTtfonly: throw new NotSupportedException("OpenType fonts containing a true type font are not currently supported."); default: data.Seek(0); break; } var header = ReadHeader(data); var fontNames = ReadStringIndex(data); var topLevelDictionaryIndex = CompactFontFormatIndexReader.ReadDictionaryData(data); var stringIndex = ReadStringIndex(data); var globalSubroutineIndex = CompactFontFormatIndexReader.ReadDictionaryData(data); var fonts = new Dictionary <string, CompactFontFormatFont>(); var individualFontParser = new CompactFontFormatIndividualFontParser(new CompactFontFormatTopLevelDictionaryReader(), new CompactFontFormatPrivateDictionaryReader()); for (var i = 0; i < fontNames.Length; i++) { var fontName = fontNames[i]; fonts[fontName] = individualFontParser.Parse(data, fontName, topLevelDictionaryIndex[i], stringIndex, globalSubroutineIndex); } return(new CompactFontFormatFontCollection(header, fonts)); }
public void Parse(CompactFontFormatData data) { var tag = ReadTag(data); switch (tag) { case TagOtto: throw new NotImplementedException("Currently tagged CFF data is not supported."); case TagTtcf: throw new NotSupportedException("True Type Collection fonts are not supported."); case TagTtfonly: throw new NotSupportedException("OpenType fonts containing a true type font are not supported."); default: data.Seek(0); break; } var header = ReadHeader(data); var fontNames = ReadStringIndex(data); var topLevelDict = indexReader.ReadDictionaryData(data); var stringIndex = ReadStringIndex(data); var globalSubroutineIndex = indexReader.ReadDictionaryData(data); for (var i = 0; i < fontNames.Length; i++) { var fontName = fontNames[i]; individualFontParser.Parse(data, fontName, topLevelDict[i], stringIndex); } }