How to make ImGui::TextWrapped() function use GlyphExtraSpacing.y

#1

I need to increase the vertical line spacing when rendering text using TextWrapped() and I was thinking to modify this function to use GlyphExtraSpacing.y.

Is it much more complicated than somehow passing the GlyphExtraSpacing.y to ImGui::TextEx() and changing the line 158 in imgui_widgets.cpp from:

const float line_height = GetTextLineHeight();

to

const float line_height = GetTextLineHeight() + GlyphExtraSpacing.y;

?

Thank you!

#2

GlyphExtraSpacing.y is documented as “not supported” for now. And lower level ImDrawList::AddText() doesn’t know of line spacing apart from the main font size.

We could potentially make change to allow this to be changed at the ImFont level, but that would mean the spacing would be fixed for all uses of the font.

In theory this should be a style setting, not a font setting, which makes this a little more problematic to implement without adding an extra parameter to AddText(). It is planned and desirable to refactor all text functions as there are many features we want to support and this will be on the list, but right now it’s not really possible. :confused: