Apply the font /Differences array to every byte of a text segment#453
Open
splitbrain wants to merge 1 commit into
Open
Apply the font /Differences array to every byte of a text segment#453splitbrain wants to merge 1 commit into
splitbrain wants to merge 1 commit into
Conversation
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.
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.
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 ;-)