Documentation ¶
Index ¶
- type PixelFont
- func (pf *PixelFont) DoLayout(text string, do func(pos image.Point, img *ebiten.Image))
- func (pf *PixelFont) DoLayoutRect(text string, rect image.Rectangle, do func(pos image.Point, img *ebiten.Image))
- func (pf *PixelFont) Measure(text string, origin image.Point) image.Rectangle
- func (pf *PixelFont) MeasureRect(text string, rect image.Rectangle) image.Rectangle
- func (pf *PixelFont) Print(screen *ebiten.Image, origin image.Point, text string)
- func (pf *PixelFont) PrintOpts(screen *ebiten.Image, origin image.Point, text string, ...)
- func (pf *PixelFont) PrintRect(screen *ebiten.Image, rect image.Rectangle, text string)
- func (pf *PixelFont) PrintRectOpts(screen *ebiten.Image, rect image.Rectangle, text string, ...)
- func (pf *PixelFont) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PixelFont ¶
type PixelFont struct { // Tightness is divided by the width of the lowercase 'm' to define the width of a space, which is // always at least one pixel. Tightness int // contains filtered or unexported fields }
PixelFont represents a single pixel font.
func LoadPixelFont ¶
LoadPixelFont loads and parses a PixelFont from the provided fs.FS. This func uses image.Decode, callers will need to include the correct anonymous import from the image package in order to use this func properly. For example:
import _ "image/png" var pf = LoadPixelFont("my_font.png", os.DirFS("."))
The image loaded contains all of the information needed to parse and use the font. An example font is included in the README for this package.
func (*PixelFont) DoLayout ¶
DoLayout calls do for each rune in the provided text, passing the relative position of the letter from the origin, and a subimage containing the glyph to be rendered.
This func is intended to be used to create your own text effects or animations without worrying about layout.
func (*PixelFont) DoLayoutRect ¶ added in v0.2.0
func (pf *PixelFont) DoLayoutRect(text string, rect image.Rectangle, do func(pos image.Point, img *ebiten.Image))
DoLayoutRect lays out the provided text in the provided rectangle, left-justified, with word wrapping. In case of long words that exceed the bounds of rect, the word-wrapping provided by this function extends the boundaries of rect, rather than breaking the word onto separate lines.
func (*PixelFont) Measure ¶
Measure measures the rectangle the text would be rendered in if it were to be written to screen using Print.
func (*PixelFont) MeasureRect ¶ added in v0.2.0
MeasureRect measures the rectangle the text would be rendered in if it were to be written to screen using PrintRect
func (*PixelFont) Print ¶ added in v0.2.0
Print lays out the runes for the provided text, left-justified, with the top-left corner of the text at the provided origin. No automatic wrapping is included.
func (*PixelFont) PrintOpts ¶ added in v0.3.0
func (pf *PixelFont) PrintOpts(screen *ebiten.Image, origin image.Point, text string, opts *ebiten.DrawImageOptions)
PrintOpts works like Print, using options from the provided opts. GeoM is reset prior to drawing.
func (*PixelFont) PrintRect ¶ added in v0.2.0
PrintRect prints the provided text, left-justified, with the top-left corner of the text at the provided origin. Text is line-wrapped so that all the characters lie within the provided rectangle. No word-wrapping is attempted.