Maintain a dictionary of characters and widths. When a new textwrap is encountered, create a set of characters from the input text. For each character not in the lookup table, measure the width with blf.dimensions(font_id, character) and record it in the table. Then, perform the text wrapping by adding words until the size would exceed the wrapping width and inserting newlines where required (how to deal with text without spaces?).
Maintain a dictionary of characters and widths. When a new textwrap is encountered, create a
set
of characters from the input text. For each character not in the lookup table, measure the width withblf.dimensions(font_id, character)
and record it in the table. Then, perform the text wrapping by adding words until the size would exceed the wrapping width and inserting newlines where required (how to deal with text without spaces?).