osu-framework icon indicating copy to clipboard operation
osu-framework copied to clipboard

`TextFlowContainer` no longer aligns text with different sizes on a baseline

Open frenzibyte opened this issue 4 years ago • 2 comments

CleanShot 2021-09-04 at 19 37 16

Notice the "Multiple Text Sizes" line not having the words aligned on one baseline, while each SpriteText implements IHasLineBaseHeight and TextFlowContainer has the logic for aligning them: https://github.com/ppy/osu-framework/blob/1a5fd5be8a947907056d0c4d3eda0bb8d56be4b3/osu.Framework/Graphics/Containers/TextFlowContainer.cs#L383-L410

After debugging through, it seems the logic behind retrieving childrenByLine isn't actually working, and is instead adding every single sprite text in the flow solely to its own line, causing the above baseline adjustment logic to never apply.

This is happening due to the logic relying on c.X > 0 to consider the children to be on the same line, but this is dependent on the flow layout code in FlowContainer to be called before, yet the TextFlowContainer layout update always runs before it:

https://github.com/ppy/osu-framework/blob/1a5fd5be8a947907056d0c4d3eda0bb8d56be4b3/osu.Framework/Graphics/Containers/TextFlowContainer.cs#L193-L202

Moving the base method call to be performed first before the text layout update seems to fix it, but caution needs to be taken on whether it's 100% the correct way.

frenzibyte avatar Sep 04 '21 17:09 frenzibyte

Did you try to bisect or blame this in any way? Would be good to know where this regressed when making the decision on how to fix.

bdach avatar Sep 04 '21 17:09 bdach

~~A bit hard to do it right now as I'm in the middle of something else, will see later today or tomorrow, if no one beats me to it.~~

Actually blaming I can do, and it appears that the update call order has actually intentionally changed in https://github.com/ppy/osu-framework/pull/2249, without taking the childrenByLine logic into account.

frenzibyte avatar Sep 04 '21 17:09 frenzibyte