Skip to content

Commit bfc7fc4

Browse files
authored
Merge pull request #20101 from calixteman/issue20065
Use canvas context text primitives when the font file is missing
2 parents e4585c2 + 8b17e5e commit bfc7fc4

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/display/canvas.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,9 @@ class CanvasGraphics {
16251625
const newPath = new Path2D();
16261626
const invTransf = ctx.getTransform().invertSelf();
16271627
for (const { transform, x, y, fontSize, path } of paths) {
1628+
if (!path) {
1629+
continue; // Skip empty paths.
1630+
}
16281631
newPath.addPath(
16291632
path,
16301633
new DOMMatrix(transform)
@@ -1768,15 +1771,16 @@ class CanvasGraphics {
17681771

17691772
let path;
17701773
if (
1771-
font.disableFontFace ||
1772-
isAddToPathSet ||
1773-
patternFill ||
1774-
patternStroke
1774+
(font.disableFontFace ||
1775+
isAddToPathSet ||
1776+
patternFill ||
1777+
patternStroke) &&
1778+
!font.missingFile
17751779
) {
17761780
path = font.getPathGenerator(this.commonObjs, character);
17771781
}
17781782

1779-
if (font.disableFontFace || patternFill || patternStroke) {
1783+
if (path && (font.disableFontFace || patternFill || patternStroke)) {
17801784
ctx.save();
17811785
ctx.translate(x, y);
17821786
ctx.scale(fontSize, -fontSize);

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,3 +733,4 @@
733733
!firefox_logo.pdf
734734
!issue20062.pdf
735735
!issue20102.pdf
736+
!issue20065.pdf

test/pdfs/issue20065.pdf

13.4 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12213,5 +12213,13 @@
1221312213
"popupRef": "27R"
1221412214
}
1221512215
}
12216+
},
12217+
{
12218+
"id": "issue20065",
12219+
"file": "pdfs/issue20065.pdf",
12220+
"md5": "39ad13514d0b0108e4ae42f4b1422839",
12221+
"rounds": 1,
12222+
"disableFontFace": true,
12223+
"type": "eq"
1221612224
}
1221712225
]

0 commit comments

Comments
 (0)