Following rP26889, I noticed a bug with right-alignment of text.
As it turns out, everything is broken™. The bug was invisible before rP26889 because of the x = dx change that I suggested last-minute (see diff-of-diff)
Anyways, here's the trouble:
- In ComputeLineSize, we removed a ' ' worth of space when wrapping, because we want to ignore the space between words.
- In AssembleCalls (and the constructor), we didn't, causing long words to sometimes get wrapped to the next line (see below) unexpectedly, breaking the layout.
- But the behaviour in ComputeLineSize is wrong anyways, because there is actually no guarantee that the word-separator is a space.
- And we didn't ignore spaces when not-wrapping, which is also broken for center/right-alignment.
To fix this mess, my proposition is to add some data to the feedback to know is the last bit of a word is a space for alignment purposes.
If yes, ignore that space in all three relevant functions: CGuiText(), ComputeLineSize and AssembleCalls.
The duplication in logic in those functions is annoying but that refactoring is for another day I'm afraid.
Compare SVN & with the fix: