Documentation ¶
Index ¶
- type Align
- type Drawer
- type LineLayout
- type RuneIterator
- type RuneLayout
- type TypeSetter
- func (setter *TypeSetter) AtPosition(position fixed.Point26_6) (index int)
- func (setter *TypeSetter) Em() (width fixed.Int26_6)
- func (setter *TypeSetter) Face() font.Face
- func (setter *TypeSetter) For(iterator RuneIterator)
- func (setter *TypeSetter) Height() int
- func (setter *TypeSetter) LayoutBounds() image.Rectangle
- func (setter *TypeSetter) LayoutBoundsSpace() image.Rectangle
- func (setter *TypeSetter) Length() int
- func (setter *TypeSetter) LineHeight() fixed.Int26_6
- func (setter *TypeSetter) MinimumSize() image.Point
- func (setter *TypeSetter) PositionAt(index int) (position fixed.Point26_6)
- func (setter *TypeSetter) ReccomendedHeightFor(width int) (height int)
- func (setter *TypeSetter) SetAlign(horizontal, vertical Align)
- func (setter *TypeSetter) SetFace(face font.Face)
- func (setter *TypeSetter) SetHeight(heignt int)
- func (setter *TypeSetter) SetText(text []rune)
- func (setter *TypeSetter) SetWidth(width int)
- func (setter *TypeSetter) SetWrap(wrap bool)
- func (setter *TypeSetter) Width() int
- type WordLayout
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Drawer ¶
type Drawer struct{ TypeSetter }
Drawer is an extended TypeSetter that is able to draw text. Much like TypeSetter, It has no constructor and its zero value can be used safely.
type LineLayout ¶
type LineLayout struct { Y fixed.Int26_6 Width fixed.Int26_6 ContentWidth fixed.Int26_6 SpaceAfter fixed.Int26_6 Words []WordLayout BreakAfter bool }
LineLayout contains layout information for a single line.
func DoLine ¶
func DoLine(text []rune, face font.Face, wrap bool, width fixed.Int26_6) (line LineLayout, remaining []rune)
DoLine consumes exactly one line from the given string, and produces a line layout according to the given font. It returns the remaining text as well. If wrap is set to true, this function will stop processing words once maxWidth is crossed. The word which would have crossed over the limit will not be processed.
func (*LineLayout) Align ¶
func (line *LineLayout) Align(align Align)
Align aligns the text in the line according to the specified alignment method.
func (*LineLayout) Length ¶ added in v0.5.0
func (line *LineLayout) Length() int
Length returns the amount of runes within the line, including the trailing line break if it exists.
type RuneIterator ¶
RuneIterator is a function that can iterate accross a typesetter's runes.
type RuneLayout ¶
RuneLayout contains layout information for a single rune relative to its word.
type TypeSetter ¶
type TypeSetter struct {
// contains filtered or unexported fields
}
TypeSetter manages several lines of text, and can perform layout operations on them. It automatically avoids performing redundant work. It has no constructor and its zero value can be used safely.
func (*TypeSetter) AtPosition ¶
func (setter *TypeSetter) AtPosition(position fixed.Point26_6) (index int)
AtPosition returns the index of the rune at the specified position.
func (*TypeSetter) Em ¶
func (setter *TypeSetter) Em() (width fixed.Int26_6)
Em returns the width of one emspace according to the typesetter's font, which is the width of the capital letter 'M'.
func (*TypeSetter) Face ¶
func (setter *TypeSetter) Face() font.Face
Face returns the TypeSetter's font face as set by SetFace.
func (*TypeSetter) For ¶
func (setter *TypeSetter) For(iterator RuneIterator)
For calls the specified iterator for every rune in the typesetter. If the iterator returns false, the loop will immediately stop.
func (*TypeSetter) Height ¶ added in v0.5.3
func (setter *TypeSetter) Height() int
Height returns the height of the typesetter as set by SetHeight.
func (*TypeSetter) LayoutBounds ¶
func (setter *TypeSetter) LayoutBounds() image.Rectangle
LayoutBounds returns the semantic bounding box of the text. The origin point (0, 0) of the rectangle corresponds to the origin of the first line's baseline.
func (*TypeSetter) LayoutBoundsSpace ¶
func (setter *TypeSetter) LayoutBoundsSpace() image.Rectangle
LayoutBoundsSpace is like LayoutBounds, but it also takes into account the trailing whitespace at the end of each line (if it exists).
func (*TypeSetter) Length ¶
func (setter *TypeSetter) Length() int
Length returns the amount of runes in the typesetter.
func (*TypeSetter) LineHeight ¶
func (setter *TypeSetter) LineHeight() fixed.Int26_6
LineHeight returns the height of one line according to the typesetter's font.
func (*TypeSetter) MinimumSize ¶ added in v0.4.0
func (setter *TypeSetter) MinimumSize() image.Point
MinimumSize returns the minimum width and height needed to display text. If wrapping is enabled, this method will return (Em(), 0)
func (*TypeSetter) PositionAt ¶
func (setter *TypeSetter) PositionAt(index int) (position fixed.Point26_6)
PositionAt returns the position of the rune at the specified index.
func (*TypeSetter) ReccomendedHeightFor ¶
func (setter *TypeSetter) ReccomendedHeightFor(width int) (height int)
ReccomendedHeightFor returns the reccomended max height if the text were to have its maximum width set to the given width. This does not alter the typesetter's state.
func (*TypeSetter) SetAlign ¶
func (setter *TypeSetter) SetAlign(horizontal, vertical Align)
SetAlign sets the alignment method of the typesetter.
func (*TypeSetter) SetFace ¶
func (setter *TypeSetter) SetFace(face font.Face)
SetFace sets the font face of the typesetter.
func (*TypeSetter) SetHeight ¶ added in v0.6.0
func (setter *TypeSetter) SetHeight(heignt int)
SetHeight sets the height of the typesetter. If the height is greater than zero, no lines will be laid out past it. If the height is zero, the text's maximum height will not be constrained.
func (*TypeSetter) SetText ¶
func (setter *TypeSetter) SetText(text []rune)
SetText sets the text content of the typesetter.
func (*TypeSetter) SetWidth ¶ added in v0.6.0
func (setter *TypeSetter) SetWidth(width int)
SetWidth sets the width of the typesetter. Text will still be able to overflow outside of this width if wrapping is disabled.
func (*TypeSetter) SetWrap ¶ added in v0.4.0
func (setter *TypeSetter) SetWrap(wrap bool)
SetWrap sets whether or not the text wraps around and forms new lines.
func (*TypeSetter) Width ¶ added in v0.5.3
func (setter *TypeSetter) Width() int
Width returns the height of the typesetter as set by SetWidth.
type WordLayout ¶
type WordLayout struct { X fixed.Int26_6 Width fixed.Int26_6 SpaceAfter fixed.Int26_6 Runes []RuneLayout }
WordLayout contains layout information for a single word relative to its line.
func DoWord ¶
func DoWord(text []rune, face font.Face) (word WordLayout, remaining []rune)
DoWord consumes exactly one word from the given string, and produces a word layout according to the given font. It returns the remaining text as well.
func (WordLayout) FirstRune ¶
func (word WordLayout) FirstRune() rune
FirstRune returns the last rune in the word.
func (WordLayout) LastRune ¶
func (word WordLayout) LastRune() rune
LastRune returns the last rune in the word.