subfont

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package subfont defines a font as a collection of subfonts. One subfont holds the character data for a specific size, style, weight and specific range of unicode codepoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data interface {
	// Advance returns the advance for the i-th glyph.
	Advance(i int) int

	// Glyph returns the data of the i-th glyph. The returned image is valid
	// until the next Glyph call.
	Glyph(i int) (img image.Image, origin image.Point, advance int)
}

Data represents a glyph storage.

type Face

type Face struct {
	Height   int16      // interline spacing (sumarizes all subfonts)
	Ascent   int16      // height above the baseline (sumarizes all subfonts)
	Subfonts []*Subfont // ordered subfonts that make up the face
	Loader   Loader     // used to load missing subfonts
}

Face is a collection of subfonts from one font with the same size, style and weight.

func (*Face) Advance

func (f *Face) Advance(r rune) int

Advance implements font.Face interface.

func (*Face) Glyph

func (f *Face) Glyph(r rune) (img image.Image, origin image.Point, advance int)

Glyph implements font.Face interface.

func (*Face) Size

func (f *Face) Size() (height, ascent int)

Size implements font.Face interface.

type Loader

type Loader interface {
	Load(r rune, current []*Subfont) (containing *Subfont, updated []*Subfont)
}

Loader is the interface that wraps the Load method.

Load loads a subfont containing the given rune. A successful call returns the pointer to the loaded subfont. Load may also add and/or remove any subfonts from the current list and return the updated version.

type Subfont

type Subfont struct {
	First  rune // first character in the subfont
	Last   rune // last character in the subfont
	Offset int  // offset in Data to the first character
	Data   Data // character data
}

Subfont provides Last-First+1 font glyphs for runes form First to Last. The glyphs are stored in Data starting from Offset.

Directories

Path Synopsis
Package font9 implements the subfont format where characters are stored as a single image with the glyphs placed side-by-side on a common baseline.
Package font9 implements the subfont format where characters are stored as a single image with the glyphs placed side-by-side on a common baseline.
vga
TODO: Package gfxfont implements the Adafruit GFX subfont format.
TODO: Package gfxfont implements the Adafruit GFX subfont format.

Jump to

Keyboard shortcuts

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