Skip to content

Commit 77596be

Browse files
jeremymanningclaude
andcommitted
Fix PDF ligature rendering - replace Unicode ligatures with ASCII
jsPDF's standard Times font doesn't support Unicode ligature characters (fi, fl, ff, ffi, ffl). These rendered as "û" with extra spacing, breaking words like "official" → "oû cial" and "conflict" → "conû ict". Added replaceLigatures() function to convert ligatures to their component letters (fi, fl, ff, etc.) before adding text to the PDF. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 07106f2 commit 77596be

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

checklist.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,19 @@ function emailChecklist() {
513513
generateChecklistPDF(dateInput.value);
514514
}
515515

516+
// Replace Unicode ligatures with their component letters
517+
// jsPDF's standard fonts don't support ligature characters
518+
function replaceLigatures(text) {
519+
return text
520+
.replace(/\uFB00/g, 'ff') // ff
521+
.replace(/\uFB01/g, 'fi') // fi
522+
.replace(/\uFB02/g, 'fl') // fl
523+
.replace(/\uFB03/g, 'ffi') // ffi
524+
.replace(/\uFB04/g, 'ffl') // ffl
525+
.replace(/\uFB05/g, 'st') // ſt (long s + t)
526+
.replace(/\uFB06/g, 'st'); // st (s + t)
527+
}
528+
516529
// Generate PDF using jsPDF library
517530
function generateChecklistPDF(dateValue) {
518531
// Check if jsPDF is available
@@ -579,6 +592,9 @@ function createPDF(dateValue) {
579592
var isChecked = checkboxes[index] && checkboxes[index].checked;
580593
var text = label.textContent.trim();
581594

595+
// Replace ligatures that jsPDF can't render properly
596+
text = replaceLigatures(text);
597+
582598
// Wrap text to content width (leave room for checkbox)
583599
var wrappedLines = doc.splitTextToSize(text, contentWidth - 10);
584600

0 commit comments

Comments
 (0)