Commit4d398540Recorded11 Nov 2026Repositorysigil-ui

Reject duplicate outline fallback font paths

Changed
 src/sigil/ui/text.sgl       | 6 ++++--
 test/test-text-fallback.sgl | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
Diff
src/sigil/ui/text.sglmodified
@@ -70,12 +70,14 @@
70
(unless (and (list? fallback-files) (<= (length fallback-files) 8)
71
(every string? fallback-files))
72
(error "Text fallback files must be a list of at most eight paths"))
−73
(let total ((files fallback-files) (bytes 0))
+73
(let total ((files fallback-files) (bytes 0) (seen '()))
74
(unless (null? files)
+75
(when (member (car files) seen)
+76
(error "Text fallback paths must be unique" (car files)))
77
(let ((size (file-size (car files))))
78
(unless (and size (> size 0) (<= (+ bytes size) 67108864))
79
(error "Text fallback files are missing, empty or exceed the 64-MiB input limit" (car files)))
−78
(total (cdr files) (+ bytes size)))))
+80
(total (cdr files) (+ bytes size) (cons (car files) seen)))))
81
(let ((preferred (and family (string-trim family)))
82
(regular #f) (bold #f) (fallbacks '()) (source 'files) (discovery-error #f))
83
(when (and preferred (string=? preferred ""))
test/test-text-fallback.sglmodified
@@ -110,5 +110,7 @@
110
(assert-error (make-text-font regular bold fallback-files: #f))
111
(assert-error (make-text-font regular bold fallback-files: (list 1)))
112
(assert-error (make-text-font regular bold fallback-files: (cons symbols symbols)))
+113
(assert-error (make-text-font regular bold fallback-files: (list symbols symbols)))
+114
(assert-error (make-text-font regular bold fallback-files: (list symbols (string-append symbols ""))))
115
(assert-error (make-text-font regular bold fallback-files: (make-list 9 symbols)))
116
(assert-error (make-text-font regular bold fallback-files: (list "missing-fallback.ttf"))))