diff --git a/Userland/Libraries/LibPDF/CMakeLists.txt b/Userland/Libraries/LibPDF/CMakeLists.txt index e16c5a30bf..dfa45c224e 100644 --- a/Userland/Libraries/LibPDF/CMakeLists.txt +++ b/Userland/Libraries/LibPDF/CMakeLists.txt @@ -14,6 +14,7 @@ set(SOURCES Fonts/Type0Font.cpp Fonts/Type1Font.cpp Fonts/Type1FontProgram.cpp + Fonts/Type3Font.cpp Function.cpp Interpolation.cpp ObjectDerivatives.cpp diff --git a/Userland/Libraries/LibPDF/Fonts/PDFFont.cpp b/Userland/Libraries/LibPDF/Fonts/PDFFont.cpp index 2bfc27b1d9..c863d83176 100644 --- a/Userland/Libraries/LibPDF/Fonts/PDFFont.cpp +++ b/Userland/Libraries/LibPDF/Fonts/PDFFont.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace PDF { @@ -44,7 +45,7 @@ PDFErrorOr> PDFFont::create(Document* document, NonnullRe } else if (subtype == "Type0") { font = adopt_ref(*new Type0Font()); } else if (subtype == "Type3") { - return Error { Error::Type::RenderingUnsupported, "Type3 fonts not yet implemented" }; + font = adopt_ref(*new Type3Font()); } else { dbgln_if(PDF_DEBUG, "Unhandled font subtype: {}", subtype); return Error::internal_error("Unhandled font subtype"); diff --git a/Userland/Libraries/LibPDF/Fonts/Type3Font.cpp b/Userland/Libraries/LibPDF/Fonts/Type3Font.cpp new file mode 100644 index 0000000000..6df3469813 --- /dev/null +++ b/Userland/Libraries/LibPDF/Fonts/Type3Font.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023, Nico Weber + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include + +namespace PDF { + +PDFErrorOr Type3Font::initialize(Document* document, NonnullRefPtr const& dict, float font_size) +{ + TRY(SimpleFont::initialize(document, dict, font_size)); + + // FIXME: /CharProcs, /FontBBox, /FontMatrix, /Resources + + return {}; +} + +Optional Type3Font::get_glyph_width(u8) const +{ + return OptionalNone {}; +} + +void Type3Font::set_font_size(float) +{ +} + +PDFErrorOr Type3Font::draw_glyph(Gfx::Painter&, Gfx::FloatPoint, float, u8, Color) +{ + return Error { Error::Type::RenderingUnsupported, "Type3 fonts not yet implemented" }; +} +} diff --git a/Userland/Libraries/LibPDF/Fonts/Type3Font.h b/Userland/Libraries/LibPDF/Fonts/Type3Font.h new file mode 100644 index 0000000000..9ec5d263a5 --- /dev/null +++ b/Userland/Libraries/LibPDF/Fonts/Type3Font.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2023, Nico Weber + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace PDF { + +class Type3Font : public SimpleFont { +public: + Optional get_glyph_width(u8 char_code) const override; + void set_font_size(float font_size) override; + PDFErrorOr draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint point, float width, u8 char_code, Color color) override; + +protected: + PDFErrorOr initialize(Document*, NonnullRefPtr const&, float font_size) override; +}; + +}