/// <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 CompactFontFormatParser(CompactFontFormatIndividualFontParser individualFontParser, CompactFontFormatIndexReader indexReader) { this.individualFontParser = individualFontParser; this.indexReader = indexReader; }