Greetings, long time lurker/first time posting here. I have been working on this one for a couple of days and can't seem to figure it out.
I'm having an issue where on macOS, there are some fonts/variants returned by
get-face-list that I can't actually use with a drawing function like
text.
#lang racket
(require pict racket/draw)
(define (list-fonts str)
(filter (lambda(s) (string=? str (substring s 0 (min (string-length str) (string-length s)))))
(get-face-list #:all-variants? #t)))
(define (demo-font str)
(apply vl-append (map (lambda (f) (text f f 30)) (list-fonts str))))
Attached is a screenshot comparison of the results of this code on Windows and macOS, both using Racket 6.12.
To sum up the problem “narratively”, as it were: on Windows, among the strings returned by
get-face-list is
"IBM Plex Sans Text, Medium" and I can do
(text "Hello" "IBM Plex Sans Text, Medium" 30), and
pict will draw using that font.
But on macOS, where
get-face-list will include the string
"IBM Plex Sans, Text" (note comma), if I do
(text "Hello" "IBM Plex Sans, Text"), I instead get the result in the default sans serif font.
Furthermore, all of IBM Plex Sans’s 16 weights work properly on macOS/Racket—except the "Text" weight!
A similar problem happens with some other fonts on macOS, e.g. Halyard Micro Regular and Halyard Micro Book — the Regular weight works but the Book weight displays using the Regular weight, despite using the exact string found in
get-face-list as the font/variant name in the call to
text.
I did my main example using IBM Plex Sans since it's a free font [1] should anyone wish to replicate my results for themselves.
How would I best go about finding out what is happening here? Are certain words like “book” or “text” just not recognized/useable as a font weight on macOS? Apologies if I’m missing something obvious!
[1]:
https://ibm.github.io/type/