diff --git a/src/Graphics.cpp b/src/Graphics.cpp index e05f3fc2d..fad82dfc2 100644 --- a/src/Graphics.cpp +++ b/src/Graphics.cpp @@ -439,8 +439,13 @@ int Graphics::textnwidth(char *s, int n) break; if(((char)*s)=='\b') { + if(!s[1]) break; s++; continue; + } else if(*s == '\x0F') { + if(!s[1] || !s[2] || !s[3]) break; + s+=3; + continue; } x += font_data[font_ptrs[(int)(*(unsigned char *)s)]]; n--; @@ -486,8 +491,14 @@ int Graphics::textwidthx(char *s, int w) { if((char)*s == '\b') { + if(!s[1]) break; s++; continue; + } else if (*s == '\x0F') + { + if(!s[1] || !s[2] || !s[3]) break; + s+=3; + continue; } cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]]; if (x+(cw/2) >= w) @@ -547,8 +558,14 @@ int Graphics::textwrapheight(char *s, int width) } else if (*s == '\b') { + if(!s[1]) break; s++; } + else if (*s == '\x0F') + { + if(!s[1] || !s[2] || !s[3]) break; + s+=3; + } else { cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]]; @@ -581,8 +598,14 @@ void Graphics::textsize(const char * s, int & width, int & height) cWidth = 0; cHeight += FONT_H+2; } + else if (*s == '\x0F') + { + if(!s[1] || !s[2] || !s[1]) break; + s+=3; + } else if (*s == '\b') { + if(!s[1]) break; s++; } else diff --git a/src/OpenGLGraphics.cpp b/src/OpenGLGraphics.cpp index ce65ad24c..b6f8f2abe 100644 --- a/src/OpenGLGraphics.cpp +++ b/src/OpenGLGraphics.cpp @@ -70,6 +70,7 @@ int Graphics::drawtext(int x, int y, const char *s, int r, int g, int b, int a) { if(!strlen(s)) return 0; + int oR = r, oG = g, oB = b; int width, height; Graphics::textsize(s, width, height); VideoBuffer texture(width, height); @@ -82,8 +83,23 @@ int Graphics::drawtext(int x, int y, const char *s, int r, int g, int b, int a) characterX = startX; characterY += FONT_H+2; } + else if (*s == '\x0F') + { + if(!s[1] || !s[2] || !s[3]) break; + r = s[1]; + g = s[2]; + b = s[3]; + s += 3; + } + else if (*s == '\x0E') + { + r = oR; + g = oG; + b = oB; + } else if (*s == '\b') { + if(!s[1]) break; switch (s[1]) { case 'w': diff --git a/src/PixelMethods.inc b/src/PixelMethods.inc index eff0b6039..4d85f6006 100644 --- a/src/PixelMethods.inc +++ b/src/PixelMethods.inc @@ -6,6 +6,7 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int return 0; int width, height; + int oR = r, oG = g, oB = b; int characterX = x, characterY = y; int startX = characterX; for (; *s; s++) @@ -15,8 +16,23 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int characterX = startX; characterY += FONT_H+2; } + else if (*s == '\x0F') + { + if(!s[1] || !s[2] || !s[3]) break; + r = s[1]; + g = s[2]; + b = s[3]; + s += 3; + } + else if (*s == '\x0E') + { + r = oR; + g = oG; + b = oB; + } else if (*s == '\b') { + if(!s[1]) break; switch (s[1]) { case 'w':