Commit 65efd6bc authored by schneider's avatar schneider
Browse files

Merge branch 'display_multiline_fix' into 'master'

fix(gfx): Break line before char is printed

See merge request card10/firmware!149
parents d29f8f95 73876f4b
...@@ -86,17 +86,25 @@ void gfx_puts( ...@@ -86,17 +86,25 @@ void gfx_puts(
Color fg, Color fg,
Color bg Color bg
) { ) {
// iterate over the string
while (*str) { while (*str) {
gfx_putchar(font, r, x, y, *str, fg, bg); // if the current position plus the width of the next character
str++; // would bring us outside of the display ...
if ((x + font->Width) > r->width) {
x += font->Width; // ... we move down a line before printing the character
if (x >= r->width) {
x = 0; x = 0;
y += font->Height; y += font->Height;
} }
// if the line is outside the display we return
if (y >= r->height) if (y >= r->height)
return; return;
// now print the character
gfx_putchar(font, r, x, y, *str, fg, bg);
str++;
// move along on the x axis to get the position of the next character
x += font->Width;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment