Documentation ¶
Overview ¶
Package font provides a simple interface to render fonts. An implementation is allowed to store glyphs in any form (pixmap, vector) but must return them rendered in alpha channel of image.Image.
Index ¶
- Constants
- type Face
- type Magnifier
- func (p *Magnifier) Advance(r rune) int
- func (p *Magnifier) Face() Face
- func (p *Magnifier) Glyph(r rune) (img image.Image, origin image.Point, advance int)
- func (p *Magnifier) Scale() (sx, sy int)
- func (p *Magnifier) SetFace(face Face)
- func (p *Magnifier) SetScale(sx, sy int)
- func (p *Magnifier) Size() (height, ascent int)
Constants ¶
const ( // Nearest means nearest-neighbor scaling. Use if the pixelated look of the // scaled font is acceptable or desirable. Nearest = images.Nearest // Bilinear means bilinear interpolation. Use if the pixelated look of the // Nearest is undesirable. Bilinear = images.Bilinear )
Scaling mode.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Face ¶
type Face interface { // Size returns the font face height (interline spacing) and the ascent // (height above the baseline). Size() (height, ascent int) // Advance returns the glyph advance for the given rune. The advance // determines the x-distance on the baseline between the origin point of the // current character and the origin point of next character. Advance(r rune) int // Glyph returns the graphical representation of the given rune in the alpha // channel of returned image. The image is valid until the next Glyph call // which makes Face UNSAFE for concurrent use. The origin point is given in // the img coordinates, may be outside of the image bounds. Glyph(r rune) (img image.Image, origin image.Point, advance int) }
Face converts an unicode codepoint (rune) to its graphical representation (glyph) in some font face. A font face represents a specific size, style and weight of a font.
The implementation of Face is allowed to be UNSAFE for concurrent use (see description of Glyph method). In such case a font repository should provide a way to request multiple independend Face instances that represents the same font face in the repository.
type Magnifier ¶
type Magnifier struct {
// contains filtered or unexported fields
}
Magnifier can wrap Face to scale it up at runtime by integer factor. It can be useful if the available fonts are too small for a display. Magnifier is UNSAFE for concurrent use. A goroutine should magnify the selected font face just before using it and should not share magnified faces with other goroutines.
func Magnify ¶
Magnify wraps face into Magnifier to scale it up by scale factor usind given scaling mode.
Directories ¶
Path | Synopsis |
---|---|
Package subfont defines a font as a collection of subfonts.
|
Package subfont defines a font as a collection of subfonts. |
font9
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. |
gfxfont
TODO: Package gfxfont implements the Adafruit GFX subfont format.
|
TODO: Package gfxfont implements the Adafruit GFX subfont format. |