Skip to content

Commit

Permalink
Fix font cache collision identical metadata for different fonts #1330
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Dec 28, 2024
1 parent 1b678c3 commit 704a005
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- Add support to scale text horizontally
- Add an option to keep the indentation after a new line starts and allow to indent a whole paragraph/text element
- Fix sets tab order to "Structure" when a document is tagged
- Fix font cache collision for fonts with missing postscript name or bad TTF metadata
- Fix font cache collision for fonts with missing postscript name or bad TTF metadata or identical metadata for different fonts
- Fix measuring text when OpenType features are passed in to .text()

### [v0.15.2] - 2024-12-15
Expand Down
11 changes: 10 additions & 1 deletion lib/mixins/fonts.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import PDFFontFactory from '../font_factory';

const isEqualFont = (font1, font2) => {
// compare font checksum
if (font1.font._tables?.head?.checkSumAdjustment !== font2.font._tables?.head?.checkSumAdjustment) {
return false;
}

// compare font name table
return (JSON.stringify(font1.font._tables?.name?.records) === JSON.stringify(font2.font._tables?.name?.records))
if (JSON.stringify(font1.font._tables?.name?.records) !== JSON.stringify(font2.font._tables?.name?.records)) {
return false;
}

return true;
}

export default {
Expand Down

0 comments on commit 704a005

Please sign in to comment.