https://github.com/danielgatis/go-findfont
Find system fonts through the fontconfig library (a.k.a `fc-match`).
https://github.com/danielgatis/go-findfont
font fontconfig fontconfig-library fonts go golang
Last synced: about 1 month ago
JSON representation
Find system fonts through the fontconfig library (a.k.a `fc-match`).
- Host: GitHub
- URL: https://github.com/danielgatis/go-findfont
- Owner: danielgatis
- License: mit
- Created: 2020-05-28T13:17:46.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-12-26T02:09:12.000Z (5 months ago)
- Last Synced: 2026-01-10T22:06:14.050Z (5 months ago)
- Topics: font, fontconfig, fontconfig-library, fonts, go, golang
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - go-findfont - match`). (Repositories)
README
# go-findfont
[](https://goreportcard.com/report/github.com/danielgatis/go-findfont)
[](https://raw.githubusercontent.com/danielgatis/go-findfont/master/LICENSE)
[](https://godoc.org/github.com/danielgatis/go-findfont)
A pure Go library to find fonts on the system. Works on macOS, Linux, and Windows without any external dependencies.
## Install
```bash
go get -u github.com/danielgatis/go-findfont
```
And then import the package in your code:
```go
import "github.com/danielgatis/go-findfont/findfont"
```
## Usage
### Find a font by name
```go
package main
import (
"fmt"
"os"
"github.com/danielgatis/go-findfont/findfont"
)
func main() {
path, err := findfont.Find("Arial")
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
fmt.Println(path)
}
```
```
❯ go run main.go
/System/Library/Fonts/Supplemental/Arial.ttf
```
### List all fonts
```go
fonts := findfont.List()
for _, f := range fonts {
fmt.Println(f)
}
```
### Find with custom suffixes
```go
path, err := findfont.FindWithSuffixes("MyFont", []string{".ttf", ".otf"})
```
## CLI
You can also use it as a command-line tool:
```bash
# Find a font
go-findfont Arial
# List all fonts
go-findfont --list
```
## Supported Platforms
| Platform | Font Directories |
|----------|------------------|
| macOS | `~/Library/Fonts`, `/Library/Fonts`, `/System/Library/Fonts` |
| Linux | `~/.fonts`, `~/.local/share/fonts`, `/usr/share/fonts`, `/usr/local/share/fonts` |
| Windows | `%windir%\Fonts`, `%localappdata%\Microsoft\Windows\Fonts` |
## License
Copyright (c) 2020-present [Daniel Gatis](https://github.com/danielgatis)
Licensed under [MIT License](./LICENSE)