diff options
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/client/gfx.cpp | 10 | ||||
| -rw-r--r-- | src/engine/interface.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/engine/client/gfx.cpp b/src/engine/client/gfx.cpp index f6295620..7b0b421e 100644 --- a/src/engine/client/gfx.cpp +++ b/src/engine/client/gfx.cpp @@ -731,12 +731,18 @@ void gfx_pretty_text(float x, float y, float size, const char *text) gfx_quads_end(); } -float gfx_pretty_text_width(float size, const char *text) +float gfx_pretty_text_width(float size, const char *text, int length) { const float spacing = 0.05f; float w = 0.0f; - while (*text) + const char *stop; + if (length == -1) + stop = text + strlen(text); + else + stop = text + length; + + while (text < stop) { const int c = *text; const float width = current_font->m_CharEndTable[c] - current_font->m_CharStartTable[c]; diff --git a/src/engine/interface.h b/src/engine/interface.h index 10a8794b..ba8dacce 100644 --- a/src/engine/interface.h +++ b/src/engine/interface.h @@ -750,7 +750,7 @@ float client_intratick(); int client_tickspeed(); void gfx_pretty_text(float x, float y, float size, const char *text); -float gfx_pretty_text_width(float size, const char *text); +float gfx_pretty_text_width(float size, const char *text, int length = -1); void gfx_getscreen(float *tl_x, float *tl_y, float *br_x, float *br_y); |