fonts

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default embed.FS
View Source
var Embedded = []fs.FS{Default}

Embedded are embedded filesystems to get fonts from. By default, this includes a set of Noto Sans and Roboto Mono fonts. System fonts are automatically supported separate from this. Use AddEmbedded to add to this. This must be called before the text shaper is created to have an effect.

On web, Embedded is only used for font metrics, as the actual font rendering happens through web fonts. See https://github.com/MobinYengejehi/core/font for more information.

View Source
var InfoExample = "AaBbCcIiPpQq12369$€¢?.:/()àáâãäåæç日本中国⇧⌘"

InfoExample is example text to demonstrate fonts.

Functions

func AddEmbedded

func AddEmbedded(fsys ...fs.FS)

AddEmbedded adds to Embedded for font loading.

func Style

func Style(face *font.Face, sty *rich.Style, tsty *text.Style)

Style sets the rich.Style and text.Style for the given font.Face.

func UseEmbeddedInMap

func UseEmbeddedInMap(fontMap *fontscan.FontMap) error

UseEmbeddedInMap adds the fonts from the current Embedded list to the given map.

func UseInMap

func UseInMap(fontMap *fontscan.FontMap, fss []fs.FS) error

UseInMap adds the fonts from given file systems to the given map.

Types

type Data

type Data struct {

	// Family name.
	Family string

	// Weight: normal, bold, etc.
	Weight rich.Weights

	// Slant: normal or italic.
	Slant rich.Slants

	// Stretch: normal, expanded, condensed, etc.
	Stretch rich.Stretch

	// Data contains the font data.
	Data []byte `display:"-"`

	// Font contains the loaded font face(s).
	Fonts []*font.Face
}

Data contains font information for embedded font data.

func (*Data) Load

func (fd *Data) Load() error

Load loads the data, setting the Font.

type Family

type Family struct {

	// Family name.
	Family string

	// example text, styled according to font family in chooser.
	Example string
}

Family is used for selecting a font family in a font chooser.

func Families

func Families(fi []Info) []Family

Families returns a list of Family with one representative per family.

func (Family) Label

func (fi Family) Label() string

Label satisfies the Labeler interface

type Info

type Info struct {

	// Family name.
	Family string

	// Weight: normal, bold, etc
	Weight rich.Weights

	// Slant: normal or italic
	Slant rich.Slants

	// Stretch: normal, expanded, condensed, etc
	Stretch rich.Stretch

	// Font contains info about the location, family, etc of the font file.
	Font fontscan.Footprint `display:"-"`
}

Info contains basic font information for aviailable fonts. This is used for a chooser for example.

func (Info) Label

func (fi Info) Label() string

Label satisfies the Labeler interface

Directories

Path Synopsis
Command metricsonly extracts font metrics from font files, discarding all the glyph outlines and other data.
Command metricsonly extracts font metrics from font files, discarding all the glyph outlines and other data.

Jump to

Keyboard shortcuts

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