Skip to content

fText: TextFormatter

Damian Monogue edited this page Feb 7, 2021 · 1 revision

Now with 100% less amnesia

The TextFormatter provides a reusable and adjustable way to format your text. It's like a demonnic:fText() you can take with you. It also provides a bit more type checking for some things. The other major difference is it defaults to formatType = c rather than uncolored, as I've found this to be the more common use case. The uncolored default was kept for cfText/align largely for historical reasons.

All of a TextFormatter's options can be adjusted/viewed via the options table. So if you make the formatter like testFormatter = demonnic.TextFormatter:new() then you can set and access the options table via testFormatter.options. However, where possible it is recommended that you use the set functions, as they provide more error handling and type checking. If you really know what you're doing and just want to change an option without the overhead of type checking and the like though, testFormatter.option.wrap = true would set the formatter's wrap option to true, etc.

ftext.TextFormatter:new(options)

options is a table of formatting options. Please see the API docs for a full list of options and the methods for interacting with them. formatType defaults to c rather than ""

ftext.TextFormatter:format()

Returns a string, formatted according to the formatter options being held by the TextFormatter

A picture is worth a thousand words

fText: TextFormatter: Examples should help you get started.