Documentation
¶
Index ¶
- Constants
- Variables
- func SetUIFont(role string, font *Font)
- func SetUIFonts(fonts map[string]*Font)
- type Buffer
- type Color
- type Face
- func (f *Face) Ascent() int
- func (f *Face) Close() error
- func (f *Face) Descent() int
- func (f *Face) DrawGlyph(dst draw.Image, r rune, x, y int, fg, bg color.Color)
- func (f *Face) DrawText(dst draw.Image, text string, x, y int, fg, bg color.Color)
- func (f *Face) LineHeight() int
- func (f *Face) Measure(text string) (int, int)
- func (f *Face) ShapeLine(line string) []ShapedGlyph
- type Font
- type Options
- type ShapedGlyph
Constants ¶
const ( UIFontParagraph = "paragraph" UIFontSubheading = "subheading" UIFontHeading = "heading" UIFontTitle = "title" )
Variables ¶
var ( ColorTransparent = core.ColorTransparent ColorWhite = core.ColorWhite NewBuffer = core.NewBuffer )
var BitmapFont = &Font{
Width: 8,
Height: 16,
FirstRun: 32,
LastRun: 126,
Glyphs: defaultGlyphs,
}
BitmapFont is the built-in 8x16 bitmap font.
var DefaultFont = BitmapFont
DefaultFont is the active font used by graphics and UI.
Functions ¶
func SetUIFonts ¶
SetUIFonts sets multiple UI role fonts at once.
Types ¶
type Face ¶
type Face struct {
// contains filtered or unexported fields
}
Face is a pure-Go anti-aliased TTF renderer.
func NewDefault ¶
NewDefault returns a TTF renderer backed by gofont/goregular.
func NewFromFile ¶
NewFromFile loads and parses a TTF file from disk.
func NewFromTTF ¶
NewFromTTF parses a TTF payload and returns a renderable face.
func (*Face) DrawText ¶
DrawText draws anti-aliased text at (x, y), where y is the top of the text box.
func (*Face) LineHeight ¶
LineHeight returns the configured line height in pixels.
func (*Face) ShapeLine ¶
func (f *Face) ShapeLine(line string) []ShapedGlyph
ShapeLine applies kerning-aware shaping to a single text line.
type Font ¶
type Font struct {
Width int
Height int
Glyphs map[rune][]byte
FirstRun rune
LastRun rune
// contains filtered or unexported fields
}
Font represents either a bitmap font or a vector TTF-backed font.
func LoadTTFFont ¶
LoadTTFFont creates a gfxfont.Font from raw TTF bytes.
func LoadTTFFontFile ¶
LoadTTFFontFile creates a gfxfont.Font from a TTF file path.
func NewDefaultTTFFont ¶
NewDefaultTTFFont creates a gfxfont.Font using gofont/goregular.
func NewTTFFont ¶
NewTTFFont wraps a shaped TTF face for the graphics renderer.
func (*Font) TextHeight ¶
TextHeight returns the height of text in pixels.