You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
raylib's Text wraps inline BBCode runs at the base font size. A fixed-width raylib Text
containing an enlarged inline run (a [FontSize=N] font swap or a [FontScale=N] multiplier) packs
words onto a base-measured line, so the enlarged run then spills past the wrap width — the same class
of bug fixed for the XNA-family (MonoGame/KNI/FNA) in #3529. raylib's inline-run size reporting was
already made font-aware in #3524; this is the remaining wrapping half.
This is the raylib follow-up split out of #3520 (which is now the XNA-family umbrella: size reporting
via #3523/#3524 and wrapping via #3529).
Root cause
The shared wrap loop IWrappedTextExtensions.UpdateLines (RenderingLibrary/Graphics/IWrappedText.cs)
now threads the current line's absolute stripped-text start index into a font-aware measurement seam, IWrappedText.MeasureString(string, int absoluteStartIndexInStrippedText) (a default interface method
added in #3529, base-font fallback). RenderingLibrary.Graphics.Text overrides that seam; raylib's Text does not, so it uses the base MeasureString and wraps base-only. Separately, raylib's CustomSetPropertyOnRenderable does not re-wrap after InlineVariables populate (the MonoGame copy
gained that in #3529), so even with the override the first wrap would remain blind to the runs.
Override MeasureString(string, int absoluteStartIndexInStrippedText) in Runtimes/RaylibGum/Renderables/Text.cs to split the range into styled runs (GetStyledSubstrings)
and sum each run measured at its own size, reusing raylib's ResolveRunFont / ResolveRunFontScale
helpers (added in RaylibGum Text: inline BBCode [FontSize] font-swap runs not supported (only Color/FontScale) #3524) so drawn / measured / wrapped run sizes stay consistent. Return width in the
same base units as the base MeasureString(string).
Re-wrap after the runs populate: in Runtimes/RaylibGum/Renderables/CustomSetPropertyOnRenderable.cs
call asText.UpdateWrappedText() before asText.UpdatePreRenderDimensions() (make raylib Text.UpdateWrappedText() public, mirroring the MonoGame change).
Pins in Tests/RaylibGum.Tests: a red-first test where a fixed-width Text with an inline [FontSize]/[FontScale] run wraps earlier than the base-font wrap; keep the plain-text wrap
behavior green.
Source
Runtimes/RaylibGum/Renderables/Text.cs — implements IWrappedText (~line 71), shared UpdateLines call in UpdateWrappedText (~681, currently private), GetInlineVariableAwareWidthAndHeight
(~1063), ResolveRunFont (~875). Needs the MeasureString(string, int) override.
Runtimes/RaylibGum/Renderables/CustomSetPropertyOnRenderable.cs — RawText set at ~704, InlineVariables populated at ~767, #3481 re-measure at ~777–781. Insert the re-wrap before 781.
Problem
raylib's
Textwraps inline BBCode runs at the base font size. A fixed-width raylibTextcontaining an enlarged inline run (a
[FontSize=N]font swap or a[FontScale=N]multiplier) packswords onto a base-measured line, so the enlarged run then spills past the wrap width — the same class
of bug fixed for the XNA-family (MonoGame/KNI/FNA) in #3529. raylib's inline-run size reporting was
already made font-aware in #3524; this is the remaining wrapping half.
This is the raylib follow-up split out of #3520 (which is now the XNA-family umbrella: size reporting
via #3523/#3524 and wrapping via #3529).
Root cause
The shared wrap loop
IWrappedTextExtensions.UpdateLines(RenderingLibrary/Graphics/IWrappedText.cs)now threads the current line's absolute stripped-text start index into a font-aware measurement seam,
IWrappedText.MeasureString(string, int absoluteStartIndexInStrippedText)(a default interface methodadded in #3529, base-font fallback).
RenderingLibrary.Graphics.Textoverrides that seam; raylib'sTextdoes not, so it uses the baseMeasureStringand wraps base-only. Separately, raylib'sCustomSetPropertyOnRenderabledoes not re-wrap afterInlineVariablespopulate (the MonoGame copygained that in #3529), so even with the override the first wrap would remain blind to the runs.
Suggested fix (mirror #3529 on the raylib side)
MeasureString(string, int absoluteStartIndexInStrippedText)inRuntimes/RaylibGum/Renderables/Text.csto split the range into styled runs (GetStyledSubstrings)and sum each run measured at its own size, reusing raylib's
ResolveRunFont/ResolveRunFontScalehelpers (added in RaylibGum Text: inline BBCode [FontSize] font-swap runs not supported (only Color/FontScale) #3524) so drawn / measured / wrapped run sizes stay consistent. Return width in the
same base units as the base
MeasureString(string).Runtimes/RaylibGum/Renderables/CustomSetPropertyOnRenderable.cscall
asText.UpdateWrappedText()beforeasText.UpdatePreRenderDimensions()(make raylibText.UpdateWrappedText()public, mirroring the MonoGame change).Tests/RaylibGum.Tests: a red-first test where a fixed-widthTextwith an inline[FontSize]/[FontScale]run wraps earlier than the base-font wrap; keep the plain-text wrapbehavior green.
Source
Runtimes/RaylibGum/Renderables/Text.cs— implementsIWrappedText(~line 71), sharedUpdateLinescall inUpdateWrappedText(~681, currentlyprivate),GetInlineVariableAwareWidthAndHeight(~1063),
ResolveRunFont(~875). Needs theMeasureString(string, int)override.Runtimes/RaylibGum/Renderables/CustomSetPropertyOnRenderable.cs—RawTextset at ~704,InlineVariablespopulated at ~767,#3481re-measure at ~777–781. Insert the re-wrap before 781.RenderingLibrary/Graphics/Text.csoverride +Text.MeasureStyledLineInBaseUnits,IWrappedText.csseam + index threading,Gum/Wireframe/CustomSetPropertyOnRenderable.csre-wrap).