fontinfo

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

FontInfo

Go Reference GoReportCard

FontInfo is a Go package to list available fonts on a Linux system.

  • No CGO required
  • Doesn't wrap fontconfig or other utilities
  • Pure Go
  • No external dependencies
  • Provides family and style for each font
  • Supports TTF and OTF
  • Fast (typically parses 1k fonts in ~100ms)

Example

package main

import (
	"fmt"

	"github.com/liamg/fontinfo"
)

func main() {

	fonts, err := fontinfo.List()
	if err != nil {
		panic(err)
	}

	for _, font := range fonts {
		fmt.Printf("Family=%s Style=%s Path=%s\n", font.Family, font.Style, font.Path)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchFamily

func MatchFamily(family string) matcher

MatchFamily is a matcher which matches fonts with the specified font family (case insensitive)

func MatchStyle

func MatchStyle(style string) matcher

MatchStyle is a matcher which matches fonts with the specified font family (case insensitive)

Types

type Font

type Font struct {
	Family string
	Style  string
	Path   string
}

Font represents a font file on disk

func List

func List() ([]Font, error)

List all otf/ttf fonts installed on the system

func Match

func Match(matchers ...matcher) ([]Font, error)

Match finds all fonts installed on the system which match the provided matchers

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL