Documentation
¶
Overview ¶
Package font is a lightweight wrapper around the Ebiten fonts API of the github.com/hajimehoshi/ebiten/v2/text/v2 package.
It provides several conveniences that are absent in the relatively low-level text/v2 package:
- A registry which caches loaded fonts. - Support for finding and using system fonts (provided by sysfont).
It still provides access to the low-level text/v2 representation for rendering.
Index ¶
Constants ¶
const ( DirectionLeftToRight = text.DirectionLeftToRight DirectionRightToLeft = text.DirectionRightToLeft DirectionTopToBottomAndLeftToRight = text.DirectionTopToBottomAndLeftToRight DirectionTopToBottomAndRightToLeft = text.DirectionTopToBottomAndRightToLeft )
Variables ¶
This section is empty.
Functions ¶
func RegisterSource ¶
RegisterSource adds a source to the registry under the provided name.
Overrides any system fonts. Safe to call from multiple goroutines simultaneously.
Types ¶
type Face ¶
type Face struct {
// contains filtered or unexported fields
}
Face represents a configuration of the display of text.
func (*Face) LineSize ¶
LineSize is the amount of vertical or horizontal space (depending on the face's Direction) takes up on a line. lineSpacing is the relative amount of additional spacing to provide the line. For example, 0.0 is single-spaced and 1.0 is double-spaced. Negative lineSpacing reduces the line size.
func (*Face) Resize ¶
Resize returns a new Face with all the same features except with the font size changed to the provided size.
func (*Face) TextFace ¶
func (f *Face) TextFace() *text.GoTextFace
TextFace returns the underlying Ebiten GoTextFace.
Mutating the result will also mutate Face.
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option represents additional optional configuration for a Face.
func Direction ¶
func Direction(d TextDirection) Option
Direction sets the Face's rendering direction.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source is a font source used to create Faces, which are used to draw text.
var DefaultSource Source
DefaultSource is a Source guaranteed to exist that may be used as a fallback.
func FindSource ¶
FindSource looks first for a pre-registered font source, registered by RegisterSource, and if that fails, searches the system for related fonts (via fuzzy match), then registers and returns that font source.
Safe to call from multiple goroutines simultaneously.
func NewSource ¶
NewSource creates a new font source from an io.Reader whose stream must be an OTF or TTF-formatted file.
func NewSourceFromBytes ¶
NewSourceFromBytes creates a new font source from the bytes of an OTF or TTF file.
func NewSourceFromFile ¶
NewSourceFromFile create a new font source from an OTF or TTF file.