Skip to main content

Text

Text is one of the trickier parts of applications.

Hokusai provides a #text draw command for rendering text, as well as a text block, but often the position, style, wrapping, and size of text is a bigger challenge.

For this Hokusai has utilities written in C with ruby wrappers for processing and wrapping text on the fly

These methods are Hokusai::Font#clamp and Hokusai::Font#clamp_markdown. Both return a Hokusai::Font::Clamping

Clampings

For a given Hokusai::Font, there are methods that take a string, and an arbitrary width in which to render it.

The result is a clamping object that contains segments, which contain the lines of characters to render.

The hierarchy looks like:

Clamping 
-> has many Segments
-> has many Groups (which can represent styles or urls)
-> has many Chars

Markdown

A subset of Markdown is supported by default via Hokusai::Font#clamp_markdown, and is the best way to process styled text or http links in Hokusai.