Conversation
oubayashi
force-pushed
the
bannertopdf-unicode
branch
from
September 24, 2026 02:24
73e3366 to
ecebcfa
Compare
Decode banner fields as UTF-8 instead of writing raw input bytes to Courier strings. Use Fontconfig to find outline fonts covering non-ASCII characters, cache matching fonts, and embed them as Unicode CID fonts through PDFio. Switch font resources as needed when a line contains characters from multiple writing systems while keeping the existing Courier path for ASCII text. Validate UTF-8 sequences, escape special and control characters in PDF literal strings, and gracefully replace characters when no embeddable font is available. Supplementary-plane characters are currently replaced because PDFio 1.6 uses a BMP-sized CIDToGID mapping. This fixes garbled printer names, locations, job titles, user names, and other banner fields containing non-ASCII text.
oubayashi
force-pushed
the
bannertopdf-unicode
branch
from
September 24, 2026 02:46
ecebcfa to
fdd4cc2
Compare
Resolve and copy an indirect page Resources dictionary before adding the banner font instead of replacing it with an empty dictionary. This preserves existing XObject, ExtGState, Font, and other resources from the banner template. Extend the Unicode banner regression test to verify that the template image resources and drawing commands remain present.
Author
|
I added a separate follow-up commit for the missing template images found The default test-page template stores The regression test has also been extended to verify the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix garbled non-ASCII text in
bannertopdfoutput.Banner fields were previously written as raw bytes using the PDF standard
Courier font, which only works reliably for single-byte text. Printer names,
locations, job titles, user names, and other fields containing UTF-8 text
could therefore appear garbled or lose characters.
This pull request also fixes an existing page-resource handling issue exposed
while testing Unicode font embedding. Banner templates with an indirect
/Resourcesdictionary could lose their image XObjects when banner fonts wereadded.
Changes
Unicode banner text
and out-of-range sequences.
systems.
strings.
invalid font references.
user names, host names, billing information, model names, and localized
times.
Preserve template resources
/Resourcesentry is a direct dictionary or anindirect object.
/XObject,/ExtGState,/Font, and other templateresources.
default-testpage.pdffrom disappearing when the pageresources are updated.
Regression Test
Add an end-to-end regression test following the existing
test-pdftopdf-inherited-mediaboxtest pattern.The test runs a mixed ASCII and Unicode banner through the existing
testfiltersharness, then reopens the generated PDF with PDFio and verifiesthat:
ToUnicodemap./x6,/x7, and/x8are preserved./x6 Do,/x7 Do, and/x8 Dodrawing commands remainin the page content stream.
The
testfiltersharness now supports selectingbannertopdfexplicitly forfocused regression testing.
The regression test is skipped when Fontconfig, PDFio, or a font covering the
test character is unavailable.
The initial regression-test implementation was prepared with assistance from
OpenAI Codex and reviewed against the existing project test patterns.
The changes were built and tested successfully on Ubuntu 24.04. Testing
included generating a banner with mixed ASCII and Unicode text, confirming
that the fallback font was embedded, and verifying that the text and template
images were rendered correctly in the generated PDF.
Compatibility
?.U+FFFFcurrently fall back toU+FFFD, because PDFio 1.6 uses a BMP-sized CID-to-GID mapping.change.
Commit Structure
This pull request is split into two commits:
string escaping, and an end-to-end Unicode banner regression test.
extend the regression test to cover template image resources.