Skip to content

Apply the font /Differences array to every byte of a text segment#453

Open
splitbrain wants to merge 1 commit into
PrinsFrank:mainfrom
cosmocode:utf8
Open

Apply the font /Differences array to every byte of a text segment#453
splitbrain wants to merge 1 commit into
PrinsFrank:mainfrom
cosmocode:utf8

Conversation

@splitbrain

Copy link
Copy Markdown
Contributor

The /Differences array was only consulted for single byte text segments, so multi-byte strings shown with a font whose encoding is a /Differences array without a base encoding or /ToUnicode CMap fell through to their raw bytes. Non-ASCII glyphs such as umlauts were then emitted as raw single byte codes, producing invalid UTF-8.

Simple fonts are single byte encoded, so the array is now applied per byte for the whole segment, falling back to the base encoding for codes it does not remap, matching the encoding resolution in spec section 9.6.6.1.

I encountered this issue when trying to convert my 20+ year old Latex-generated diploma thesis - the issue seems to be rare for modern PDFs. The commit adds a synthetic test PDF - if you need my thesis for tests, let me know ;-)

The /Differences array was only consulted for single byte text segments,
so multi-byte strings shown with a font whose encoding is a /Differences
array without a base encoding or /ToUnicode CMap fell through to their raw
bytes. Non-ASCII glyphs such as umlauts were then emitted as raw single
byte codes, producing invalid UTF-8.

Simple fonts are single byte encoded, so the array is now applied per byte
for the whole segment, falling back to the base encoding for codes it does
not remap, matching the encoding resolution in spec section 9.6.6.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant