LibPDF: Move font files into their own directory

This commit is contained in:
Matthew Olsson 2022-03-24 22:14:50 -07:00 committed by Andreas Kling
parent d2771eafc5
commit 5f9d35909d
8 changed files with 55 additions and 26 deletions

View file

@ -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
)

View file

@ -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

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) 2022, Matthew Olsson <mattco@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibPDF/CommonNames.h>
#include <LibPDF/Fonts/PDFFont.h>
#include <LibPDF/Fonts/Type1Font.h>
namespace PDF {
PDFErrorOr<NonnullRefPtr<PDFFont>> PDFFont::create(Document* document, NonnullRefPtr<DictObject> 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();
}
}

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2022, Matthew Olsson <mattco@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibPDF/Document.h>
namespace PDF {
class PDFFont : public RefCounted<PDFFont> {
public:
static PDFErrorOr<NonnullRefPtr<PDFFont>> create(Document*, NonnullRefPtr<DictObject>);
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;
};
}

View file

@ -5,7 +5,7 @@
*/
#include <LibPDF/CommonNames.h>
#include <LibPDF/Fonts.h>
#include <LibPDF/Fonts/Type1Font.h>
namespace PDF {
@ -26,16 +26,6 @@ static bool is_standard_latin_font(FlyString const& font)
"Courier-BoldOblique");
}
PDFErrorOr<NonnullRefPtr<PDFFont>> PDFFont::create(Document* document, NonnullRefPtr<DictObject> dict)
{
auto subtype = TRY(dict->get_name(document, CommonNames::Subtype))->name();
if (subtype == "Type1")
return TRY(Type1Font::create(document, dict));
TODO();
}
PDFErrorOr<NonnullRefPtr<Type1Font>> Type1Font::create(Document* document, NonnullRefPtr<DictObject> dict)
{
// FIXME: "Required except for the standard 14 fonts"...

View file

@ -7,20 +7,10 @@
#pragma once
#include <LibPDF/Encoding.h>
#include <LibPDF/ObjectDerivatives.h>
#include <LibPDF/Fonts/PDFFont.h>
namespace PDF {
class PDFFont : public RefCounted<PDFFont> {
public:
static PDFErrorOr<NonnullRefPtr<PDFFont>> create(Document*, NonnullRefPtr<DictObject>);
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<NonnullRefPtr<Type1Font>> create(Document*, NonnullRefPtr<DictObject>);

View file

@ -6,7 +6,7 @@
#include <AK/Utf8View.h>
#include <LibPDF/CommonNames.h>
#include <LibPDF/Fonts.h>
#include <LibPDF/Fonts/PDFFont.h>
#include <LibPDF/Renderer.h>
#define RENDERER_HANDLER(name) \

View file

@ -19,7 +19,7 @@
#include <LibGfx/Size.h>
#include <LibPDF/ColorSpace.h>
#include <LibPDF/Document.h>
#include <LibPDF/Fonts.h>
#include <LibPDF/Fonts/PDFFont.h>
#include <LibPDF/Object.h>
namespace PDF {