LibPDF: Add a CFF_DEBUG toggle

I'd like to put some debug prints behind this soon.

No behavior change.
This commit is contained in:
Nico Weber 2023-10-14 18:54:46 -04:00 committed by Andreas Kling
parent 11f7db8f34
commit 3c49d0dad3
4 changed files with 12 additions and 2 deletions

View file

@ -38,6 +38,10 @@
# cmakedefine01 CANVAS_RENDERING_CONTEXT_2D_DEBUG
#endif
#ifndef CFF_DEBUG
# cmakedefine01 CFF_DEBUG
#endif
#ifndef CMAKE_DEBUG
# cmakedefine01 CMAKE_DEBUG
#endif

View file

@ -14,6 +14,7 @@ set(BXVGA_DEBUG ON)
set(CACHE_DEBUG ON)
set(CALLBACK_MACHINE_DEBUG ON)
set(CANVAS_RENDERING_CONTEXT_2D_DEBUG ON)
set(CFF_DEBUG ON)
set(CMAKE_DEBUG ON)
set(COMMIT_DEBUG ON)
set(COMPOSE_DEBUG ON)

View file

@ -243,6 +243,7 @@ write_cmake_config("ak_debug_gen") {
"CACHE_DEBUG=",
"CALLBACK_MACHINE_DEBUG=",
"CANVAS_RENDERING_CONTEXT_2D_DEBUG=",
"CFF_DEBUG=",
"CMAKE_DEBUG=",
"COMPOSE_DEBUG=",
"COPY_DEBUG=",

View file

@ -6,6 +6,7 @@
// CFF spec: https://adobe-type-tools.github.io/font-tech-notes/pdfs/5176.CFF.pdf
#include <AK/Debug.h>
#include <AK/Endian.h>
#include <AK/String.h>
#include <LibGfx/Forward.h>
@ -31,8 +32,9 @@ PDFErrorOr<NonnullRefPtr<CFF>> CFF::create(ReadonlyBytes const& cff_bytes, RefPt
// CFF spec, "7 Name INDEX"
Vector<String> font_names;
TRY(parse_index(reader, [&](ReadonlyBytes const& data) -> PDFErrorOr<void> {
auto string = TRY(String::from_utf8(data));
return TRY(font_names.try_append(string));
auto font_name = TRY(String::from_utf8(data));
dbgln_if(CFF_DEBUG, "CFF font name '{}'", font_name);
return TRY(font_names.try_append(font_name));
}));
auto cff = adopt_ref(*new CFF());
@ -130,8 +132,10 @@ PDFErrorOr<NonnullRefPtr<CFF>> CFF::create(ReadonlyBytes const& cff_bytes, RefPt
// Encoding given or read
if (encoding) {
dbgln_if(CFF_DEBUG, "CFF using external encoding");
cff->set_encoding(move(encoding));
} else {
dbgln_if(CFF_DEBUG, "CFF using embedded encoding");
auto encoding = Encoding::create();
for (size_t i = 0; i < glyphs.size(); i++) {
if (i == 0) {