|
|
@ -231,17 +231,39 @@ static const int char_heights[] = { |
|
|
|
// library. AND HEAVILY MODIFIED
|
|
|
|
// library. AND HEAVILY MODIFIED
|
|
|
|
void LCD_setStrEx(const char *dString, int x, int y, enum Color color, struct TextStyle style) |
|
|
|
void LCD_setStrEx(const char *dString, int x, int y, enum Color color, struct TextStyle style) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const int x0 = x; |
|
|
|
struct Utf8Char uchar; |
|
|
|
struct Utf8Iterator iter; |
|
|
|
struct Utf8Iterator iter; |
|
|
|
Utf8Iterator_Init(&iter, dString); |
|
|
|
Utf8Iterator_Init(&iter, dString); |
|
|
|
|
|
|
|
|
|
|
|
int charw = char_widths[style.size]; |
|
|
|
int charw = char_widths[style.size]; |
|
|
|
int charh = char_heights[style.size]; |
|
|
|
int charh = char_heights[style.size]; |
|
|
|
|
|
|
|
|
|
|
|
int spacingx = char_spacings[style.size] + style.spacing_x; |
|
|
|
int spacingx = char_spacings[style.size] + style.spacing_x; |
|
|
|
int spacingy = style.spacing_y; |
|
|
|
int spacingy = style.spacing_y; |
|
|
|
|
|
|
|
|
|
|
|
struct Utf8Char uchar; |
|
|
|
if (style.align != ALIGN_LEFT) { |
|
|
|
|
|
|
|
int line_len = 0; |
|
|
|
|
|
|
|
int skip = style.skip; |
|
|
|
|
|
|
|
while ((uchar = Utf8Iterator_Next(&iter)).uint) { |
|
|
|
|
|
|
|
if (skip > 0) { |
|
|
|
|
|
|
|
skip -= 1; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (uchar.bytes[0] == '\n') { |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
line_len++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (style.align == ALIGN_CENTER) { |
|
|
|
|
|
|
|
x -= ((charw + spacingx) * line_len) / 2 - spacingx/2; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// right
|
|
|
|
|
|
|
|
x -= ((charw + spacingx) * line_len) - spacingx; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int x0 = x; |
|
|
|
|
|
|
|
Utf8Iterator_Init(&iter, dString); |
|
|
|
|
|
|
|
|
|
|
|
int limit = style.limit; |
|
|
|
int limit = style.limit; |
|
|
|
int skip = style.skip; |
|
|
|
int skip = style.skip; |
|
|
|
bool wrap; |
|
|
|
bool wrap; |
|
|
|