]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Decoding of quake's qfont to ascii.
authorDavid Mazary <dmaz@vt.edu>
Fri, 11 Nov 2011 16:37:15 +0000 (11:37 -0500)
committerDavid Mazary <dmaz@vt.edu>
Fri, 11 Nov 2011 16:37:15 +0000 (11:37 -0500)
xonstat/util.py

index 4ef6c8097bb72da72759da1da034ce93fd7cafe1..ce94a71206d2b8314bce4e2f93eab82b09207bb4 100755 (executable)
@@ -1,6 +1,52 @@
 import re
 from datetime import datetime
 
+qfont_table = [
+ '\0', '#',  '#',  '#',  '#',  '.',  '#',  '#',
+ '#',  9,    10,   '#',  ' ',  13,   '.',  '.',
+ '[',  ']',  '0',  '1',  '2',  '3',  '4',  '5',
+ '6',  '7',  '8',  '9',  '.',  '<',  '=',  '>',
+ ' ',  '!',  '"',  '#',  '$',  '%',  '&',  '\'',
+ '(',  ')',  '*',  '+',  ',',  '-',  '.',  '/',
+ '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',
+ '8',  '9',  ':',  ';',  '<',  '=',  '>',  '?',
+ '@',  'A',  'B',  'C',  'D',  'E',  'F',  'G',
+ 'H',  'I',  'J',  'K',  'L',  'M',  'N',  'O',
+ 'P',  'Q',  'R',  'S',  'T',  'U',  'V',  'W',
+ 'X',  'Y',  'Z',  '[',  '\\', ']',  '^',  '_',
+ '`',  'a',  'b',  'c',  'd',  'e',  'f',  'g',
+ 'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',
+ 'p',  'q',  'r',  's',  't',  'u',  'v',  'w',
+ 'x',  'y',  'z',  '{',  '|',  '}',  '~',  '<',
+ '<',  '=',  '>',  '#',  '#',  '.',  '#',  '#',
+ '#',  '#',  ' ',  '#',  ' ',  '>',  '.',  '.',
+ '[',  ']',  '0',  '1',  '2',  '3',  '4',  '5',
+ '6',  '7',  '8',  '9',  '.',  '<',  '=',  '>',
+ ' ',  '!',  '"',  '#',  '$',  '%',  '&',  '\'',
+ '(',  ')',  '*',  '+',  ',',  '-',  '.',  '/',
+ '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',
+ '8',  '9',  ':',  ';',  '<',  '=',  '>',  '?',
+ '@',  'A',  'B',  'C',  'D',  'E',  'F',  'G',
+ 'H',  'I',  'J',  'K',  'L',  'M',  'N',  'O',
+ 'P',  'Q',  'R',  'S',  'T',  'U',  'V',  'W',
+ 'X',  'Y',  'Z',  '[',  '\\', ']',  '^',  '_',
+ '`',  'a',  'b',  'c',  'd',  'e',  'f',  'g',
+ 'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',
+ 'p',  'q',  'r',  's',  't',  'u',  'v',  'w',
+ 'x',  'y',  'z',  '{',  '|',  '}',  '~',  '<'
+]
+
+
+def qfont_decode(qstr=''):
+    """
+    Convert a name from qfont to ascii.
+    'qstr' must be a unicode string.
+    """
+    by = bytearray(qstr, 'latin_1')
+    return ''.join([qfont_table[b & 0xff] for b in by])
+
+
 def strip_colors(str=''):
     if str is None:
         str = ''