Hello Paolo,

This behaviour actually comes from font-config and not from Lilypond. It is 
somewhat sensible, since we want to be able to specify a font intuitively and 
not by some set identifier.

One hacky way to get what you want if you are checking for very specific fonts 
could be this, which would be checking the font file for some string we’d 
expect to find in it.

Cheers,
Valentin
#(define path1 (ly:font-config-get-font-file "TeX Gyre Schola"))
#(define path2 (ly:font-config-get-font-file "nonsense"))

#(define (read-line port)
   (define (iterator prev)
     (let ((char (read-char port)))
       (if (or (eof-object? char) (equal? char #\nl))
           (if (and (eof-object? char) (null? prev))
               'eof
               prev)
           (iterator (cons char prev)))))
   (let ((rev-list (iterator '())))
     (if (equal? rev-list 'eof) 'eof
         (list->string (reverse rev-list)))))

#(define (file-contains? path expr)
   (define (iterator port)
     (let ((line (read-line port)))
       (if (equal? line 'eof)
           #f
           (if (string-contains line expr)
               #t
               (iterator port)))))
   (iterator (open-input-file path)))

#(display (file-contains? path1 "TeXGyreSchola"))
#(display (file-contains? path2 "nonsense"))

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to