Skip to content

Commit 8eac60a

Browse files
authored
Merge pull request #846 from pimoroni/patch-bitmap-fixed-space
Bitmap Fonts: Fixed-width space for #765.
2 parents 36f3e3a + 93525a4 commit 8eac60a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libraries/bitmap_fonts/bitmap_fonts.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ namespace bitmap {
152152
uint32_t line_offset = 0; // line (if wrapping) offset
153153
unicode_sorta::codepage_t codepage = unicode_sorta::PAGE_195;
154154

155+
int32_t space_width = measure_character(font, ' ', scale, codepage, fixed_width);
156+
space_width += letter_spacing * scale;
157+
155158
size_t i = 0;
156159
while(i < t.length()) {
157160
// find length of current word
@@ -201,7 +204,7 @@ namespace bitmap {
201204
line_offset += (font->height + 1) * scale;
202205
char_offset = 0;
203206
} else if (t[j] == ' ') { // Space
204-
char_offset += font->widths[0] * scale;
207+
char_offset += space_width;
205208
} else {
206209
switch(rotation) {
207210
case 0:

0 commit comments

Comments
 (0)