diff --git a/src/graphics/font.c b/src/graphics/font.c index 80b21a26..aaf41917 100644 --- a/src/graphics/font.c +++ b/src/graphics/font.c @@ -106,6 +106,14 @@ void lovrFontRender(Font* font, const char* str, float wrap, HorizontalAlign hal continue; } + // Tabs + if (codepoint == '\t') { + Glyph* space = lovrFontGetGlyph(font, ' '); + cx += space->advance * 4; + str += bytes; + continue; + } + // Kerning cx += lovrFontGetKerning(font, previous, codepoint); previous = codepoint; @@ -180,6 +188,14 @@ float lovrFontGetWidth(Font* font, const char* str, float wrap) { continue; } + // Tabs + if (codepoint == '\t') { + Glyph* space = lovrFontGetGlyph(font, ' '); + x += space->advance * 4; + str += bytes; + continue; + } + Glyph* glyph = lovrFontGetGlyph(font, codepoint); x += glyph->advance + lovrFontGetKerning(font, previous, codepoint); previous = codepoint;