Skip to content

tinne26/fonts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Free latin fonts

This project exposes fonts (latin-ext only) in a similar way to the go-fonts repositories, but using embed and transparently loading the *sfnt.Font right away.

This project was made mostly for personal use, to make it easier to write code examples that use the etxt text rendering package (Golang / Ebitengine).

Licenses

Fonts have each their own licenses, located in their respective folders, but they are all licensed under free software licenses.

The code is distributed under the MIT license instead.

Usage

All subpackages expose three methods:

  • Font(), which parses the font if it wasn't parsed yet, caches it and returns it as an *sfnt.Font.
  • Name(), which exposes the font name that you would use with etxt.FontLibrary.
  • Release(), which frees the cached font if it was loaded at any point by Font().

Example program (should be run with -tags gtxt):

package main

import "fmt"
import "github.com/tinne26/etxt"
import "github.com/tinne26/fonts/liberation/lbrtserif"

func main() {
	renderer := etxt.NewStdRenderer()
	renderer.SetFont(lbrtserif.Font())
	rect := renderer.SelectionRect("controversial opinion")
	fmt.Printf("%dx%d pixels\n", rect.Width.Ceil(), rect.Height.Ceil())
}

The names of the subpackages and their paths match what you can find in this repository.

Subpackage cheatsheet

Font names are shortened in funny ways, but they get too long and repetitive for my taste otherwise:

  • Liberation Sans | sans-serif, regular, neutral | github.com/tinne26/fonts/liberation/lbrtsans
  • Liberation Serif | serif, regular, neutral | github.com/tinne26/fonts/liberation/lbrtserif
  • Liberation Mono | monospace, regular, neutral | github.com/tinne26/fonts/liberation/lbrtmono

About

Packages embedding fonts for use with etxt.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages