public IFont Generate(PdfDictionary dictionary, IRandomAccessRead reader, bool isLenientParsing) { var baseFont = dictionary.GetName(CosName.BASE_FONT); var cMap = ReadEncoding(dictionary, out var isCMapPredefined); ICidFont cidFont; if (TryGetFirstDescendant(dictionary, out var descendantObject)) { var parsed = DirectObjectFinder.Find <PdfDictionary>(descendantObject, pdfObjectParser, reader, isLenientParsing); if (parsed is PdfDictionary descendantFontDictionary) { cidFont = ParseDescendant(descendantFontDictionary, reader, isLenientParsing); } else { throw new InvalidFontFormatException("Expected to find a Descendant Font dictionary, instead it was: " + parsed); } } else { throw new InvalidFontFormatException("No descendant font dictionary was declared for this Type 0 font. This dictionary should contain the CIDFont for the Type 0 font. " + dictionary); } var ucs2CMap = GetUcs2CMap(dictionary, isCMapPredefined, false); CMap toUnicodeCMap = null; if (dictionary.ContainsKey(CosName.TO_UNICODE)) { var toUnicodeValue = dictionary[CosName.TO_UNICODE]; var toUnicode = pdfObjectParser.Parse(((CosObject)toUnicodeValue).ToIndirectReference(), reader, isLenientParsing) as PdfRawStream; var decodedUnicodeCMap = toUnicode?.Decode(filterProvider); if (decodedUnicodeCMap != null) { toUnicodeCMap = cMapCache.Parse(new ByteArrayInputBytes(decodedUnicodeCMap), isLenientParsing); } } var font = new Type0Font(baseFont, cidFont, cMap, toUnicodeCMap); return(font); }