mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:37:44 +00:00
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:
parent
11f7db8f34
commit
3c49d0dad3
4 changed files with 12 additions and 2 deletions
|
@ -38,6 +38,10 @@
|
||||||
# cmakedefine01 CANVAS_RENDERING_CONTEXT_2D_DEBUG
|
# cmakedefine01 CANVAS_RENDERING_CONTEXT_2D_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CFF_DEBUG
|
||||||
|
# cmakedefine01 CFF_DEBUG
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CMAKE_DEBUG
|
#ifndef CMAKE_DEBUG
|
||||||
# cmakedefine01 CMAKE_DEBUG
|
# cmakedefine01 CMAKE_DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,6 +14,7 @@ set(BXVGA_DEBUG ON)
|
||||||
set(CACHE_DEBUG ON)
|
set(CACHE_DEBUG ON)
|
||||||
set(CALLBACK_MACHINE_DEBUG ON)
|
set(CALLBACK_MACHINE_DEBUG ON)
|
||||||
set(CANVAS_RENDERING_CONTEXT_2D_DEBUG ON)
|
set(CANVAS_RENDERING_CONTEXT_2D_DEBUG ON)
|
||||||
|
set(CFF_DEBUG ON)
|
||||||
set(CMAKE_DEBUG ON)
|
set(CMAKE_DEBUG ON)
|
||||||
set(COMMIT_DEBUG ON)
|
set(COMMIT_DEBUG ON)
|
||||||
set(COMPOSE_DEBUG ON)
|
set(COMPOSE_DEBUG ON)
|
||||||
|
|
|
@ -243,6 +243,7 @@ write_cmake_config("ak_debug_gen") {
|
||||||
"CACHE_DEBUG=",
|
"CACHE_DEBUG=",
|
||||||
"CALLBACK_MACHINE_DEBUG=",
|
"CALLBACK_MACHINE_DEBUG=",
|
||||||
"CANVAS_RENDERING_CONTEXT_2D_DEBUG=",
|
"CANVAS_RENDERING_CONTEXT_2D_DEBUG=",
|
||||||
|
"CFF_DEBUG=",
|
||||||
"CMAKE_DEBUG=",
|
"CMAKE_DEBUG=",
|
||||||
"COMPOSE_DEBUG=",
|
"COMPOSE_DEBUG=",
|
||||||
"COPY_DEBUG=",
|
"COPY_DEBUG=",
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
// CFF spec: https://adobe-type-tools.github.io/font-tech-notes/pdfs/5176.CFF.pdf
|
// 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/Endian.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibGfx/Forward.h>
|
#include <LibGfx/Forward.h>
|
||||||
|
@ -31,8 +32,9 @@ PDFErrorOr<NonnullRefPtr<CFF>> CFF::create(ReadonlyBytes const& cff_bytes, RefPt
|
||||||
// CFF spec, "7 Name INDEX"
|
// CFF spec, "7 Name INDEX"
|
||||||
Vector<String> font_names;
|
Vector<String> font_names;
|
||||||
TRY(parse_index(reader, [&](ReadonlyBytes const& data) -> PDFErrorOr<void> {
|
TRY(parse_index(reader, [&](ReadonlyBytes const& data) -> PDFErrorOr<void> {
|
||||||
auto string = TRY(String::from_utf8(data));
|
auto font_name = TRY(String::from_utf8(data));
|
||||||
return TRY(font_names.try_append(string));
|
dbgln_if(CFF_DEBUG, "CFF font name '{}'", font_name);
|
||||||
|
return TRY(font_names.try_append(font_name));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
auto cff = adopt_ref(*new CFF());
|
auto cff = adopt_ref(*new CFF());
|
||||||
|
@ -130,8 +132,10 @@ PDFErrorOr<NonnullRefPtr<CFF>> CFF::create(ReadonlyBytes const& cff_bytes, RefPt
|
||||||
|
|
||||||
// Encoding given or read
|
// Encoding given or read
|
||||||
if (encoding) {
|
if (encoding) {
|
||||||
|
dbgln_if(CFF_DEBUG, "CFF using external encoding");
|
||||||
cff->set_encoding(move(encoding));
|
cff->set_encoding(move(encoding));
|
||||||
} else {
|
} else {
|
||||||
|
dbgln_if(CFF_DEBUG, "CFF using embedded encoding");
|
||||||
auto encoding = Encoding::create();
|
auto encoding = Encoding::create();
|
||||||
for (size_t i = 0; i < glyphs.size(); i++) {
|
for (size_t i = 0; i < glyphs.size(); i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue