The Text Layout engine for the SDF Text Renderer definitely needs a serious rework. The way the code, mostly in layoutText.ts is structured is brittle, difficult to understand, relies on hacks and is prone to infinite loops (see #220). But it also comes with certain functional limitations that aren't easy to resolve with the way the code is currently structured.
Overflow Suffix Limitation
There are at least a few issues with how the overflow suffix (i.e. the truncating "..." sequence) is placed, when contain is set to 'both':
If a single word, at the beginning of a line, can't fit on a line it is not truncated
The mechanism that tries to make sure a suffix fits at the end of a line can truncate text that fits the line pefectly.
Overflow suffix may bleed off the edge of the contained box width.
Solution
The solution is a refactor that simplifies the code flow and allows for more intelligent calculation/placement of the overflow suffix.
Worth also removing the overly complex "text state" system with dynamic properties overriding. A simpler object with a dirty flag would be better as it's not directly exposed to library users.
The Text Layout engine for the SDF Text Renderer definitely needs a serious rework. The way the code, mostly in layoutText.ts is structured is brittle, difficult to understand, relies on hacks and is prone to infinite loops (see #220). But it also comes with certain functional limitations that aren't easy to resolve with the way the code is currently structured.
Overflow Suffix Limitation
There are at least a few issues with how the overflow suffix (i.e. the truncating "..." sequence) is placed, when contain is set to 'both':
Solution
The solution is a refactor that simplifies the code flow and allows for more intelligent calculation/placement of the overflow suffix.