]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/batch/badges/skin.py
Add font hinting options for ttf version of Xolonium 4.0
[xonotic/xonstat.git] / xonstat / batch / badges / skin.py
index f18370f9d79546d9e1212cb840323191f457fff7..3b5b13b3286f491da07b8cc351f4ff56f4c27d25 100644 (file)
@@ -204,18 +204,16 @@ class Skin:
 
         # make sorted list of gametypes
         game_types = []
-        num_games  = 0
-        for gt,info in data['games_played'].items():
-            if gt == "overall":
+        for gt in data['games_played'].keys():
+            if gt == 'overall':
                 continue
-            if info.games > num_games:
-                game_types.insert(0, gt)
-            else:
-                game_types.append(gt)
-        
-        # make sure gametypes list if sorted correctly (number of games, descending)
-        game_types = sorted(game_types, key=lambda x: data['games_played'][x].games, reverse=True)
+            if elos.has_key(gt):
+                game_types.append(gt)  # only uses gametypes with elo values (needed later on)
 
+        ## make sure gametypes list if sorted correctly (number of games, descending)
+        ##game_types = sorted(game_types, key=lambda x: data['games_played'][x].games, reverse=True)
+        # make sure gametypes list if sorted correctly (total playing time per game type, descending)
+        game_types = sorted(game_types, key=lambda x: data['overall_stats'][x].total_playing_time, reverse=True)
 
 
         # build image
@@ -225,6 +223,13 @@ class Skin:
         self.ctx = ctx
         ctx.set_antialias(C.ANTIALIAS_GRAY)
 
+        # set font hinting options
+        fo = C.FontOptions()
+        fo.set_antialias(C.ANTIALIAS_GRAY)
+        fo.set_hint_style(C.HINT_STYLE_FULL)
+        fo.set_hint_metrics(C.HINT_METRICS_ON)
+        ctx.set_font_options(fo)
+
         # draw background
         if self.bg == None:
             if self.bgcolor != None:
@@ -271,7 +276,9 @@ class Skin:
         ## draw player's nickname with fancy colors
 
         # deocde nick, strip all weird-looking characters
-        qstr = qfont_decode(player.nick).replace('^^', '^').replace(u'\x00', '')
+        qstr = qfont_decode(qstr=player.nick, glyph_translation=True).\
+                replace('^^', '^').\
+                replace(u'\x00', '')
         #chars = []
         #for c in qstr:
         #    # replace weird characters that make problems - TODO
@@ -351,7 +358,7 @@ class Skin:
             if not elos.has_key(gt):
                 continue
             count += 1
-            
+
         # re-align segments if less than max. gametypes are shown
         if count > 0:
             if count < self.num_gametypes: