fix: use dynamic count for beginbfrange declaration#1660
Merged
blikblum merged 6 commits intofoliojs:masterfrom Dec 1, 2025
Merged
fix: use dynamic count for beginbfrange declaration#1660blikblum merged 6 commits intofoliojs:masterfrom
blikblum merged 6 commits intofoliojs:masterfrom
Conversation
Fixes garbled text copying in Chrome/Edge for PDFs with >256 unique characters
Addressed an issue with garbled text copying in Chrome/Edge for PDFs containing more than 256 unique characters.
Add test cases to verify that the beginbfrange count declaration in ToUnicode CMap matches the actual number of bfrange entries. - Test for fonts with >256 characters (multiple ranges) - Test for fonts with <=256 characters (single range) These tests ensure the fix for the beginbfrange count bug is correct and prevent regression. Related to foliojs#1659
blikblum
requested changes
Nov 26, 2025
| }); | ||
| }); | ||
|
|
||
| test.each([ |
Contributor
Author
There was a problem hiding this comment.
Sorry for that. Maybe I use wrong version of the file to generate tests code. I have fixed it.
tests/unit/font.spec.js
Outdated
| const font = PDFFontFactory.open( | ||
| document, | ||
| 'tests/fonts/Roboto-Regular.ttf', | ||
| 'tests/fonts/Roboto-Regular.ttf' |
Member
There was a problem hiding this comment.
Please run prettier to make style consistent
Contributor
Author
There was a problem hiding this comment.
Sorry for that. Maybe I use wrong version of the file to generate tests code. I have fixed it.
Member
|
There s one remaining eslint error |
Replace for loops with unused match variables with spread operator to directly get array length, fixing ESLint no-unused-vars errors. - Replace loop counting with [...rangeMatches].length - Fixes ESLint errors at lines 152 and 197 in tests/unit/font.spec.js - All tests pass successfully
Contributor
Author
My bad. I Fixed it. ToT |
Member
|
Many thanks |
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.
Fixes garbled text copying in Chrome/Edge for PDFs with >256 unique characters
What kind of change does this PR introduce?
Bug fix
issue : #1659
Checklist:
PDF standards 1.3 Chapter 5. Page 344
(https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/pdfreference1.3.pdf)