mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
LibPDF: Add some scaffolding for type 3 fonts
This commit is contained in:
parent
7f999b1ff5
commit
4cd1a2d319
4 changed files with 61 additions and 1 deletions
|
@ -14,6 +14,7 @@ set(SOURCES
|
||||||
Fonts/Type0Font.cpp
|
Fonts/Type0Font.cpp
|
||||||
Fonts/Type1Font.cpp
|
Fonts/Type1Font.cpp
|
||||||
Fonts/Type1FontProgram.cpp
|
Fonts/Type1FontProgram.cpp
|
||||||
|
Fonts/Type3Font.cpp
|
||||||
Function.cpp
|
Function.cpp
|
||||||
Interpolation.cpp
|
Interpolation.cpp
|
||||||
ObjectDerivatives.cpp
|
ObjectDerivatives.cpp
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <LibPDF/Fonts/TrueTypeFont.h>
|
#include <LibPDF/Fonts/TrueTypeFont.h>
|
||||||
#include <LibPDF/Fonts/Type0Font.h>
|
#include <LibPDF/Fonts/Type0Font.h>
|
||||||
#include <LibPDF/Fonts/Type1Font.h>
|
#include <LibPDF/Fonts/Type1Font.h>
|
||||||
|
#include <LibPDF/Fonts/Type3Font.h>
|
||||||
|
|
||||||
namespace PDF {
|
namespace PDF {
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ PDFErrorOr<NonnullRefPtr<PDFFont>> PDFFont::create(Document* document, NonnullRe
|
||||||
} else if (subtype == "Type0") {
|
} else if (subtype == "Type0") {
|
||||||
font = adopt_ref(*new Type0Font());
|
font = adopt_ref(*new Type0Font());
|
||||||
} else if (subtype == "Type3") {
|
} else if (subtype == "Type3") {
|
||||||
return Error { Error::Type::RenderingUnsupported, "Type3 fonts not yet implemented" };
|
font = adopt_ref(*new Type3Font());
|
||||||
} else {
|
} else {
|
||||||
dbgln_if(PDF_DEBUG, "Unhandled font subtype: {}", subtype);
|
dbgln_if(PDF_DEBUG, "Unhandled font subtype: {}", subtype);
|
||||||
return Error::internal_error("Unhandled font subtype");
|
return Error::internal_error("Unhandled font subtype");
|
||||||
|
|
35
Userland/Libraries/LibPDF/Fonts/Type3Font.cpp
Normal file
35
Userland/Libraries/LibPDF/Fonts/Type3Font.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Nico Weber <thakis@chromium.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibGfx/Painter.h>
|
||||||
|
#include <LibPDF/CommonNames.h>
|
||||||
|
#include <LibPDF/Fonts/Type3Font.h>
|
||||||
|
|
||||||
|
namespace PDF {
|
||||||
|
|
||||||
|
PDFErrorOr<void> Type3Font::initialize(Document* document, NonnullRefPtr<DictObject> const& dict, float font_size)
|
||||||
|
{
|
||||||
|
TRY(SimpleFont::initialize(document, dict, font_size));
|
||||||
|
|
||||||
|
// FIXME: /CharProcs, /FontBBox, /FontMatrix, /Resources
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<float> Type3Font::get_glyph_width(u8) const
|
||||||
|
{
|
||||||
|
return OptionalNone {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void Type3Font::set_font_size(float)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFErrorOr<void> Type3Font::draw_glyph(Gfx::Painter&, Gfx::FloatPoint, float, u8, Color)
|
||||||
|
{
|
||||||
|
return Error { Error::Type::RenderingUnsupported, "Type3 fonts not yet implemented" };
|
||||||
|
}
|
||||||
|
}
|
23
Userland/Libraries/LibPDF/Fonts/Type3Font.h
Normal file
23
Userland/Libraries/LibPDF/Fonts/Type3Font.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Nico Weber <thakis@chromium.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibPDF/Fonts/SimpleFont.h>
|
||||||
|
|
||||||
|
namespace PDF {
|
||||||
|
|
||||||
|
class Type3Font : public SimpleFont {
|
||||||
|
public:
|
||||||
|
Optional<float> get_glyph_width(u8 char_code) const override;
|
||||||
|
void set_font_size(float font_size) override;
|
||||||
|
PDFErrorOr<void> draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint point, float width, u8 char_code, Color color) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PDFErrorOr<void> initialize(Document*, NonnullRefPtr<DictObject> const&, float font_size) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue