Bugfix: Handle TypedArrays and Buffers in deep-merge/clone#1744
Open
ykw9263 wants to merge 13 commits into
Open
Bugfix: Handle TypedArrays and Buffers in deep-merge/clone#1744ykw9263 wants to merge 13 commits into
ykw9263 wants to merge 13 commits into
Conversation
blikblum
reviewed
Jun 26, 2026
blikblum
requested changes
Jun 27, 2026
blikblum
left a comment
Member
There was a problem hiding this comment.
While the font handling is not overhauled this seems a good workaround
- remove unnecessary isObject check - rename binary data check function Co-authored-by: Luiz Américo <camara_luiz@yahoo.com.br>
- font family name is not allowed for ttf fonts with no Variations
blikblum
reviewed
Jun 28, 2026
Comment on lines
+126
to
+132
| // extract fonts | ||
| const { font: defaultFont, ...restDefaultStyle } = defaultColStyle || {}; | ||
| const { font: font, ...restStyle } = colStyle || {}; | ||
| const mergedFont = { | ||
| ...defaultFont, | ||
| ...font, | ||
| }; |
Member
There was a problem hiding this comment.
Given that deepMerge was modified to handle binary data, why not use it?
Author
There was a problem hiding this comment.
Just found a bug where merging fonts with font collections would cause problem
doc.table({
rowStyles: [{
font: { src: SOME_TTC_FONT, family: FONT_FAMILY },
}]
})
.row([
{ text: 'Hello World', font: { src: SOME_TTF_FONT } }
]);
// throws `Variations require a font with the fvar, gvar and glyf, or CFF2 tables`I think font src should be binded with its family and not be merged with other family names across styles
Member
|
There is a minor changelog conflict |
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.
What kind of change does this PR introduce?
This fixes #1743 where providing font buffers crashes table generation.
In
lib\table\utils.js,deepMergeanddeepClone()copy properties key by key includingBufferandUint8Arraywithout inheriting the class. This causes the merged font buffer failing to be recognised byPDFFontFactorywhich relies oninstanceofto determine the type of font sources.This PR changes:
deepMerge()anddeepClone()now clone TypedArrays and Buffers using.slice()andBuffer.from(buffer)respectively.Table style merging is modified to copy fonts by reference.
Additional unit tests (fonts in tables, deep-merging buffers) are added for the changes.
Checklist:
TODO: