Documentation ¶
Index ¶
- func CharacterSetASCII() []rune
- func CharacterSetGreek() []rune
- func FontToAtlas(font Font, atlas *sprite.Atlas) ([]rune, []int, error)
- func Render(target *image.RGBA, bounds math.Box2D[int], text string, font Font)
- type BitmapFont
- type Font
- type FontMetrics
- type RuneMetrics
- type RuneToSpriteMap
- type TrueTypeFont
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FontToAtlas ¶
Adds a font to a sprite atlas. Returns a list of runes and a matching list of sprite ids
Types ¶
type BitmapFont ¶
type BitmapFont struct {
// contains filtered or unexported fields
}
BitmapFont stores an image with equally sized font characters (runes). The runes are layed out in a grid.
func NewBitmapFont ¶
func NewBitmapFont(imageFile string, rows, columns int, runes []rune) (*BitmapFont, error)
Create a new bitmap from an imageFile. Rows and columns are the number of characters per column and row. glyphs are the characters in this bitmap image, the order of this array matches the order in the image (left to right, top to bot)
func (*BitmapFont) FontMetrics ¶
func (b *BitmapFont) FontMetrics() FontMetrics
func (*BitmapFont) GetRuneBounds ¶
Get bounding box (in pixels) of the rune in the bitmap image
func (*BitmapFont) Image ¶
func (b *BitmapFont) Image() *image.RGBA
func (*BitmapFont) RuneMetrics ¶
func (b *BitmapFont) RuneMetrics(r rune) RuneMetrics
func (*BitmapFont) Runes ¶
func (b *BitmapFont) Runes() []rune
type Font ¶
type Font interface { // Get the image representation of the font Image() *image.RGBA // Get render information for a rune RuneMetrics(r rune) RuneMetrics // Get font information FontMetrics() FontMetrics // Get the runes for which this font has glyphs Runes() []rune }
Font is the common interface for bitmap and ttf fonts
type FontMetrics ¶
type RuneMetrics ¶
type RuneMetrics struct { BoundingBox math.Box2D[int] //glyph fits inside this Adjust math.Vector2[int] Advance int }
RuneMetrics stores rune information: bounding box, origin and advance
type RuneToSpriteMap ¶
Holds runes and their corresponding sprite ids in two arrays whose indexes match.
func NewRuneToSpriteMap ¶
func NewRuneToSpriteMap(runes []rune, sprites []int) *RuneToSpriteMap
type TrueTypeFont ¶
type TrueTypeFont struct {
// contains filtered or unexported fields
}
TrueTypeFont holds an image with renders of characters from a true type font.
func NewTrueTypeFont ¶
func NewTrueTypeFont(fontFile string, fontSize float64, runes []rune) (*TrueTypeFont, error)
func (*TrueTypeFont) FontMetrics ¶
func (t *TrueTypeFont) FontMetrics() FontMetrics
func (*TrueTypeFont) Image ¶
func (t *TrueTypeFont) Image() *image.RGBA
func (*TrueTypeFont) RuneMetrics ¶
func (t *TrueTypeFont) RuneMetrics(r rune) RuneMetrics
func (*TrueTypeFont) Runes ¶
func (t *TrueTypeFont) Runes() []rune