Documentation ¶
Overview ¶
Package text implements text font support.
Index ¶
- 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) DrawText(text string) *image.RGBA
- func (f *Font) DrawTextOnImage(text string, x, y int, dst *image.RGBA)
- func (f *Font) MeasureText(text string) (int, int)
- func (f *Font) Metrics() font.Metrics
- func (f *Font) SetAttributes(attrib FontAttributes)
- func (f *Font) SetBgColor(color math32.Color4)
- func (f *Font) SetColor(fg math32.Color4)
- func (f *Font) SetDPI(dpi float64)
- func (f *Font) SetFgColor(color math32.Color4)
- func (f *Font) SetHinting(hinting font.Hinting)
- func (f *Font) SetLineSpacing(spacing float64)
- func (f *Font) SetPointSize(size float64)
- func (f *Font) SetScaleXY(x, y float64)
- type FontAttributes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StrFind ¶
StrFind returns the start and length of the rune at the specified position in the string
Types ¶
type Atlas ¶
type Atlas struct { Chars []CharInfo Image *image.RGBA Height int // Recommended vertical space between two lines of text Ascent int // Distance from the top of a line to its baseline Descent int // Distance from the bottom of a line to its baseline }
Atlas represents an image containing characters and the information about their location in the image
type Canvas ¶
Canvas is an image to draw on.
func NewCanvas ¶
NewCanvas creates a new Canvas with the specified width, height, and background color.
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 height in pixels // Normalized position of char in the image OffsetX float32 OffsetY float32 RepeatX float32 RepeatY float32 }
CharInfo contains the information to locate a character in an Atlas
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
Font represents a TrueType font face.
func NewFontFromData ¶
NewFontFromData creates and returns a new font object from the specified TTF data.
func (*Font) DrawText ¶
DrawText draws the specified text on a new, tightly fitting image, and returns a pointer to the image.
func (*Font) DrawTextOnImage ¶
DrawTextOnImage draws the specified text on the specified image at the specified coordinates.
func (*Font) MeasureText ¶
MeasureText returns the minimum width and height in pixels necessary for an image to contain the specified text. The supplied text string can contain line breaks.
func (*Font) SetAttributes ¶
func (f *Font) SetAttributes(attrib FontAttributes)
SetAttributes sets the font attributes.
func (*Font) SetBgColor ¶
SetBgColor sets the background color.
func (*Font) SetColor ¶
SetColor sets the text color to the specified value and makes the background color transparent. Note that for perfect transparency in the anti-aliased region it's important that the RGB components of the text and background colors match. This method handles that for the user.
func (*Font) SetFgColor ¶
SetFgColor sets the text color.
func (*Font) SetHinting ¶
SetHinting sets the hinting type.
func (*Font) SetLineSpacing ¶
SetLineSpacing sets the amount of spacing between lines (in terms of font height).
func (*Font) SetPointSize ¶
SetPointSize sets the point size of the font.
func (*Font) SetScaleXY ¶
SetScaleXY sets the ratio of actual pixel/GL point.