diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index d392d51f15..1390aebe8e 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -396,8 +396,9 @@ if (BUILD_LAGOM) # PDF file(GLOB LIBPDF_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibPDF/*.cpp") + file(GLOB LIBPDF_SUBDIR_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibPDF/*/*.cpp") lagom_lib(PDF pdf - SOURCES ${LIBPDF_SOURCES} + SOURCES ${LIBPDF_SOURCES} ${LIBPDF_SUBDIR_SOURCES} LIBS LagomGfx LagomIPC LagomTextCodec ) diff --git a/Userland/Libraries/LibPDF/CMakeLists.txt b/Userland/Libraries/LibPDF/CMakeLists.txt index 363fc55b89..eb8231c511 100644 --- a/Userland/Libraries/LibPDF/CMakeLists.txt +++ b/Userland/Libraries/LibPDF/CMakeLists.txt @@ -5,7 +5,8 @@ set(SOURCES Encoding.cpp Encryption.cpp Filter.cpp - Fonts.cpp + Fonts/PDFFont.cpp + Fonts/Type1Font.cpp ObjectDerivatives.cpp Parser.cpp Renderer.cpp diff --git a/Userland/Libraries/LibPDF/Fonts/PDFFont.cpp b/Userland/Libraries/LibPDF/Fonts/PDFFont.cpp new file mode 100644 index 0000000000..289169abe9 --- /dev/null +++ b/Userland/Libraries/LibPDF/Fonts/PDFFont.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022, Matthew Olsson + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include + +namespace PDF { + +PDFErrorOr> PDFFont::create(Document* document, NonnullRefPtr dict) +{ + auto subtype = TRY(dict->get_name(document, CommonNames::Subtype))->name(); + + if (subtype == "Type1") + return TRY(Type1Font::create(document, dict)); + + dbgln("Unknown font subtype: {}", subtype); + TODO(); +} + +} diff --git a/Userland/Libraries/LibPDF/Fonts/PDFFont.h b/Userland/Libraries/LibPDF/Fonts/PDFFont.h new file mode 100644 index 0000000000..6f3f0ce671 --- /dev/null +++ b/Userland/Libraries/LibPDF/Fonts/PDFFont.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022, Matthew Olsson + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace PDF { + +class PDFFont : public RefCounted { +public: + static PDFErrorOr> create(Document*, NonnullRefPtr); + + virtual ~PDFFont() = default; + + virtual u32 char_code_to_code_point(u16 char_code) const = 0; + virtual float get_char_width(u16 char_code) const = 0; +}; + +} diff --git a/Userland/Libraries/LibPDF/Fonts.cpp b/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp similarity index 91% rename from Userland/Libraries/LibPDF/Fonts.cpp rename to Userland/Libraries/LibPDF/Fonts/Type1Font.cpp index b43678db4b..315e808579 100644 --- a/Userland/Libraries/LibPDF/Fonts.cpp +++ b/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include namespace PDF { @@ -26,16 +26,6 @@ static bool is_standard_latin_font(FlyString const& font) "Courier-BoldOblique"); } -PDFErrorOr> PDFFont::create(Document* document, NonnullRefPtr dict) -{ - auto subtype = TRY(dict->get_name(document, CommonNames::Subtype))->name(); - - if (subtype == "Type1") - return TRY(Type1Font::create(document, dict)); - - TODO(); -} - PDFErrorOr> Type1Font::create(Document* document, NonnullRefPtr dict) { // FIXME: "Required except for the standard 14 fonts"... diff --git a/Userland/Libraries/LibPDF/Fonts.h b/Userland/Libraries/LibPDF/Fonts/Type1Font.h similarity index 68% rename from Userland/Libraries/LibPDF/Fonts.h rename to Userland/Libraries/LibPDF/Fonts/Type1Font.h index 3d98305e61..361d2229cf 100644 --- a/Userland/Libraries/LibPDF/Fonts.h +++ b/Userland/Libraries/LibPDF/Fonts/Type1Font.h @@ -7,20 +7,10 @@ #pragma once #include -#include +#include namespace PDF { -class PDFFont : public RefCounted { -public: - static PDFErrorOr> create(Document*, NonnullRefPtr); - - virtual ~PDFFont() = default; - - virtual u32 char_code_to_code_point(u16 char_code) const = 0; - virtual float get_char_width(u16 char_code) const = 0; -}; - class Type1Font : public PDFFont { public: static PDFErrorOr> create(Document*, NonnullRefPtr); diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp index fd7985e132..7e95d21a0a 100644 --- a/Userland/Libraries/LibPDF/Renderer.cpp +++ b/Userland/Libraries/LibPDF/Renderer.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #define RENDERER_HANDLER(name) \ diff --git a/Userland/Libraries/LibPDF/Renderer.h b/Userland/Libraries/LibPDF/Renderer.h index cccc83fb36..60af100dde 100644 --- a/Userland/Libraries/LibPDF/Renderer.h +++ b/Userland/Libraries/LibPDF/Renderer.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include namespace PDF {