From: Jan D. Behrens Date: Mon, 27 Aug 2012 22:38:30 +0000 (+0200) Subject: Improved handling of whitespace in playernicks X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=63092758d5d458c69994b18a9e37507a4e98f47d;p=xonotic%2Fxonstat.git Improved handling of whitespace in playernicks --- diff --git a/xonstat/batch/badges/gen_badges.py b/xonstat/batch/badges/gen_badges.py index d554560..efd00f0 100644 --- a/xonstat/batch/badges/gen_badges.py +++ b/xonstat/batch/badges/gen_badges.py @@ -262,6 +262,8 @@ def render_image(data): xoff, yoff, tw, th = ctx.text_extents(stripped_nick)[:4] if tw > NICK_MAXWIDTH: ctx.set_font_size(12) + xoff, yoff, tw, th = ctx.text_extents("_")[:4] + space_w = tw # split up nick into colored segments and draw each of them @@ -306,7 +308,7 @@ def render_image(data): ctx.show_text(txt) xoff, yoff, tw, th = ctx.text_extents(txt)[:4] - tw += (len(txt)-len(txt.strip()))*3 # account for lost whitespaces + tw += (len(txt)-len(txt.strip())) * space_w # account for lost whitespaces xoffset += tw + 2