ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.58k stars 360 forks source link

Update the ui_text code to have less duplications and simplier renderer #8854

Open Districh-ru opened 1 week ago

Districh-ru commented 1 week ago

This PR changes the fheroes2::Text behavior to calculate text parameters only once and then use them for width, height, rows count and rendering.

This PR changes all texts rendering including buttons text.

ihhub commented 6 days ago

Hi @Districh-ru , would you be okay to merge this change after 1.1.1 release? I am worried that since we are getting close to the release we might face some issues with such a big change.

ihhub commented 6 days ago

Additionally, I noticed that the text is rendered differently with these changes. Is it intentional?

Districh-ru commented 6 days ago

Additionally, I noticed that the text is rendered differently with these changes. Is it intentional?

If you are talking about the MultiFontText: previously the next line offset was considered as the biggest line height of all texts. IMHO it was done to easily calculate text height ( lines_count * line_height ). Now the next line offset is the height of the current font in which the \n is used: like it is used to work in most modern text editors. It can be changed to the previous implementation if it is needed. It can be discussed.

If this differences are in the fheroes2::Text then please let me now where it is - I'll fix it.