Skip to content

Commit d2c86c2

Browse files
authored
Merge pull request #1051 from ahnlak/measure-text-fix
Don't include the spacing after the final letter when measuring bitmap text
2 parents cfee94a + 6628efe commit d2c86c2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

libraries/bitmap_fonts/bitmap_fonts.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ namespace bitmap {
3939
text_width += letter_spacing * scale;
4040
codepage = unicode_sorta::PAGE_195; // Reset back to default
4141
}
42+
43+
// Do not include the spacing on the final character
44+
if (text_width>0) {
45+
text_width -= letter_spacing * scale;
46+
}
47+
4248
return text_width;
4349
}
4450

@@ -230,4 +236,4 @@ namespace bitmap {
230236
i = next_break += 1;
231237
}
232238
}
233-
}
239+
}

0 commit comments

Comments
 (0)