/* * Copyright (c) 2022, Julian Offenhäuser * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace PDF { class Reader; class Encoding; class PS1FontProgram : public RefCounted { public: PDFErrorOr create(ReadonlyBytes const&, RefPtr, size_t cleartext_length, size_t encrypted_length); RefPtr rasterize_glyph(u32 char_code, float width); Gfx::Path build_char(u32 char_code, float width); RefPtr encoding() const { return m_encoding; } Gfx::FloatPoint glyph_translation(u32 char_code, float width) const; private: struct Glyph { Gfx::Path path; float width; }; struct GlyphParserState { Glyph glyph; Gfx::FloatPoint point; bool flex_feature { false }; size_t flex_index; Array flex_sequence; size_t sp { 0 }; Array stack; size_t postscript_sp { 0 }; Array postscript_stack; }; Gfx::AffineTransform glyph_transform_to_device_space(Glyph const&, float width) const; PDFErrorOr parse_glyph(ReadonlyBytes const&, GlyphParserState&); PDFErrorOr parse_encrypted_portion(ByteBuffer const&); PDFErrorOr> parse_subroutines(Reader&); PDFErrorOr> parse_number_array(Reader&, size_t length); PDFErrorOr parse_word(Reader&); PDFErrorOr parse_float(Reader&); PDFErrorOr parse_int(Reader&); PDFErrorOr decrypt(ReadonlyBytes const&, u16 key, size_t skip); bool seek_name(Reader&, DeprecatedString const&); static Error error( DeprecatedString const& message #ifdef PDF_DEBUG , SourceLocation loc = SourceLocation::current() #endif ); Vector m_subroutines; Vector m_character_names; HashMap m_glyph_map; Gfx::AffineTransform m_font_matrix; RefPtr m_encoding; u16 m_encryption_key { 4330 }; int m_lenIV { 4 }; }; }