Use canvas context text primitives when the font file is missing

It fixes #20065.

The only to get a path (from the path generator) is when the font is embedded.
So when we need a path (disableFontFace: true or when we want to use a pattern for stroking/filling), it's impossible
to fulfil.
This commit is contained in:
Calixte Denizet 2025-07-17 18:01:47 +02:00
parent e4585c2452
commit 8b17e5ecd8
4 changed files with 168 additions and 5 deletions

View File

@ -1625,6 +1625,9 @@ class CanvasGraphics {
const newPath = new Path2D();
const invTransf = ctx.getTransform().invertSelf();
for (const { transform, x, y, fontSize, path } of paths) {
if (!path) {
continue; // Skip empty paths.
}
newPath.addPath(
path,
new DOMMatrix(transform)
@ -1768,15 +1771,16 @@ class CanvasGraphics {
let path;
if (
font.disableFontFace ||
(font.disableFontFace ||
isAddToPathSet ||
patternFill ||
patternStroke
patternStroke) &&
!font.missingFile
) {
path = font.getPathGenerator(this.commonObjs, character);
}
if (font.disableFontFace || patternFill || patternStroke) {
if (path && (font.disableFontFace || patternFill || patternStroke)) {
ctx.save();
ctx.translate(x, y);
ctx.scale(fontSize, -fontSize);

View File

@ -733,3 +733,4 @@
!firefox_logo.pdf
!issue20062.pdf
!issue20102.pdf
!issue20065.pdf

150
test/pdfs/issue20065.pdf Executable file

File diff suppressed because one or more lines are too long

View File

@ -12213,5 +12213,13 @@
"popupRef": "27R"
}
}
},
{
"id": "issue20065",
"file": "pdfs/issue20065.pdf",
"md5": "39ad13514d0b0108e4ae42f4b1422839",
"rounds": 1,
"disableFontFace": true,
"type": "eq"
}
]