Documentation ¶
Overview ¶
Package text implements text font support.
Index ¶
- Constants
- func Color4NRGBA(c *math32.Color4) color.NRGBA
- func StrCount(s string) int
- func StrFind(s string, pos int) (start, length int)
- func StrInsert(s, data string, col int) string
- func StrPrefix(text string, pos int) string
- func StrRemove(s string, col int) string
- type Atlas
- type Canvas
- type CharInfo
- type Font
- func (f *Font) BgColor4() math32.Color4
- func (f *Font) DPI() float64
- func (f *Font) FgColor4() math32.Color4
- func (f *Font) MeasureText(text string) (int, int)
- func (f *Font) Metrics() font.Metrics
- func (f *Font) SetBgColor(color *math32.Color)
- func (f *Font) SetBgColor4(color *math32.Color4)
- func (f *Font) SetDPI(dpi float64)
- func (f *Font) SetFgColor(color *math32.Color)
- func (f *Font) SetFgColor4(color *math32.Color4)
- func (f *Font) SetHinting(hinting font.Hinting)
- func (f *Font) SetLineSpacing(spacing float64)
- func (f *Font) SetSize(size float64)
- func (f *Font) Size() float64
Constants ¶
const ( HintingNone = font.HintingNone HintingVertical = font.HintingVertical HintingFull = font.HintingFull )
Variables ¶
This section is empty.
Functions ¶
func Color4NRGBA ¶
Color4NRGBA converts a math32.Color4 to Go's image/color.NRGBA NON pre-multiplied alpha.
func StrFind ¶
StrFind returns the start and length of the rune at the specified position in the string
Types ¶
type Atlas ¶
type Canvas ¶
Canvas is an image to draw text
func NewCanvas ¶
NewCanvas creates and returns a pointer to a new canvas with the specified width and height in pixels and background color
func (Canvas) DrawText ¶
DrawText draws text at the specified position (in pixels) of this canvas, using the specified font. The supplied text string can contain line break escape sequences (\n).
func (Canvas) DrawTextCaret ¶
DrawTextCaret draws text at the specified position (in pixels) of this canvas, using the specified font, and also a caret at the specified line and column. The supplied text string can contain line break escape sequences (\n).
type CharInfo ¶
type CharInfo struct { X int // Position X in pixels in the sheet image from left to right Y int // Position Y in pixels in the sheet image from top to bottom Width int // Char width in pixels Height int // Char heigh in pixels // Normalized position of char in the image OffsetX float32 OffsetY float32 RepeatX float32 RepeatY float32 }
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
func NewFontFromData ¶
NewFontFromData creates and returns a new font object from the specified data
func (*Font) MeasureText ¶
MeasureText returns the maximum width and height in pixels necessary for an image to contain the specified text. The supplied text string can contain line break escape sequences (\n).
func (*Font) SetBgColor ¶
SetBgColor sets the current foreground color of the font The alpha value is set to 1 (opaque)
func (*Font) SetBgColor4 ¶
SetBgColor sets the current background color of the font
func (*Font) SetFgColor ¶
SetFgColor sets the current foreground color of the font The alpha value is set to 1 (opaque)
func (*Font) SetFgColor4 ¶
SetFgColor4 sets the current foreground color of the font
func (*Font) SetHinting ¶
SetHinting sets the hinting type
func (*Font) SetLineSpacing ¶
SetLineSpacing sets the spacing between lines