https://github.com/flopp/go-findfont
A platform-agnostic go (golang) library to easily locate truetype font files in your system's user and system font directories
https://github.com/flopp/go-findfont
Last synced: about 1 year ago
JSON representation
A platform-agnostic go (golang) library to easily locate truetype font files in your system's user and system font directories
- Host: GitHub
- URL: https://github.com/flopp/go-findfont
- Owner: flopp
- License: mit
- Created: 2016-03-17T22:05:29.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-04-21T14:45:46.000Z (about 2 years ago)
- Last Synced: 2024-10-14T00:58:50.086Z (over 1 year ago)
- Language: Go
- Size: 19.5 KB
- Stars: 132
- Watchers: 3
- Forks: 19
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/flopp/go-findfont)
[](https://goreportcard.com/report/github.com/flopp/go-findfont)
[](https://github.com/flopp/go-findfont/)
# go-findfont
A platform-agnostic go (golang) library to easily locate truetype font files in your system's user and system font directories.
## What?
`go-findfont` is a golang library that allows you to locate font file on your system. The library is currently aware of the default font directories on Linux/Unix, Windows, and MacOS.
## How?
### Installation
Installing `go-findfont` is as easy as
```bash
go get -u github.com/flopp/go-findfont
```
### Library Usage
```go
import (
"fmt"
"io/ioutil"
"github.com/flopp/go-findfont"
"github.com/golang/freetype/truetype"
)
func main() {
fontPath, err := findfont.Find("arial.ttf")
if err != nil {
panic(err)
}
fmt.Printf("Found 'arial.ttf' in '%s'\n", fontPath)
// load the font with the freetype library
fontData, err := ioutil.ReadFile(fontPath)
if err != nil {
panic(err)
}
font, err := truetype.Parse(fontData)
if err != nil {
panic(err)
}
// use the font...
}
```
## License
Copyright 2016 Florian Pigorsch. All rights reserved.
Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.