flame-engine / flame

A Flutter based game engine.
https://flame-engine.org
MIT License
8.98k stars 879 forks source link

fix: Fix text rendering issue where spaces are missing #3192

Closed luanpotter closed 1 week ago

luanpotter commented 3 weeks ago

Description

Fix text rendering issue where spaces end up missing.

What happens is that if a single paragraph is split into multiple spans, due to having different formatting, for example, the layouting engine will run into an edge case when trying to place the last span. It will:

That is not normally an issue because if it doesn't fit, it will go to the next line and the space becomes unnecessary in that case. But in case we are still trying to populate the same line, we need to make sure we don't "eat up" the space.

There could be other similar edge cases where a space could go missing, so I opted to make it explicit whether the initial space should be added or not by adding a parameter to determine if it is the start of a new line or not.

Examples

Before:

image

image

After:

image

image

Checklist

Breaking Change?