britzl / defold-richtext

Defold-RichText is a system to create styled text based on an HTML inspired markup language
MIT License
75 stars 12 forks source link

Fix line layout when using combine_words #36

Closed dapetcu21 closed 5 years ago

dapetcu21 commented 5 years ago

Fixes #35

The way this is achieved is by splitting up the metering and creation steps for text nodes, so if I can combine the current node with the previous one on the line, I will modify the previous node and not create a new one.

combine_nodes also now doesn't merge nodes with different tags, because otherwise we could swallow custom user tags.

This also fixes richtext.characters() when used with combined nodes that contain whitespaces (since it ignored kerning, it would previously swallow whitespaces and merge words). I now measure the text up to and including the character to determine where each character is positioned.

dapetcu21 commented 5 years ago

Look at this nice kerning ❤️

Screenshot 2019-08-23 at 18 37 10
britzl commented 5 years ago

Thanks! Good changes!