Documentation ¶
Index ¶
- Constants
- func BoundParagraph(face font.Face, text string, maxWidth int) image.Rectangle
- func BoundString(face font.Face, text string) image.Rectangle
- func DrawParagraph(dst *ebiten.Image, text string, face font.Face, clr color.Color, ...) float64
- func DrawString(dst *ebiten.Image, text string, face font.Face, clr color.Color, ...) error
- func Font(name string, size int) font.Face
- func LoadFontFromFile(name, path string) error
- type Alignment
Constants ¶
const ( Start = Alignment("start") End = Alignment("end") Center = Alignment("center") )
Variables ¶
This section is empty.
Functions ¶
func BoundParagraph ¶
func BoundString ¶
BoundString returns the measured size of a given string using a given font. This method will return the exact size in pixels that a string drawn by Draw will be. The bound's origin point indicates the dot (period) position. This means that if the text consists of one character '.', this dot is rendered at (0, 0).
This is very similar to golang.org/x/image/font's BoundString, but this BoundString calculates the actual rendered area considering multiple lines and space characters.
face is the font for text rendering. text is the string that's being measured.
Be careful that the passed font face is held by this package and is never released. This is a known issue (#498).
func DrawParagraph ¶
func DrawParagraph(dst *ebiten.Image, text string, face font.Face, clr color.Color, underline bool, maxWidth, maxHeight, cursor, scroll int, op ebiten.DrawImageOptions) float64
DrawParagraph draws a paragraph of text. It allows configuration of the maximum width and height of the text, wrapping words to constrain the width and limiting the lines drawn to constrain the height.
DrawParagraph returns the scroll position in [0, 1] if maxHeight and scroll are non-negative
face is the font for text rendering.
clr is the color for text rendering.
underline draws a line along the baseline.
maxWidth and maxHeight (both in pixels), when positive, turn on word wrapping and line limiting
cursor will draw a | character at the given boundary between two characters, when negative no cursor will be drawn
scroll sets the starting line and can be used with maxHeight to draw a scrollable window
op sets the transform used to control placement of the text
The '\n' newline character puts the following text on the next line. Line height is based on Metrics().Height of the font.
It is OK to call DrawParagraph with a same text and a same face at every frame in terms of performance. Glyphs used for rendering are cached in least-recently-used way.
Be careful that the passed font face is held by this package and is never released. This is a known issue (#498).
func DrawString ¶
func DrawString(dst *ebiten.Image, text string, face font.Face, clr color.Color, underline bool, width, height int, ha Alignment, va Alignment, cursor int, op ebiten.DrawImageOptions) error
DrawString draws a given text on a given destination image dst.
face is the font for text rendering.
clr is the color for text rendering.
underline draws a line along the baseline.
width, height, ha, and va specify the alignment of the text inside a box of width and height.
cursor will draw a | character at the given boundary between two characters, -1 means no cursor.
op sets the transform used to control placement of the text.
It is OK to call Draw with a same text and a same face at every frame in terms of performance. Glyphs used for rendering are cached in least-recently-used way.
Be careful that the passed font face is held by this package and is never released. This is a known issue (#498).