Indented lines of text not working with TextBox

Hi there, I’m trying to draw some source code (indented with tabs) using gl::TextureFont::drawStringWrapped(), but it’s not respecting the tabs (tested on Windows). So I replaced the tabs by spaces, but it still seems to strip whitespace at the start of lines…

I think it’s the function TextBox::calculateLineBreaks() that’s not calculating the glyphs correctly. Aha – I just found this comment in the function lineBreakUtf8():

// eat any spaces we'd start on on the next line

Any suggestions on how to avoid this behaviour? It’s pretty deeply ingrained in the glyph calculation code, and I don’t see a way to switch it off (e.g. using DrawOptions).


Hmm, the hacky workaround I discovered was to add spaces after tabs at the start of indented lines (rather than replacing the tabs, just add spaces after them). Because the TextBox code doesn’t check for “any whitespace” at the start of lines, but specifically for ' ' (the space character)… So, that works (if a bit hacky), and I can now see my nicely indented code. :wink: