livesplit-core
livesplit-core copied to clipboard
Implement Wrapping Text and Line Breaks for Text Component
Unlike doing this for the title component where switching runs has the potential of changing the size of your layout, for the text component we can very uncontroversially implement line breaks and text that word wraps into multiple lines. We most likely either only want to do it for centered text. There may be ways to extend it to left / right mode too, but an initial implementation could just ignore that case. The implementation would use xi-unicode
for the line breaking algorithm. It gives you mandatory and optional line breaking opportunities. It remains to be seen if we want a setting (or multiple) for word wrap mode.
It seems like two row mode / horizontal + centered text doesn't actually vertically center the text properly. This may need a test and fix, or becomes irrelevant as we may want to just have centered text ignore two row mode altogether and just base its height on the amount of rows calculated by the line breaking. We almost definitely want a test for the behavior regarding horizontal mode though, as the line breaks would probably break out of the component's borders.
We use 0.8 as the font size (which is meant to also be the line height most of the time) and 1.0 as the default component height. This means that there's a vertical padding of 0.2 (0.1 on both sides). If we logically extend this to two rows we end up with 0.2 + 0.8 * 2 = 1.8, but our two row height is defined as 1.75. We may need to redefine the two row height for consistency with the line height.