fonts

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultFonts

func GetDefaultFonts() []string

GetDefaultFonts returns an ordered list of preferred fonts.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles font loading and caching. fonts caches parsed *truetype.Font objects (read-only after parse, safe to share). Faces are NOT cached — each caller gets its own face with its own GlyphBuf, since truetype.face is not safe for concurrent use.

func NewManager

func NewManager(logger *slog.Logger) *Manager

NewManager returns the process-wide font manager singleton. The logger from the first call is used; subsequent calls ignore their logger.

func (*Manager) GetFace

func (m *Manager) GetFace(fontName string, size float64) (font.Face, error)

GetFace returns a new font face with the specified size. A fresh face is returned on every call — truetype.face is not safe for concurrent use (it wraps a mutable GlyphBuf), so callers must not share faces.

func (*Manager) LoadBestAvailableFont

func (m *Manager) LoadBestAvailableFont(size float64) (font.Face, string, error)

LoadBestAvailableFont tries to load fonts in order of preference.

func (*Manager) LoadFont

func (m *Manager) LoadFont(name string) (*truetype.Font, error)

LoadFont loads a TrueType font from embedded, system, or bundled sources.

Jump to

Keyboard shortcuts

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