axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
923 stars 205 forks source link

RichText text formatting issue #1065

Closed rh101 closed 1 year ago

rh101 commented 1 year ago

Left-aligned text can result in spaces at the start of lines. This issue is not present in center and right aligned text.

The issue is visible in the screenshots below (with label debug draw turned on):

Actual: image

Expected: image

I've managed to fix the issue, but before I submit a PR, I need some input regarding the handling of text in this situation where there are spaces between words, like this:

This is just simple text, with, no XML tags. Testing the basics. Testing word-wrapping. Testing, Testing, Testing

In all text displays/editors I've entered that text into, the trailing spaces/leading spaces are always removed, but, if the spaces happen to be in the middle of a sentence, then they are not removed. At the moment, the implementation of RichText (with plain text) will delete all spaces except 1, but is that the desired behavior?

To highlight this issue, this is the display in an external editor: Sample 1: image Sample 2: image Sample 3: image

In Axmol/cocos2d-x, this is the result (regardless of alignment, always results in a max of 1 space between words): image image

Should this remain as-is, or should RichText reproduce the spaces between words (assuming the spaces are not at the start or end of a line)?

halx99 commented 1 year ago

It's HTML standard, so I think the space behavior is correct

rh101 commented 1 year ago

I understand, then the PR will just contain the fix for the space visible at the start of the line.