lightning-js / renderer

Lightning 3 Renderer
Apache License 2.0
54 stars 23 forks source link

SDF Text Layout Refactor #223

Open frank-weindel opened 6 months ago

frank-weindel commented 6 months ago

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.

elsassph commented 6 months ago

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.