text

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package text is fonts, their glyphs drawn on demand into a sheet of their own, and the fixed debug text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugPrintAt

func DebugPrintAt(dst *gfx.Image, s string, x, y int)

DebugPrintAt prints s with its top-left corner at (x, y), a line of it under another at each newline.

func Glyphs added in v0.20.0

func Glyphs(f *Font, s string, dst []gpu.Piece) []gpu.Piece

Glyphs appends to dst the glyphs of s in f, each where it lies from the top-left of the first line, a line under another at each newline, and where it is on f's Sheet.

func Ink added in v0.20.0

func Ink(glyphs []gpu.Piece) (x, y, w, h float32)

Ink is the box round the glyphs laid: its top-left and its size; zero for none.

func NumberGlyphs added in v0.20.0

func NumberGlyphs(f *Font, n int, dst []gpu.Piece) []gpu.Piece

NumberGlyphs appends to dst the glyphs of n written in f, as Glyphs lays a string.

func NumberInk added in v0.20.0

func NumberInk(n int) (x, y, w, h float32)

NumberInk is the box round the ink of n written in NumberFont, as NumberGlyphs lays it: its top-left and its size. It may be asked on any goroutine.

func Sheet added in v0.20.0

func Sheet(f *Font) *gfx.Image

Sheet is the image f's glyphs are drawn from, every glyph laid so far on it.

Types

type Font

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

Font is a typeface at a size, its glyphs drawn on demand into a sheet of its own.

func DefaultBoldFont

func DefaultBoldFont() *Font

DefaultBoldFont is Go Bold at 14 pixels, DefaultFont's weight for a heading.

func DefaultFont

func DefaultFont() *Font

DefaultFont is Go Regular at 14 pixels, which has the Latin letters of every European language.

func DefaultLargeFont

func DefaultLargeFont() *Font

DefaultLargeFont is Go Bold at 28 pixels, for a screen's title.

func NewFont

func NewFont(ttf []byte, size float64) (*Font, error)

NewFont is the face of the TrueType or OpenType font ttf at size pixels.

func NumberFont added in v0.20.0

func NumberFont() *Font

NumberFont is Go Bold at 10 pixels, the face a badge's number is drawn in.

func (*Font) Draw

func (f *Font) Draw(dst *gfx.Image, s string, x, y float32, c color.Color)

Draw draws s in the font, c its colour, its first line's top-left at (x, y) of dst, a line under another at each newline.

func (*Font) Has

func (f *Font) Has(r rune) bool

Has reports whether the face has a glyph for r.

func (*Font) LineHeight

func (f *Font) LineHeight() float32

LineHeight is how far one line of text lies under the one before it.

func (*Font) Measure

func (f *Font) Measure(s string) (w, h float32)

Measure is how wide the longest line of s is and how high its lines are.

Jump to

Keyboard shortcuts

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