Documentation
¶
Overview ¶
Package fonts lists the font families installed on the machine, for the interface's and the terminal's font settings. It asks MyGo's text engine first (ui.FontFamilies: Core Text, DirectWrite, fontconfig through Pango), which knows what text can actually draw with; where that lists nothing, it reads the system itself, without cgo: fontconfig's fc-list on Linux when present, else the font files in the platform's font directories (macOS's, %WINDIR%\Fonts and the per-user fonts on Windows, fontconfig's on Linux), whose names and pitch it parses from their OpenType tables.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Family ¶
type Family struct {
Name string
// Mono is whether it is monospaced, as a terminal wants.
Mono bool
}
Family is an installed font family.
func ForTerminal ¶
ForTerminal orders families for a terminal's font setting: the monospaced ones first, then, unless monoOnly, the others.
func List ¶
func List() []Family
List lists the installed families, each once, sorted without regard to case.
func Normalize ¶
Normalize drops empty and hidden names (".SF NS", as macOS keeps for itself) and lists each family once, monospaced if any of its fonts is, sorted without regard to case.
func ParseFCList ¶
ParseFCList parses `fc-list --format '%{family}\t%{spacing}\n'`: per font, its family names (a comma-separated list, the first the canonical one; commas within names are escaped as "\,") and its spacing, 100 for monospaced and 90 for dual-width (as CJK monospace fonts are), empty for proportional.