PS1FontProgram.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2022, Julian Offenhäuser <offenhaeuser@protonmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <LibGfx/AffineTransform.h>
  9. #include <LibGfx/Font/Font.h>
  10. #include <LibGfx/Path.h>
  11. #include <LibPDF/Error.h>
  12. #include <LibPDF/Fonts/Type1FontProgram.h>
  13. namespace PDF {
  14. class Reader;
  15. class Encoding;
  16. class PS1FontProgram : public Type1FontProgram {
  17. public:
  18. static PDFErrorOr<NonnullRefPtr<Type1FontProgram>> create(ReadonlyBytes const&, RefPtr<Encoding>, size_t cleartext_length, size_t encrypted_length);
  19. private:
  20. PDFErrorOr<void> parse_encrypted_portion(ByteBuffer const&);
  21. PDFErrorOr<Vector<ByteBuffer>> parse_subroutines(Reader&) const;
  22. static PDFErrorOr<Vector<float>> parse_number_array(Reader&, size_t length);
  23. static PDFErrorOr<ByteString> parse_word(Reader&);
  24. static PDFErrorOr<float> parse_float(Reader&);
  25. static PDFErrorOr<int> parse_int(Reader&);
  26. static PDFErrorOr<ByteBuffer> decrypt(ReadonlyBytes const&, u16 key, size_t skip);
  27. static bool seek_name(Reader&, ByteString const&);
  28. u16 m_encryption_key { 4330 };
  29. int m_lenIV { 4 };
  30. };
  31. }