From: Ant Zucaro Date: Sun, 11 May 2014 00:22:46 +0000 (-0400) Subject: Add Xolonium glyph support. No more ASCII-only! X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f12c58e59c214ff64dbe68addfe84daeb6f3b051;p=xonotic%2Fxonstat.git Add Xolonium glyph support. No more ASCII-only! Our wonderful font artist sev has been working hard on the Xolonium font for quite some time. He has posted a darkplaces to standard unicode code point mapping for me to utilize in turning the characters chosen in-game with actual glyphs in his font. The result is awesome! --- diff --git a/xonstat/static/css/app.css b/xonstat/static/css/app.css index ce2b71d..d628a43 100644 --- a/xonstat/static/css/app.css +++ b/xonstat/static/css/app.css @@ -1,16 +1,15 @@ /* Fonts */ @font-face { font-family: 'XoloniumNormal'; - src: url('fonts/xolonium-webfont.eot'); - src: url('fonts/xolonium-webfont.eot?#iefix') format('embedded-opentype'), - url('fonts/xolonium-webfont.woff') format('woff'), - url('fonts/xolonium-webfont.ttf') format('truetype'), - url('fonts/xolonium-webfont.svg#XoloniumNormal') format('svg'); + src: url('fonts/xolonium.eot'); + src: url('fonts/xolonium.eot?#iefix') format('embedded-opentype'), + url('fonts/xolonium.ttf') format('truetype'), + url('fonts/xolonium.woff') format('woff'), + url('fonts/xolonium.svg#xoloniumregular') format('svg'); font-weight: normal; font-style: normal; } - /* Primary elements */ body { background: url("img/web_background_4.jpg") no-repeat fixed center center / cover black; diff --git a/xonstat/static/css/app.min.css b/xonstat/static/css/app.min.css index d0a01e8..ad102ee 100644 --- a/xonstat/static/css/app.min.css +++ b/xonstat/static/css/app.min.css @@ -1 +1 @@ -@font-face{font-family:'XoloniumNormal';src:url('fonts/xolonium-webfont.eot');src:url('fonts/xolonium-webfont.eot?#iefix') format('embedded-opentype'),url('fonts/xolonium-webfont.woff') format('woff'),url('fonts/xolonium-webfont.ttf') format('truetype'),url('fonts/xolonium-webfont.svg#XoloniumNormal') format('svg');font-weight:normal;font-style:normal}body{background:url("img/web_background_4.jpg") no-repeat fixed center center / cover black;background-color:black;color:#d0d0d0;font-family:"XoloniumNormal","Helvetica Neue",Helvetica,Arial,sans-serif}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;color:#999}h1{font-size:30px;line-height:36px}h1 small{font-size:18px}h2{font-size:24px;line-height:36px}h2 small{font-size:18px}h3{line-height:27px;font-size:18px}h3 small{font-size:14px}h4,h5,h6{line-height:18px}h4{font-size:14px}h4 small{font-size:12px}h5{font-size:12px}h6{font-size:11px;color:#999;text-transform:uppercase}table{background:#000;background:none repeat scroll 0 0 rgba(0,0,0,0.7);border:1px solid #436688}table th{border:1px solid #436688;background-color:#001021}table td{border:1px solid #436688;font-size:10px}.table-hover>tbody>tr:hover>td,.table-hover>tbody>tr:hover>th{background-color:#222}.table th,.table td{border:1px solid #436688}.table td{vertical-align:middle}.table .tdcenter{text-align:center}.accordion-group{border:1px solid #272525}.accordion-inner{border:0}#statline{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;position:relative;top:-25px}#xonborder{background:#000;background:none repeat scroll 0 0 rgba(0,0,0,0.5);border-radius:15px 15px 15px 15px;margin-bottom:30px;margin-left:0;padding:20px}#title{color:#08c;font-size:30px;margin-bottom:15px;position:relative;text-align:center;text-shadow:2px 2px 3px #333}.indexform{margin:20px 0 20px 0}.indexbox{width:250px}.navbar-brand{margin-left:0;padding-bottom:0;padding-top:10px;text-align:left}.navbar-inverse{background:none repeat scroll 0 0 rgba(0,0,0,0.6)}.navbar-inverse .nav>.active>a,.navbar-inverse .nav>.active>a:hover,.navbar-inverse .nav>.active>a:focus{background:none repeat scroll 0 0 rgba(49,49,49,0.6)}.navbar-inverse .nav>li>a,.navbar-brand{font-family:XoloniumNormal}.search,input[type="search"]{background-color:#606060;border:1px solid #202020;color:#aaa;width:100px}.game{float:left;min-width:700px;padding:10px 7px}.game a{color:#CCC}.game a:hover{color:#d95f00;text-decoration:none}.game tr{background-color:#000}.game tr.red{background-color:#4d0000}.game tr.blue{background-color:#00004d}.game tr.yellow{background-color:#4d4d00}.game tr.pink{background-color:#4d004d}.game tr:hover{background-color:#222}.teamscore{text-align:right;text-shadow:-1px -1px 0 #222;font-size:20px;font-weight:bold;padding:10px 7px;margin-right:5px;margin-top:12px}.teamscore .teamname{font-size:12px}.teamscore .red{color:#ad0000}.teamscore .blue{color:#0000ad}.teamscore .yellow{color:#adad00}.teamscore .pink{color:#ad00ad}.player-score{color:#feff3a}.ping{width:50px}.weapon-nav{height:70px;margin-bottom:20px}.weapon-nav ul{display:block;list-style:none outside none}.weapon-nav li{cursor:pointer;float:left;margin-right:10px}.weapon-nav li:hover{border-bottom:2px solid #001021}.weapon-nav .weapon-active{border-bottom:2px solid #436688}.weapon-nav p{text-align:center}.flot table,.flot td{background-color:black;border:0}#gbtabcontainer{margin-top:10px}#gbtab{font-size:12px}.tabbable p{font-size:14px}.tabs-below .nav-tabs>li>a{border-radius:4px 4px 4px 4px}.nav-tabs>.active>a,.nav-tabs>.active>a:hover{background-color:#111;color:#aaa;border-color:#222}.nav-tabs>.active>a,.nav-tabs>.active>a:focus{background-color:#111;color:#aaa;border-color:#222}.nav-tabs>li>a{border-radius:4px 4px 4px 4px;text-align:center}.nav-tabs>li>a:hover{background-color:#111;border-color:#333}.nav-tabs{border-bottom:0 solid #000}.table .tdcenter{text-align:center}.game-detail img{float:left;margin-right:10px;margin-bottom:5px}.game img{float:left;margin-right:5px;margin-bottom:5px}.game-detail p,.game h4{float:left}.btn-toolbar .nav>li a{width:80px}.btn.dropdown-toggle,.btn.dropdown-toggle:active{background:0;border:1px solid transparent;border-radius:4px 4px 4px 4px;line-height:20px;color:#428bca;padding:10px 0 10px 0;font-size:14px;outline:0}.btn.dropdown-toggle:hover,.btn.dropdown-toggle:focus{background-color:#111;color:#2a6496;border-color:#333}.btn.dropdown-toggle>.caret{height:21px;border-top-color:#428bca;border-top-width:8px;border-left-width:8px;border-right-width:8px}.dropdown-menu{width:100px}.dropdown-menu.nav-tabs{padding:4px;background-color:#111;border:1px solid #333;width:256px}.dropdown-menu.nav-tabs>li>a{width:80px;color:inherit}.dropdown-menu.nav-tabs>li>a:hover{color:#222}.nostretch{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.player-nick{width:25%}.eloup{color:green}.elodown{color:#be0000}.eloneutral{color:gray}.pagination>li>a,.pagination>li>span{background-color:#111;border-color:#313131;color:#797979}.pagination>li>a:hover,.pagination>li>a:focus,.pagination>.active>a,.pagination>.active>span{background-color:#2b2222}@media(min-width:768px){.navbar-form{float:right}} +@font-face{font-family:'XoloniumNormal';src:url('fonts/xolonium.eot');src:url('fonts/xolonium.eot?#iefix') format('embedded-opentype'),url('fonts/xolonium.ttf') format('truetype'),url('fonts/xolonium.woff') format('woff'),url('fonts/xolonium.svg#xoloniumregular') format('svg');font-weight:normal;font-style:normal}body{background:url("img/web_background_4.jpg") no-repeat fixed center center / cover black;background-color:black;color:#d0d0d0;font-family:"XoloniumNormal","Helvetica Neue",Helvetica,Arial,sans-serif}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;color:#999}h1{font-size:30px;line-height:36px}h1 small{font-size:18px}h2{font-size:24px;line-height:36px}h2 small{font-size:18px}h3{line-height:27px;font-size:18px}h3 small{font-size:14px}h4,h5,h6{line-height:18px}h4{font-size:14px}h4 small{font-size:12px}h5{font-size:12px}h6{font-size:11px;color:#999;text-transform:uppercase}table{background:#000;background:none repeat scroll 0 0 rgba(0,0,0,0.7);border:1px solid #436688}table th{border:1px solid #436688;background-color:#001021}table td{border:1px solid #436688;font-size:10px}.table-hover>tbody>tr:hover>td,.table-hover>tbody>tr:hover>th{background-color:#222}.table th,.table td{border:1px solid #436688}.table td{vertical-align:middle}.table .tdcenter{text-align:center}.accordion-group{border:1px solid #272525}.accordion-inner{border:0}#statline{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;position:relative;top:-25px}#xonborder{background:#000;background:none repeat scroll 0 0 rgba(0,0,0,0.5);border-radius:15px 15px 15px 15px;margin-bottom:30px;margin-left:0;padding:20px}#title{color:#08c;font-size:30px;margin-bottom:15px;position:relative;text-align:center;text-shadow:2px 2px 3px #333}.indexform{margin:20px 0 20px 0}.indexbox{width:250px}.navbar-brand{margin-left:0;padding-bottom:0;padding-top:10px;text-align:left}.navbar-inverse{background:none repeat scroll 0 0 rgba(0,0,0,0.6)}.navbar-inverse .nav>.active>a,.navbar-inverse .nav>.active>a:hover,.navbar-inverse .nav>.active>a:focus{background:none repeat scroll 0 0 rgba(49,49,49,0.6)}.navbar-inverse .nav>li>a,.navbar-brand{font-family:XoloniumNormal}.search,input[type="search"]{background-color:#606060;border:1px solid #202020;color:#aaa;width:100px}.game{float:left;min-width:700px;padding:10px 7px}.game a{color:#CCC}.game a:hover{color:#d95f00;text-decoration:none}.game tr{background-color:#000}.game tr.red{background-color:#4d0000}.game tr.blue{background-color:#00004d}.game tr.yellow{background-color:#4d4d00}.game tr.pink{background-color:#4d004d}.game tr:hover{background-color:#222}.teamscore{text-align:right;text-shadow:-1px -1px 0 #222;font-size:20px;font-weight:bold;padding:10px 7px;margin-right:5px;margin-top:12px}.teamscore .teamname{font-size:12px}.teamscore .red{color:#ad0000}.teamscore .blue{color:#0000ad}.teamscore .yellow{color:#adad00}.teamscore .pink{color:#ad00ad}.player-score{color:#feff3a}.ping{width:50px}.weapon-nav{height:70px;margin-bottom:20px}.weapon-nav ul{display:block;list-style:none outside none}.weapon-nav li{cursor:pointer;float:left;margin-right:10px}.weapon-nav li:hover{border-bottom:2px solid #001021}.weapon-nav .weapon-active{border-bottom:2px solid #436688}.weapon-nav p{text-align:center}.flot table,.flot td{background-color:black;border:0}#gbtabcontainer{margin-top:10px}#gbtab{font-size:12px}.tabbable p{font-size:14px}.tabs-below .nav-tabs>li>a{border-radius:4px 4px 4px 4px}.nav-tabs>.active>a,.nav-tabs>.active>a:hover{background-color:#111;color:#aaa;border-color:#222}.nav-tabs>.active>a,.nav-tabs>.active>a:focus{background-color:#111;color:#aaa;border-color:#222}.nav-tabs>li>a{border-radius:4px 4px 4px 4px;text-align:center}.nav-tabs>li>a:hover{background-color:#111;border-color:#333}.nav-tabs{border-bottom:0 solid #000}.table .tdcenter{text-align:center}.game-detail img{float:left;margin-right:10px;margin-bottom:5px}.game img{float:left;margin-right:5px;margin-bottom:5px}.game-detail p,.game h4{float:left}.btn-toolbar .nav>li a{width:80px}.btn.dropdown-toggle,.btn.dropdown-toggle:active{background:0;border:1px solid transparent;border-radius:4px 4px 4px 4px;line-height:20px;color:#428bca;padding:10px 0 10px 0;font-size:14px;outline:0}.btn.dropdown-toggle:hover,.btn.dropdown-toggle:focus{background-color:#111;color:#2a6496;border-color:#333}.btn.dropdown-toggle>.caret{height:21px;border-top-color:#428bca;border-top-width:8px;border-left-width:8px;border-right-width:8px}.dropdown-menu{width:100px}.dropdown-menu.nav-tabs{padding:4px;background-color:#111;border:1px solid #333;width:256px}.dropdown-menu.nav-tabs>li>a{width:80px;color:inherit}.dropdown-menu.nav-tabs>li>a:hover{color:#222}.nostretch{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.player-nick{width:25%}.eloup{color:green}.elodown{color:#be0000}.eloneutral{color:gray}.pagination>li>a,.pagination>li>span{background-color:#111;border-color:#313131;color:#797979}.pagination>li>a:hover,.pagination>li>a:focus,.pagination>.active>a,.pagination>.active>span{background-color:#2b2222}@media(min-width:768px){.navbar-form{float:right}} \ No newline at end of file diff --git a/xonstat/static/css/fonts/xolonium.eot b/xonstat/static/css/fonts/xolonium.eot new file mode 100644 index 0000000..5d26e97 Binary files /dev/null and b/xonstat/static/css/fonts/xolonium.eot differ diff --git a/xonstat/static/css/fonts/xolonium.otf b/xonstat/static/css/fonts/xolonium.otf new file mode 100644 index 0000000..c2a8d80 Binary files /dev/null and b/xonstat/static/css/fonts/xolonium.otf differ diff --git a/xonstat/static/css/fonts/xolonium.svg b/xonstat/static/css/fonts/xolonium.svg new file mode 100644 index 0000000..722173e --- /dev/null +++ b/xonstat/static/css/fonts/xolonium.svg @@ -0,0 +1,1630 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xonstat/static/css/fonts/xolonium.ttf b/xonstat/static/css/fonts/xolonium.ttf new file mode 100644 index 0000000..ba58404 Binary files /dev/null and b/xonstat/static/css/fonts/xolonium.ttf differ diff --git a/xonstat/static/css/fonts/xolonium.woff b/xonstat/static/css/fonts/xolonium.woff new file mode 100644 index 0000000..69ba0d5 Binary files /dev/null and b/xonstat/static/css/fonts/xolonium.woff differ diff --git a/xonstat/util.py b/xonstat/util.py index 0891765..dc752f7 100644 --- a/xonstat/util.py +++ b/xonstat/util.py @@ -14,7 +14,7 @@ log = logging.getLogger(__name__) # Map of special chars to ascii from Darkplace's console.c. -_qfont_table = [ +_qfont_ascii_table = [ '\0', '#', '#', '#', '#', '.', '#', '#', '#', '\t', '\n', '#', ' ', '\r', '.', '.', '[', ']', '0', '1', '2', '3', '4', '5', @@ -50,6 +50,73 @@ _qfont_table = [ 'x', 'y', 'z', '{', '|', '}', '~', '<' ] +_qfont_unicode_glyphs = [ + u'\u0020', u'\u0020', u'\u2014', u'\u0020', + u'\u005F', u'\u2747', u'\u2020', u'\u00B7', + u'\U0001F52B', u'\u0020', u'\u0020', u'\u25A0', + u'\u2022', u'\u2192', u'\u2748', u'\u2748', + u'\u005B', u'\u005D', u'\U0001F47D', u'\U0001F60F', + u'\U0001F61E', u'\U0001F635', u'\U0001F615', u'\U0001F60A', + u'\u00AB', u'\u00BB', u'\u2022', u'\u203E', + u'\u2748', u'\u25AC', u'\u25AC', u'\u25AC', + u'\u0020', u'\u0021', u'\u0022', u'\u0023', + u'\u0024', u'\u0025', u'\u0026', u'\u0027', + u'\u0028', u'\u0029', u'\u00D7', u'\u002B', + u'\u002C', u'\u002D', u'\u002E', u'\u002F', + u'\u0030', u'\u0031', u'\u0032', u'\u0033', + u'\u0034', u'\u0035', u'\u0036', u'\u0037', + u'\u0038', u'\u0039', u'\u003A', u'\u003B', + u'\u003C', u'\u003D', u'\u003E', u'\u003F', + u'\u0040', u'\u0041', u'\u0042', u'\u0043', + u'\u0044', u'\u0045', u'\u0046', u'\u0047', + u'\u0048', u'\u0049', u'\u004A', u'\u004B', + u'\u004C', u'\u004D', u'\u004E', u'\u004F', + u'\u0050', u'\u0051', u'\u0052', u'\u0053', + u'\u0054', u'\u0055', u'\u0056', u'\u0057', + u'\u0058', u'\u0059', u'\u005A', u'\u005B', + u'\u005C', u'\u005D', u'\u005E', u'\u005F', + u'\u0027', u'\u0061', u'\u0062', u'\u0063', + u'\u0064', u'\u0065', u'\u0066', u'\u0067', + u'\u0068', u'\u0069', u'\u006A', u'\u006B', + u'\u006C', u'\u006D', u'\u006E', u'\u006F', + u'\u0070', u'\u0071', u'\u0072', u'\u0073', + u'\u0074', u'\u0075', u'\u0076', u'\u0077', + u'\u0078', u'\u0079', u'\u007A', u'\u007B', + u'\u007C', u'\u007D', u'\u007E', u'\u2190', + u'\u003C', u'\u003D', u'\u003E', u'\U0001F680', + u'\u00A1', u'\u004F', u'\u0055', u'\u0049', + u'\u0043', u'\u00A9', u'\u00AE', u'\u25A0', + u'\u00BF', u'\u25B6', u'\u2748', u'\u2748', + u'\u2772', u'\u2773', u'\U0001F47D', u'\U0001F60F', + u'\U0001F61E', u'\U0001F635', u'\U0001F615', u'\U0001F60A', + u'\u00AB', u'\u00BB', u'\u2747', u'\u0078', + u'\u2748', u'\u2014', u'\u2014', u'\u2014', + u'\u0020', u'\u0021', u'\u0022', u'\u0023', + u'\u0024', u'\u0025', u'\u0026', u'\u0027', + u'\u0028', u'\u0029', u'\u002A', u'\u002B', + u'\u002C', u'\u002D', u'\u002E', u'\u002F', + u'\u0030', u'\u0031', u'\u0032', u'\u0033', + u'\u0034', u'\u0035', u'\u0036', u'\u0037', + u'\u0038', u'\u0039', u'\u003A', u'\u003B', + u'\u003C', u'\u003D', u'\u003E', u'\u003F', + u'\u0040', u'\u0041', u'\u0042', u'\u0043', + u'\u0044', u'\u0045', u'\u0046', u'\u0047', + u'\u0048', u'\u0049', u'\u004A', u'\u004B', + u'\u004C', u'\u004D', u'\u004E', u'\u004F', + u'\u0050', u'\u0051', u'\u0052', u'\u0053', + u'\u0054', u'\u0055', u'\u0056', u'\u0057', + u'\u0058', u'\u0059', u'\u005A', u'\u005B', + u'\u005C', u'\u005D', u'\u005E', u'\u005F', + u'\u0027', u'\u0041', u'\u0042', u'\u0043', + u'\u0044', u'\u0045', u'\u0046', u'\u0047', + u'\u0048', u'\u0049', u'\u004A', u'\u004B', + u'\u004C', u'\u004D', u'\u004E', u'\u004F', + u'\u0050', u'\u0051', u'\u0052', u'\u0053', + u'\u0054', u'\u0055', u'\u0056', u'\u0057', + u'\u0058', u'\u0059', u'\u005A', u'\u007B', + u'\u007C', u'\u007D', u'\u007E', u'\u25C0', +] + # Hex-colored spans for decimal color codes ^0 - ^9 _dec_spans = [ "", @@ -73,15 +140,22 @@ _hex_colors = re.compile(r'\^x([\dA-Fa-f])([\dA-Fa-f])([\dA-Fa-f])') _contrast_threshold = 0.5 -def qfont_decode(qstr=''): +def qfont_decode(qstr='', for_html=False): """ Convert the qfont characters in a string to ascii. + + for_html - determines whether to convert the unicode characters to + their ascii counterparts (if False, the default) or to + the mapped glyph in the Xolonium font (if True). """ if qstr == None: qstr = '' chars = [] for c in qstr: if u'\ue000' <= c <= u'\ue0ff': - c = _qfont_table[ord(c) - 0xe000] + if for_html: + c = _qfont_unicode_glyphs[ord(c) - 0xe000] + else: + c = _qfont_ascii_table[ord(c) - 0xe000] chars.append(c) return ''.join(chars) @@ -112,7 +186,7 @@ def hex_repl(match): def html_colors(qstr='', limit=None): - qstr = html_escape(qfont_decode(qstr)) + qstr = html_escape(qfont_decode(qstr, for_html=True)) qstr = qstr.replace('^^', '^') if limit is not None and limit > 0: