Skip to content

Commit

Permalink
Tweak adjustType1ToUnicode for fonts with a predefined *named* enco…
Browse files Browse the repository at this point in the history
…ding (bug 1811668, PR 14050 follow-up)

*Please note:* I cannot reproduce the problem reported in bug 1811668, regarding the context menu, and in any case it's not clear that that part is even a PDF Viewer bug.

Looking at bug 1811668 I couldn't help but noticing that the textLayer isn't correct, and it's unfortunately once again a problem with the `adjustType1ToUnicode` function. That's intended to help improve text-selection for fonts without a /ToUnicode-entry, and in many cases it does help (the original PR fixed lots of issues) however it's also caused some problems.

In order to improve text-selection in bug 1811668, we'll now properly ignore fonts that have a predefined *named* encoding specified since that's really the intention with PR 14050.
  • Loading branch information
Snuffleupagus committed Jan 21, 2023
1 parent 7b95788 commit 40a46e4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/fonts.js
Expand Up @@ -201,7 +201,7 @@ function adjustType1ToUnicode(properties, builtInEncoding) {
for (const charCode in builtInEncoding) {
if (properties.hasEncoding) {
if (
properties.differences.length === 0 ||
properties.baseEncodingName ||
properties.differences[charCode] !== undefined
) {
continue; // The font dictionary has an `Encoding`/`Differences` entry.
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Expand Up @@ -399,6 +399,7 @@
!issue4461.pdf
!issue4573.pdf
!issue4722.pdf
!bug1811668_reduced.pdf
!issue4800.pdf
!issue9243.pdf
!issue13147.pdf
Expand Down
Binary file added test/pdfs/bug1811668_reduced.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions test/test_manifest.json
Expand Up @@ -1006,6 +1006,12 @@
"lastPage": 1,
"type": "eq"
},
{ "id": "bug1811668",
"file": "pdfs/bug1811668_reduced.pdf",
"md5": "87aa65d89aa0682cbe7b87152b884495",
"rounds": 1,
"type": "text"
},
{ "id": "issue8092",
"file": "pdfs/issue8092.pdf",
"md5": "e4f3376b35fd132580246c3db1fbd738",
Expand Down

0 comments on commit 40a46e4

Please sign in to comment.