debug | ||
examples/test | ||
internal | ||
.editorconfig | ||
.gitignore | ||
draw.go | ||
flow_test.go | ||
flow.go | ||
go.mod | ||
go.sum | ||
LICENSE | ||
measure_test.go | ||
measure.go | ||
parse_test.go | ||
parse.go | ||
README.md | ||
recommend.go | ||
typesetter.go |
typeset
Typeset provides utilities for text layout, wrapping, and rendering. It is designed to avoid redundant work and minimize memory allocations wherever posible in situations where the bounds of a section of text may change frequently and its content semi-frequently. Text layout is performed by the TypeSetter struct, which operates in a three-phase process:
- Tokenization
- Measurement
- Layout, alignment
The results of these phases are memoized. When the state of the TypeSetter is queried, it will run through only the required phases before returning a value.
The contents of a TypeSetter can be drawn onto any draw.Image using the Draw function included within this package, but it is entirely possible to create a custom draw function that iterates over TypeSetter.Runes that uses some other method of drawing that's faster than five gazillion virtual method calls.