Utilities for text layout, wrapping, and rendering.
Go to file
2024-09-19 21:22:21 -04:00
examples/test Have the test example stress the flow algorithm a bit more 2024-09-19 21:22:21 -04:00
old Back up old files 2024-09-10 11:17:10 -04:00
.editorconfig Add .editorconfig because why not 2024-09-10 11:17:52 -04:00
.gitignore Add test example 2024-09-10 15:52:56 -04:00
draw.go Add documentation on what the DrawBounds colors mean 2024-09-18 22:54:25 -04:00
flow_test.go Benchmark text flow 2024-09-19 21:05:18 -04:00
flow.go Fix LayoutBoundsSpace 2024-09-19 10:42:48 -04:00
go.mod Initial commit 2023-07-07 01:49:32 -04:00
go.sum Initial commit 2023-07-07 01:49:32 -04:00
LICENSE Initial commit 2023-07-07 01:49:32 -04:00
measure_test.go Add measurement stage 2024-09-10 11:20:08 -04:00
measure.go Add measurement stage 2024-09-10 11:20:08 -04:00
parse_test.go Benchmarks report token waste 2024-09-19 09:33:14 -04:00
parse.go 5 is the appears to be the sweet spot for average token len 2024-09-19 09:40:00 -04:00
README.md Update README.md 2024-09-10 11:17:29 -04:00
typesetter.go Sort methods of TypeSetter alphabetically 2024-09-19 21:10:02 -04:00

typeset

Go Reference

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:

  1. Tokenization
  2. Measurement
  3. 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.