Skip to content

Commit 69a0461

Browse files
author
quentin.legrand
committed
Fix: Context2d font regex too restrictive ( #3904 )
Add Unit test
1 parent 3f73650 commit 69a0461

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

test/reference/fa-solid-900.ttf

391 KB
Binary file not shown.

test/specs/context2d.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,24 @@ describe("Context2D: standard tests", () => {
164164
comparePdf(doc.output(), "context2d-custom-fonts.pdf", "context2d");
165165
});
166166

167+
it("context2d: custom fonts name regex", () => {
168+
const FaSolid = loadBinaryResource("reference/fa-solid-900.ttf");
169+
170+
const doc = new jsPDF({
171+
orientation: "p",
172+
unit: "pt",
173+
format: "a4",
174+
floatPrecision: 2
175+
});
176+
doc.addFileToVFS("fa-solid-900.ttf", FaSolid);
177+
doc.addFont("fa-solid-900.ttf", "Font Awesome 6 Free Solid", "normal");
178+
179+
const ctx = doc.context2d;
180+
ctx.font = "normal 16pt \"Font Awesome 6 Free Solid\"";
181+
182+
expect(doc.getFont().fontName).toBe("Font Awesome 6 Free Solid");
183+
});
184+
167185
it("context2d: css color names", () => {
168186
var doc = new jsPDF({
169187
orientation: "p",

0 commit comments

Comments
 (0)