]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Improved handling of whitespace in playernicks
authorJan D. Behrens <zykure@web.de>
Mon, 27 Aug 2012 22:38:30 +0000 (00:38 +0200)
committerJan D. Behrens <zykure@web.de>
Mon, 27 Aug 2012 22:38:30 +0000 (00:38 +0200)
xonstat/batch/badges/gen_badges.py

index d554560712a4e6101e8ca72082b72fab361c0213..efd00f0128ee46778b72583df25b369d5126bbd9 100644 (file)
@@ -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