/* * Copyright (c) 2023, Rodrigo Tobar . * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace PDF { class Reader; class CFF : public Type1FontProgram { private: // Table 9: Top DICT Operator Entries enum class TopDictOperator { Version = 0, Notice, FullName, FamilyName, Weight, FontBBox, // UniqueID = 13, // XUID, Charset = 15, Encoding, CharStrings, Private, // IsFixedPitch = (12 << 8 | 1), // ItalicAngle, // UnderlinePosition, // UnderlineThickness, // PaintType, }; enum class PrivDictOperator { Subrs = 19, DefaultWidthX, NominalWidthX, }; public: static PDFErrorOr> create(ReadonlyBytes const&, RefPtr encoding); // to private using Card8 = u8; using Card16 = u16; using Offset = i32; using OffSize = u8; using SID = u16; using DictOperand = Variant; static int load_int_dict_operand(u8 b0, Reader&); static float load_float_dict_operand(Reader&); static PDFErrorOr load_dict_operand(u8, Reader&); using IndexDataHandler = Function(ReadonlyBytes const&)>; static PDFErrorOr parse_index(Reader& reader, IndexDataHandler&&); template static PDFErrorOr parse_index_data(Card16 count, Reader& reader, IndexDataHandler&); template using DictEntryHandler = Function(OperatorT, Vector const&)>; template static PDFErrorOr parse_dict(Reader& reader, DictEntryHandler&& handler); template static PDFErrorOr parse_dict_operator(u8, Reader&); static PDFErrorOr> parse_charstrings(Reader&&, Vector const& subroutines); static PDFErrorOr> parse_charset(Reader&&, size_t); static PDFErrorOr> parse_encoding(Reader&&); static HashMap builtin_names; }; }