diff --git a/demos/01-font.c b/demos/01-font.c index c21bb1b..d70cba9 100644 --- a/demos/01-font.c +++ b/demos/01-font.c @@ -10,6 +10,7 @@ int main() { #define FONT_JAPANESE FONT_FACE4 #define FONT_MONOSPACE FONT_FACE5 + #define FONT_WHITE FONT_COLOR1 #define FONT_GRAY FONT_COLOR2 #define FONT_ORANGE FONT_COLOR3 #define FONT_LIME FONT_COLOR4 @@ -139,7 +140,7 @@ int main() { { vec2 pos = vec2(1990,820); ddraw_push_2d(); - char *txt = FONT_RIGHT FONT_BOTTOM "This is the first line.\nAnd now the second line.\n \nYou can do a third great line, too!\n"; + char *txt = FONT_RIGHT FONT_BOTTOM FONT_WHITE "This is the first line.\n" FONT_LIME "And now the second line.\n" FONT_WHITE "You can do a third great line, too!\n"; font_goto(pos.x, pos.y); vec2 size=font_rect(txt); font_metrics_t m=font_metrics(txt); diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 5c46322..b54ef1a 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -363957,16 +363957,18 @@ vec2 font_print_rect(const char *text, vec4 rect) { if (num_newlines > 1) { vec2 text_dims = font_rect(text); char tags[4] = {0}; - for (int i = 0, t = 0, end = strlen(text); i < end; ++i) { - char ch = text[i]; + int t=0; + while (*text) { + char ch = *text; if( (ch >= 1 && ch <= 6) || (ch >= 0x1a && ch <= 0x1f) || (ch >= 0x10 && ch <= 0x19)) { tags[t++] = ch; - ++text; } - + else break; + ++text; + if (t == 3) break; } array(char *) lines = strsplit(text, "\n"); diff --git a/engine/split/v4k_font.c b/engine/split/v4k_font.c index 66eec2e..dab347a 100644 --- a/engine/split/v4k_font.c +++ b/engine/split/v4k_font.c @@ -2399,16 +2399,18 @@ vec2 font_print_rect(const char *text, vec4 rect) { if (num_newlines > 1) { vec2 text_dims = font_rect(text); char tags[4] = {0}; - for (int i = 0, t = 0, end = strlen(text); i < end; ++i) { - char ch = text[i]; + int t=0; + while (*text) { + char ch = *text; if( (ch >= 1 && ch <= 6) || (ch >= 0x1a && ch <= 0x1f) || (ch >= 0x10 && ch <= 0x19)) { tags[t++] = ch; - ++text; } - + else break; + ++text; + if (t == 3) break; } array(char *) lines = strsplit(text, "\n"); diff --git a/engine/v4k.c b/engine/v4k.c index efc6c0f..dd68e72 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -11097,16 +11097,18 @@ vec2 font_print_rect(const char *text, vec4 rect) { if (num_newlines > 1) { vec2 text_dims = font_rect(text); char tags[4] = {0}; - for (int i = 0, t = 0, end = strlen(text); i < end; ++i) { - char ch = text[i]; + int t=0; + while (*text) { + char ch = *text; if( (ch >= 1 && ch <= 6) || (ch >= 0x1a && ch <= 0x1f) || (ch >= 0x10 && ch <= 0x19)) { tags[t++] = ch; - ++text; } - + else break; + ++text; + if (t == 3) break; } array(char *) lines = strsplit(text, "\n");