AtlatestRepositorysigil-fontconfig
sigil-fontconfig / tree / testtest-fontconfig.sgl
1
(import (sigil test)2
(sigil fs)3
(sigil fontconfig))5
(test-group "fontconfig"6
(test "family style and size select a usable file and face index"7
(let ((font (fc-font-match8
(fc-pattern family: "JetBrains Mono" style: "Regular" size: 7))))9
(assert-true (fc-font? font))10
(assert-equal "JetBrains Mono" (fc-font-family font))11
(assert-true (file-exists? (fc-font-file font)))12
(assert-true (exact-integer? (fc-font-index font)))13
(assert-true (>= (fc-font-index font) 0))))15
(test "bold style is honored"16
(let ((font (fc-font-match17
(fc-pattern family: "JetBrains Mono" style: "Bold" size: 7))))18
(assert-equal "Bold" (fc-font-style font))))20
(test "listing returns copied records surviving native set destruction"21
(let* ((fonts (fc-font-list (fc-pattern family: "JetBrains Mono")))22
(saved (and (pair? fonts) (fc-font-file (car fonts)))))23
(assert-true (pair? fonts))24
(assert-true (pair? (fc-font-list)))25
(assert-true (file-exists? saved))26
(for-each27
(lambda (font)28
(assert-true (file-exists? (fc-font-file font)))29
(assert-equal "JetBrains Mono" (fc-font-family font)))30
fonts)))32
(test "listing an unavailable family is empty while matching falls back"33
(let ((pattern (fc-pattern family: "Sigil nonexistent font 8e9c60")))34
(assert-equal '() (fc-font-list pattern))35
(assert-true (fc-font? (fc-font-match pattern)))))37
(test "invalid patterns are rejected before native calls"38
(assert-error (fc-font-match "sans"))39
(assert-error (fc-font-match (fc-pattern family: "")))40
(assert-error (fc-font-match (fc-pattern family: 3)))41
(assert-error (fc-font-match (fc-pattern style: 3)))42
(assert-error (fc-font-match (fc-pattern size: 0)))43
(assert-error (fc-font-match (fc-pattern size: -1)))44
(assert-error (fc-font-match (fc-pattern size: "7")))45
(assert-error46
(fc-font-match (fc-pattern family: (string #\A (integer->char 0) #\B))))))