Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/v2/pdf_resources/page_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,13 @@ namespace pdflib

auto& fm = bfonts.get(fontname);

if(fm.has(c))
// If font declares a specific encoding (MacRoman, WinAnsi, etc.),
// use that encoding instead of base font's built-in mapping
if(encoding == MACROMAN || encoding == MACEXPERT || encoding == WINANSI || encoding == STANDARD)
{
return get_character_from_encoding(c);
}
else if(fm.has(c))
{
return fm.to_utf8(c);
}
Expand Down Expand Up @@ -703,6 +709,13 @@ namespace pdflib

LOG_S(INFO) << "font-encoding [" << name << "]: " << to_string(encoding);
}
else if(result.is_object() && result.count("/BaseEncoding") == 1 && result["/BaseEncoding"].is_string())
{
// Extract /BaseEncoding from encoding dictionary
std::string base_enc = result["/BaseEncoding"].get<std::string>();
encoding = to_encoding_name(base_enc);
LOG_S(INFO) << "font-encoding from object /BaseEncoding [" << base_enc << "]: " << to_string(encoding);
}
else
{
LOG_S(WARNING) << "font-encoding [object]: " << result.dump();
Expand Down
28 changes: 14 additions & 14 deletions tests/data/groundtruth/broken_media_box_v01.pdf.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"info": {
"#-pages": 1,
"filename": "tests/data/regression/broken_media_box_v01.pdf"
"filename": ""
},
"pages": [
{
Expand Down Expand Up @@ -12935,23 +12935,23 @@
},
"timings": {
"decode_annots": 0.0,
"decode_contents": 0.001505,
"decode_dimensions": 0.0,
"decode_page": 0.003311,
"decode_resources": 0.000751,
"sanitise_contents": 0.00015
"decode_contents": 0.001218,
"decode_dimensions": 1e-06,
"decode_page": 0.002446,
"decode_resources": 0.000629,
"sanitise_contents": 0.000133
}
}
],
"timings": {
"decode_annots": 0.0,
"decode_contents": 0.001505,
"decode_dimensions": 0.0,
"decode_document": 0.003574,
"decode_page": 0.003311,
"decode_resources": 0.000751,
"decoding page 0": 0.003497,
"process_document_from_file": 0.000606,
"sanitise_contents": 0.00015
"decode_contents": 0.001218,
"decode_dimensions": 1e-06,
"decode_document": 0.002718,
"decode_page": 0.002446,
"decode_resources": 0.000629,
"decoding page 0": 0.002638,
"process_document_from_bytesio": 0.000393,
"sanitise_contents": 0.000133
}
}
Loading
Loading