Replies: 2 comments
-
|
Off the top of my head, all of the text drawing is funneled through a couple functions in MGUI/MGUI.Core/UI/MGTextBlock.cs Lines 593 to 653 in 882ce4d I ran into issues where measuring a set of substrings and summing up their measurements wasn't always giving the same width as measuring the whole string at once. That difference caused problems with my text-wrapping logic and logic for parsing text runs out of text with inline formatting. So if you had text like "Hello [color=Red]World", splitting it up into "Hello " and "World" and measuring them both and adding the widths together could give a different resulting than just measuring "Hello World" |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for the remark. I’ll consider it and fix this behavior |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! Before opening a PR I'd like to get your feedback on the approach.
What is ITextEngine?
Currently all text measurement and rendering in MGUI is hard-coded against MonoGame's
SpriteFont(viaFontManager/FontSet). The idea is to introduce a small interface that abstracts the three operations the UI needs from a font backend:MGDesktop would gain a TextEngine property defaulting to a SpriteFontTextEngine that wraps the existing FontManager — zero breaking change, all existing behavior remains bit-for-bit identical. Individual elements can override it via TextEngineOverride.
SpriteFont vs FontStashSharp
MonoGame SpriteFont
FontStashSharp
Scope of the PR
Would you be open to this? Happy to discuss scope or adjust the approach if needed.
Beta Was this translation helpful? Give feedback.
All reactions