Handle tabs in fonts;

This commit is contained in:
bjorn 2018-11-11 18:28:34 -08:00
parent 185bb8438e
commit 4188fd53ec
1 changed files with 16 additions and 0 deletions

View File

@ -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;