Skip to content

Commit 704a005

Browse files
committed
Fix font cache collision identical metadata for different fonts #1330
1 parent 1b678c3 commit 704a005

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- Add support to scale text horizontally
99
- Add an option to keep the indentation after a new line starts and allow to indent a whole paragraph/text element
1010
- Fix sets tab order to "Structure" when a document is tagged
11-
- Fix font cache collision for fonts with missing postscript name or bad TTF metadata
11+
- Fix font cache collision for fonts with missing postscript name or bad TTF metadata or identical metadata for different fonts
1212
- Fix measuring text when OpenType features are passed in to .text()
1313

1414
### [v0.15.2] - 2024-12-15

lib/mixins/fonts.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import PDFFontFactory from '../font_factory';
22

33
const isEqualFont = (font1, font2) => {
4+
// compare font checksum
5+
if (font1.font._tables?.head?.checkSumAdjustment !== font2.font._tables?.head?.checkSumAdjustment) {
6+
return false;
7+
}
8+
49
// compare font name table
5-
return (JSON.stringify(font1.font._tables?.name?.records) === JSON.stringify(font2.font._tables?.name?.records))
10+
if (JSON.stringify(font1.font._tables?.name?.records) !== JSON.stringify(font2.font._tables?.name?.records)) {
11+
return false;
12+
}
13+
14+
return true;
615
}
716

817
export default {

0 commit comments

Comments
 (0)