fontconfig/pattern.scm (make-pattern): Take keyword arguments.

* examples/exmaple.scm: Update accordingly.
master
nixo 2021-01-18 10:23:12 +01:00
parent e0683f7bc4
commit 2afa2625c2
2 changed files with 12 additions and 3 deletions

View File

@ -1,7 +1,7 @@
(use-modules (fontconfig))
(let ((pattern (make-pattern
'((family "JuliaMono")))))
#:family "JuliaMono" #:style "bold")))
(map
(lambda (pat)
(format #t "

View File

@ -19,6 +19,7 @@
(define-module (fontconfig pattern)
#:use-module (ice-9 match)
#:use-module (ice-9 optargs)
#:use-module ((fontconfig bindings) #:prefix ffi:)
#:use-module (fontconfig object-set)
#:use-module (rnrs bytevectors)
@ -67,7 +68,15 @@
(ffi:fontconfig-pattern-add-bool
(unwrap-pattern pattern) (symbol->pointer attr) (if value 1 0)))
(define* (make-pattern #:optional (args '()))
(define* (keywords->symbols args #:optional (out '()))
(if (>= (length args) 2)
(keywords->symbols
(cddr args)
(cons (list (keyword->symbol (car args)) (cadr args))
out))
out))
(define (make-pattern . args)
(define bool? (cute member <> %bool-attrs))
(define int? (cute member <> %integer-attrs))
(define double? (cute member <> %double-attrs))
@ -85,7 +94,7 @@
(((? double? attr) value) pattern-add-double)
(((? string? attr) value) pattern-add-string))
pattern args))
args)
(keywords->symbols args))
pattern))
(define (font-list pattern os)