Handle tabs in fonts;
@@ -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;
