fonts in many locations
Hey
I am needing to allow someone to be able to tell Deck multiply places to look for fonts, as well as guess where they typically are.
https://github.com/flopp/go-findfont works for me, and finds all fonts on the users system by searching in the standard paths per OS. It can also search for a particular font.
I am not sure of the best approach in terms of usability. I think that Deck could look into the standard system folders using go-findfont, and then allow the DECK_FONTS env variable to be an array, so that the user can hint for other non system folders what do you think ?
What is the use-case for multiple font locations?
Re: using go-findfont, people can easily point DECKFONT to a system location, and I'd rather not introduce a dependency for this function. Also, because you may want to use fonts that are not in the system directories, with the current scheme you have full control. Moreover, you don't have to worry about name collisions.
Its just for helping users to use the fonts that are native on their OS. People often have fonts in many locations.
All good points you raise. I don't want to make things more complicated either.
As a compromise solution to their problem, i could write a little folder in a util package that allows the users users to find all fonts on their OS , and copy them into the DECK_FONTS directory. It would then not change the deck code. I could offer this util to them when they run a deck and it does not find a Font. Essentially asking them if they want to try to find the missing font.
what do you think ?
I'm ok with the idea of a utility that helps set DECKFONTS:
$ setdeckfont # use the default for the host OS DECKFONTS=/Library/Fonts/ $ setdeckfont -os unix DECKFONTS=~/.local/share/fonts/
Sounds good
where do you think this code should live ?
Do you want me to write it ? Happy to but on holidays for a few more weeks just so you know
see: https://github.com/ajstarks/utils/blob/master/cmd/setdeckfont/setdeckfont.go
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/flopp/go-findfont"
)
func main() {
sample := ""
if len(os.Args) > 1 {
sample = os.Args[1]
}
fontPath, err := findfont.Find(sample)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
fmt.Printf("DECKFONTS=%s\n", filepath.Dir(fontPath))
}
Thanks @ajstarks
sorted this out. Will close