1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3#
4# Urwid BigText fonts
5#    Copyright (C) 2004-2006  Ian Ward
6#
7#    This library is free software; you can redistribute it and/or
8#    modify it under the terms of the GNU Lesser General Public
9#    License as published by the Free Software Foundation; either
10#    version 2.1 of the License, or (at your option) any later version.
11#
12#    This library is distributed in the hope that it will be useful,
13#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15#    Lesser General Public License for more details.
16#
17#    You should have received a copy of the GNU Lesser General Public
18#    License along with this library; if not, write to the Free Software
19#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20#
21# Urwid web site: http://excess.org/urwid/
22
23from __future__ import division, print_function
24
25from urwid.escape import SAFE_ASCII_DEC_SPECIAL_RE
26from urwid.util import apply_target_encoding, str_util
27from urwid.canvas import TextCanvas
28from urwid.compat import text_type
29
30
31def separate_glyphs(gdata, height):
32    """return (dictionary of glyphs, utf8 required)"""
33    gl = gdata.split("\n")
34    del gl[0]
35    del gl[-1]
36    for g in gl:
37        assert "\t" not in g
38    assert len(gl) == height+1, repr(gdata)
39    key_line = gl[0]
40    del gl[0]
41    c = None # current character
42    key_index = 0 # index into character key line
43    end_col = 0 # column position at end of glyph
44    start_col = 0 # column position at start of glyph
45    jl = [0]*height # indexes into lines of gdata (gl)
46    dout = {}
47    utf8_required = False
48    while True:
49        if c is None:
50            if key_index >= len(key_line):
51                break
52            c = key_line[key_index]
53        if key_index < len(key_line) and key_line[key_index] == c:
54            end_col += str_util.get_width(ord(c))
55            key_index += 1
56            continue
57        out = []
58        for k in range(height):
59            l = gl[k]
60            j = jl[k]
61            y = 0
62            fill = 0
63            while y < end_col - start_col:
64                if j >= len(l):
65                    fill = end_col - start_col - y
66                    break
67                y += str_util.get_width(ord(l[j]))
68                j += 1
69            assert y + fill == end_col - start_col, \
70                repr((y, fill, end_col))
71
72            segment = l[jl[k]:j]
73            if not SAFE_ASCII_DEC_SPECIAL_RE.match(segment):
74                utf8_required = True
75
76            out.append(segment + " " * fill)
77            jl[k] = j
78
79        start_col = end_col
80        dout[c] = (y + fill, out)
81        c = None
82    return dout, utf8_required
83
84_all_fonts = []
85def get_all_fonts():
86    """
87    Return a list of (font name, font class) tuples.
88    """
89    return _all_fonts[:]
90
91def add_font(name, cls):
92    _all_fonts.append((name, cls))
93
94
95class Font(object):
96    def __init__(self):
97        assert self.height
98        assert self.data
99        self.char = {}
100        self.canvas = {}
101        self.utf8_required = False
102        data = [self._to_text(block) for block in self.data]
103        for gdata in data:
104            self.add_glyphs(gdata)
105
106    @staticmethod
107    def _to_text(obj, encoding='utf-8', errors='strict'):
108        if isinstance(obj, text_type):
109            return obj
110        elif isinstance(obj, bytes):
111            return obj.decode(encoding, errors)
112
113    def add_glyphs(self, gdata):
114        d, utf8_required = separate_glyphs(gdata, self.height)
115        self.char.update(d)
116        self.utf8_required |= utf8_required
117
118    def characters(self):
119        l = list(self.char.keys())
120        l.sort()
121        return "".join(l)
122
123    def char_width(self, c):
124        if c in self.char:
125            return self.char[c][0]
126        return 0
127
128    def char_data(self, c):
129        return self.char[c][1]
130
131    def render(self, c):
132        if c in self.canvas:
133            return self.canvas[c]
134        width, l = self.char[c]
135        tl = []
136        csl = []
137        for d in l:
138            t, cs = apply_target_encoding(d)
139            tl.append(t)
140            csl.append(cs)
141        canv = TextCanvas(tl, None, csl, maxcol=width,
142            check_width=False)
143        self.canvas[c] = canv
144        return canv
145
146
147
148#safe_palette = u"┘┐┌└┼─├┤┴┬│"
149#more_palette = u"═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬○"
150#block_palette = u"▄#█#▀#▌#▐#▖#▗#▘#▙#▚#▛#▜#▝#▞#▟"
151
152
153class Thin3x3Font(Font):
154    height = 3
155    data = [u"""
156000111222333444555666777888999  !
157┌─┐ ┐ ┌─┐┌─┐  ┐┌─ ┌─ ┌─┐┌─┐┌─┐  │
158│ │ │ ┌─┘ ─┤└─┼└─┐├─┐  ┼├─┤└─┤  │
159└─┘ ┴ └─ └─┘  ┴ ─┘└─┘  ┴└─┘ ─┘  .
160""", r"""
161"###$$$%%%'*++,--.///:;==???[[\\\]]^__`
162" ┼┼┌┼┐O /'         /.. _┌─┐┌ \   ┐^  `
163  ┼┼└┼┐ /  * ┼  ─  / ., _ ┌┘│  \  │
164    └┼┘/ O    ,  ./       . └   \ ┘ ──
165"""]
166add_font("Thin 3x3",Thin3x3Font)
167
168class Thin4x3Font(Font):
169    height = 3
170    data = Thin3x3Font.data + [u"""
1710000111122223333444455556666777788889999  ####$$$$
172┌──┐  ┐ ┌──┐┌──┐   ┐┌── ┌── ┌──┐┌──┐┌──┐   ┼─┼┌┼┼┐
173│  │  │ ┌──┘  ─┤└──┼└──┐├──┐   ┼├──┤└──┤   ┼─┼└┼┼┐
174└──┘  ┴ └── └──┘   ┴ ──┘└──┘   ┴└──┘ ──┘      └┼┼┘
175"""]
176add_font("Thin 4x3",Thin4x3Font)
177
178class HalfBlock5x4Font(Font):
179    height = 4
180    data = [u"""
18100000111112222233333444445555566666777778888899999  !!
182▄▀▀▄  ▄█  ▄▀▀▄ ▄▀▀▄ ▄  █ █▀▀▀ ▄▀▀  ▀▀▀█ ▄▀▀▄ ▄▀▀▄   █
183█  █   █    ▄▀   ▄▀ █▄▄█ █▄▄  █▄▄    ▐▌ ▀▄▄▀ ▀▄▄█   █
184█  █   █  ▄▀   ▄  █    █    █ █  █   █  █  █    █   ▀
185 ▀▀   ▀▀▀ ▀▀▀▀  ▀▀     ▀ ▀▀▀   ▀▀    ▀   ▀▀   ▀▀    ▀
186""", u'''
187"""######$$$$$$%%%%%&&&&&((()))******++++++,,,-----..////::;;;
188█▐▌ █ █  ▄▀█▀▄ ▐▌▐▌ ▄▀▄   █ █   ▄ ▄    ▄              ▐▌
189   ▀█▀█▀ ▀▄█▄    █  ▀▄▀  ▐▌ ▐▌ ▄▄█▄▄ ▄▄█▄▄    ▄▄▄▄    █  ▀  ▀
190   ▀█▀█▀ ▄ █ █  ▐▌▄ █ ▀▄▌▐▌ ▐▌  ▄▀▄    █             ▐▌  ▀ ▄▀
191    ▀ ▀   ▀▀▀   ▀ ▀  ▀▀   ▀ ▀              ▄▀      ▀ ▀
192''', r"""
193<<<<<=====>>>>>?????@@@@@@[[[[\\\\]]]]^^^^____```{{{{||}}}}~~~~''´´´
194  ▄▀      ▀▄   ▄▀▀▄ ▄▀▀▀▄ █▀▀ ▐▌  ▀▀█ ▄▀▄     ▀▄  ▄▀ █ ▀▄   ▄  █ ▄▀
195▄▀   ▀▀▀▀   ▀▄   ▄▀ █ █▀█ █    █    █            ▄▀  █  ▀▄ ▐▐▌▌
196 ▀▄  ▀▀▀▀  ▄▀    ▀  █ ▀▀▀ █    ▐▌   █             █  █  █    ▀
197   ▀      ▀      ▀   ▀▀▀  ▀▀▀   ▀ ▀▀▀     ▀▀▀▀     ▀ ▀ ▀
198""", u'''
199AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGGHHHHHIIJJJJJKKKKK
200▄▀▀▄ █▀▀▄ ▄▀▀▄ █▀▀▄ █▀▀▀ █▀▀▀ ▄▀▀▄ █  █ █    █ █  █
201█▄▄█ █▄▄▀ █    █  █ █▄▄  █▄▄  █    █▄▄█ █    █ █▄▀
202█  █ █  █ █  ▄ █  █ █    █    █ ▀█ █  █ █ ▄  █ █ ▀▄
203▀  ▀ ▀▀▀   ▀▀  ▀▀▀  ▀▀▀▀ ▀     ▀▀  ▀  ▀ ▀  ▀▀  ▀  ▀
204''', u'''
205LLLLLMMMMMMNNNNNOOOOOPPPPPQQQQQRRRRRSSSSSTTTTT
206█    █▄ ▄█ ██ █ ▄▀▀▄ █▀▀▄ ▄▀▀▄ █▀▀▄ ▄▀▀▄ ▀▀█▀▀
207█    █ ▀ █ █▐▌█ █  █ █▄▄▀ █  █ █▄▄▀ ▀▄▄    █
208█    █   █ █ ██ █  █ █    █ ▌█ █  █ ▄  █   █
209▀▀▀▀ ▀   ▀ ▀  ▀  ▀▀  ▀     ▀▀▌ ▀  ▀  ▀▀    ▀
210''', u'''
211UUUUUVVVVVVWWWWWWXXXXXXYYYYYYZZZZZ
212█  █ █   █ █   █ █   █ █   █ ▀▀▀█
213█  █ ▐▌ ▐▌ █ ▄ █  ▀▄▀   ▀▄▀   ▄▀
214█  █  █ █  ▐▌█▐▌ ▄▀ ▀▄   █   █
215 ▀▀    ▀    ▀ ▀  ▀   ▀   ▀   ▀▀▀▀
216''', u'''
217aaaaabbbbbcccccdddddeeeeeffffggggghhhhhiijjjjkkkkk
218     █            █       ▄▀▀     █    ▄   ▄ █
219 ▀▀▄ █▀▀▄ ▄▀▀▄ ▄▀▀█ ▄▀▀▄ ▀█▀ ▄▀▀▄ █▀▀▄ ▄   ▄ █ ▄▀
220▄▀▀█ █  █ █  ▄ █  █ █▀▀   █  ▀▄▄█ █  █ █   █ █▀▄
221 ▀▀▀ ▀▀▀   ▀▀   ▀▀▀  ▀▀   ▀   ▄▄▀ ▀  ▀ ▀ ▄▄▀ ▀  ▀
222''', u'''
223llmmmmmmnnnnnooooopppppqqqqqrrrrssssstttt
224█                                     █
225█ █▀▄▀▄ █▀▀▄ ▄▀▀▄ █▀▀▄ ▄▀▀█ █▀▀ ▄▀▀▀ ▀█▀
226█ █ █ █ █  █ █  █ █  █ █  █ █    ▀▀▄  █
227▀ ▀   ▀ ▀  ▀  ▀▀  █▀▀   ▀▀█ ▀   ▀▀▀    ▀
228''', u'''
229uuuuuvvvvvwwwwwwxxxxxxyyyyyzzzzz
230
231█  █ █  █ █ ▄ █ ▀▄ ▄▀ █  █ ▀▀█▀
232█  █ ▐▌▐▌ ▐▌█▐▌  ▄▀▄  ▀▄▄█ ▄▀
233 ▀▀   ▀▀   ▀ ▀  ▀   ▀  ▄▄▀ ▀▀▀▀
234''']
235add_font("Half Block 5x4",HalfBlock5x4Font)
236
237class HalfBlock6x5Font(Font):
238    height = 5
239    data = [u"""
240000000111111222222333333444444555555666666777777888888999999  ..::////
241▄▀▀▀▄  ▄█   ▄▀▀▀▄ ▄▀▀▀▄ ▄  █  █▀▀▀▀ ▄▀▀▀  ▀▀▀▀█ ▄▀▀▀▄ ▄▀▀▀▄         █
242█   █   █       █     █ █  █  █     █        ▐▌ █   █ █   █     ▀  ▐▌
243█   █   █     ▄▀    ▀▀▄ ▀▀▀█▀ ▀▀▀▀▄ █▀▀▀▄    █  ▄▀▀▀▄  ▀▀▀█     ▄  █
244█   █   █   ▄▀    ▄   █    █      █ █   █   ▐▌  █   █     █       ▐▌
245 ▀▀▀   ▀▀▀  ▀▀▀▀▀  ▀▀▀     ▀  ▀▀▀▀   ▀▀▀    ▀    ▀▀▀   ▀▀▀    ▀   ▀
246"""]
247add_font("Half Block 6x5",HalfBlock6x5Font)
248
249class HalfBlockHeavy6x5Font(Font):
250    height = 5
251    data = [u"""
252000000111111222222333333444444555555666666777777888888999999  ..::////
253▄███▄  ▐█▌  ▄███▄ ▄███▄    █▌ █████ ▄███▄ █████ ▄███▄ ▄███▄         █▌
254█▌ ▐█  ▀█▌  ▀  ▐█ ▀  ▐█ █▌ █▌ █▌    █▌       █▌ █▌ ▐█ █▌ ▐█     █▌ ▐█
255█▌ ▐█   █▌    ▄█▀   ██▌ █████ ████▄ ████▄   ▐█  ▐███▌ ▀████        █▌
256█▌ ▐█   █▌  ▄█▀   ▄  ▐█    █▌    ▐█ █▌ ▐█   █▌  █▌ ▐█    ▐█     █▌▐█
257▀███▀  ███▌ █████ ▀███▀    █▌ ████▀ ▀███▀  ▐█   ▀███▀ ▀███▀   █▌  █▌
258"""]
259add_font("Half Block Heavy 6x5",HalfBlockHeavy6x5Font)
260
261class Thin6x6Font(Font):
262    height = 6
263    data = [u"""
264000000111111222222333333444444555555666666777777888888999999''
265┌───┐   ┐   ┌───┐ ┌───┐    ┐  ┌───  ┌───  ┌───┐ ┌───┐ ┌───┐ │
266│   │   │       │     │ ┌  │  │     │         │ │   │ │   │
267│ / │   │   ┌───┘    ─┤ └──┼─ └───┐ ├───┐     ┼ ├───┤ └───┤
268│   │   │   │         │    │      │ │   │     │ │   │     │
269└───┘   ┴   └───  └───┘    ┴   ───┘ └───┘     ┴ └───┘  ───┘
270
271""", r'''
272!!   """######$$$$$$%%%%%%&&&&&&((()))******++++++
273│    ││  ┌ ┌  ┌─┼─┐ ┌┐  /  ┌─┐   / \
274│       ─┼─┼─ │ │   └┘ /   │ │  │   │  \ /    │
275│        │ │  └─┼─┐   /   ┌─\┘  │   │ ──X── ──┼──
276│       ─┼─┼─   │ │  / ┌┐ │  \, │   │  / \    │
277.        ┘ ┘  └─┼─┘ /  └┘ └───\  \ /
278
279''', r"""
280,,-----..//////::;;<<<<=====>>>>??????@@@@@@
281             /                  ┌───┐ ┌───┐
282            /  . .   / ──── \       │ │┌──┤
283  ────     /        /        \    ┌─┘ ││  │
284          /    . ,  \  ────  /    │   │└──┘
285,      . /           \      /     .   └───┘
286
287""", r"""
288[[\\\\\\]]^^^____``{{||}}~~~~~~
289┌ \     ┐ /\     \ ┌ │ ┐
290│  \    │          │ │ │ ┌─┐
291│   \   │          ┤ │ ├   └─┘
292│    \  │          │ │ │
293└     \ ┘    ────  └ │ ┘
294
295""", u"""
296AAAAAABBBBBBCCCCCCDDDDDDEEEEEEFFFFFFGGGGGGHHHHHHIIJJJJJJ
297┌───┐ ┬───┐ ┌───┐ ┬───┐ ┬───┐ ┬───┐ ┌───┐ ┬   ┬ ┬     ┬
298│   │ │   │ │     │   │ │     │     │     │   │ │     │
299├───┤ ├───┤ │     │   │ ├──   ├──   │ ──┬ ├───┤ │     │
300│   │ │   │ │     │   │ │     │     │   │ │   │ │ ┬   │
301┴   ┴ ┴───┘ └───┘ ┴───┘ ┴───┘ ┴     └───┘ ┴   ┴ ┴ └───┘
302
303""", u"""
304KKKKKKLLLLLLMMMMMMNNNNNNOOOOOOPPPPPPQQQQQQRRRRRRSSSSSS
305┬   ┬ ┬     ┌─┬─┐ ┬─┐ ┬ ┌───┐ ┬───┐ ┌───┐ ┬───┐ ┌───┐
306│ ┌─┘ │     │ │ │ │ │ │ │   │ │   │ │   │ │   │ │
307├─┴┐  │     │ │ │ │ │ │ │   │ ├───┘ │   │ ├─┬─┘ └───┐
308│  └┐ │     │   │ │ │ │ │   │ │     │  ┐│ │ └─┐     │
309┴   ┴ ┴───┘ ┴   ┴ ┴ └─┴ └───┘ ┴     └──┼┘ ┴   ┴ └───┘
310311""", u"""
312TTTTTTUUUUUUVVVVVVWWWWWWXXXXXXYYYYYYZZZZZZ
313┌─┬─┐ ┬   ┬ ┬   ┬ ┬   ┬ ┬   ┬ ┬   ┬ ┌───┐
314  │   │   │ │   │ │   │ └┐ ┌┘ │   │   ┌─┘
315  │   │   │ │   │ │ │ │  ├─┤  └─┬─┘  ┌┘
316  │   │   │ └┐ ┌┘ │ │ │ ┌┘ └┐   │   ┌┘
317  ┴   └───┘  └─┘  └─┴─┘ ┴   ┴   ┴   └───┘
318
319""", u"""
320aaaaaabbbbbbccccccddddddeeeeeefffgggggghhhhhhiijjj
321                              ┌─┐
322      │               │       │        │     .  .
323┌───┐ ├───┐ ┌───┐ ┌───┤ ┌───┐ ┼  ┌───┐ ├───┐ ┐  ┐
324┌───┤ │   │ │     │   │ ├───┘ │  │   │ │   │ │  │
325└───┴ └───┘ └───┘ └───┘ └───┘ ┴  └───┤ ┴   ┴ ┴  │
326                                 └───┘         ─┘
327""", u"""
328kkkkkkllmmmmmmnnnnnnooooooppppppqqqqqqrrrrrssssss
329
330│     │
331│ ┌─  │ ┬─┬─┐ ┬───┐ ┌───┐ ┌───┐ ┌───┐ ┬──┐ ┌───┐
332├─┴┐  │ │ │ │ │   │ │   │ │   │ │   │ │    └───┐
333┴  └─ └ ┴   ┴ ┴   ┴ └───┘ ├───┘ └───┤ ┴    └───┘
334                          │         │
335""", u"""
336ttttuuuuuuvvvvvvwwwwwwxxxxxxyyyyyyzzzzzz
337
338339─┼─ ┬   ┬ ┬   ┬ ┬   ┬ ─┐ ┌─ ┬   ┬ ────┬
340 │  │   │ └┐ ┌┘ │ │ │  ├─┤  │   │ ┌───┘
341 └─ └───┴  └─┘  └─┴─┘ ─┘ └─ └───┤ ┴────
342                            └───┘
343"""]
344add_font("Thin 6x6",Thin6x6Font)
345
346
347class HalfBlock7x7Font(Font):
348    height = 7
349    data = [u"""
3500000000111111122222223333333444444455555556666666777777788888889999999'''
351 ▄███▄   ▐█▌   ▄███▄  ▄███▄     █▌ ▐█████▌ ▄███▄ ▐█████▌ ▄███▄  ▄███▄ ▐█
352▐█   █▌  ▀█▌  ▐█   █▌▐█   █▌▐█  █▌ ▐█     ▐█         ▐█ ▐█   █▌▐█   █▌▐█
353▐█ ▐ █▌   █▌       █▌   ▐██ ▐█████▌▐████▄ ▐████▄     █▌  █████  ▀████▌
354▐█ ▌ █▌   █▌     ▄█▀      █▌    █▌      █▌▐█   █▌   ▐█  ▐█   █▌     █▌
355▐█   █▌   █▌   ▄█▀   ▐█   █▌    █▌      █▌▐█   █▌   █▌  ▐█   █▌     █▌
356 ▀███▀   ███▌ ▐█████▌ ▀███▀     █▌ ▐████▀  ▀███▀   ▐█    ▀███▀  ▀███▀
357
358""", u'''
359!!!   """""#######$$$$$$$%%%%%%%&&&&&&&(((())))*******++++++
360▐█    ▐█ █▌ ▐█ █▌    █    ▄  █▌   ▄█▄    █▌▐█   ▄▄ ▄▄
361▐█    ▐█ █▌▐█████▌ ▄███▄ ▐█▌▐█   ▐█ █▌  ▐█  █▌  ▀█▄█▀   ▐█
362▐█          ▐█ █▌ ▐█▄█▄▄  ▀ █▌    ███   █▌  ▐█ ▐█████▌ ████▌
363▐█         ▐█████▌ ▀▀█▀█▌  ▐█ ▄  ███▌▄  █▌  ▐█  ▄█▀█▄   ▐█
364            ▐█ █▌  ▀███▀   █▌▐█▌▐█  █▌  ▐█  █▌  ▀▀ ▀▀
365▐█                   █    ▐█  ▀  ▀██▀█▌  █▌▐█
366
367''', u"""
368,,,------.../////:::;;;<<<<<<<======>>>>>>>???????@@@@@@@
369               █▌          ▄█▌      ▐█▄     ▄███▄  ▄███▄
370              ▐█ ▐█ ▐█   ▄█▀  ▐████▌  ▀█▄  ▐█   █▌▐█ ▄▄█▌
371   ▐████▌     █▌       ▐██              ██▌    █▌ ▐█▐█▀█▌
372             ▐█  ▐█ ▐█   ▀█▄  ▐████▌  ▄█▀     █▌  ▐█▐█▄█▌
373             █▌     ▀      ▀█▌      ▐█▀           ▐█ ▀▀▀
374▐█       ▐█ ▐█                                █▌   ▀███▀
375376""", r"""
377[[[[\\\\\]]]]^^^^^^^_____```{{{{{|||}}}}}~~~~~~~´´´
378▐██▌▐█   ▐██▌  ▐█▌       ▐█    █▌▐█ ▐█           █▌
379▐█   █▌    █▌ ▐█ █▌       █▌  █▌ ▐█  ▐█   ▄▄    ▐█
380▐█   ▐█    █▌▐█   █▌         ▄█▌ ▐█  ▐█▄ ▐▀▀█▄▄▌
381▐█    █▌   █▌                ▀█▌ ▐█  ▐█▀     ▀▀
382▐█    ▐█   █▌                 █▌ ▐█  ▐█
383▐██▌   █▌▐██▌       █████      █▌▐█ ▐█
384
385""", u"""
386AAAAAAABBBBBBBCCCCCCCDDDDDDDEEEEEEEFFFFFFFGGGGGGGHHHHHHHIIIIJJJJJJJ
387 ▄███▄ ▐████▄  ▄███▄ ▐████▄ ▐█████▌▐█████▌ ▄███▄ ▐█   █▌ ██▌     █▌
388▐█   █▌▐█   █▌▐█     ▐█   █▌▐█     ▐█     ▐█     ▐█   █▌ ▐█      █▌
389▐█████▌▐█████ ▐█     ▐█   █▌▐████  ▐████  ▐█     ▐█████▌ ▐█      █▌
390▐█   █▌▐█   █▌▐█     ▐█   █▌▐█     ▐█     ▐█  ██▌▐█   █▌ ▐█      █▌
391▐█   █▌▐█   █▌▐█     ▐█   █▌▐█     ▐█     ▐█   █▌▐█   █▌ ▐█ ▐█   █▌
392▐█   █▌▐████▀  ▀███▀ ▐████▀ ▐█████▌▐█      ▀███▀ ▐█   █▌ ██▌ ▀███▀
393
394""", u"""
395KKKKKKKLLLLLLLMMMMMMMMNNNNNNNOOOOOOOPPPPPPPQQQQQQQRRRRRRRSSSSSSS
396▐█   █▌▐█      ▄█▌▐█▄ ▐██  █▌ ▄███▄ ▐████▄  ▄███▄ ▐████▄  ▄███▄
397▐█  █▌ ▐█     ▐█ ▐▌ █▌▐██▌ █▌▐█   █▌▐█   █▌▐█   █▌▐█   █▌▐█
398▐█▄█▌  ▐█     ▐█ ▐▌ █▌▐█▐█ █▌▐█   █▌▐████▀ ▐█   █▌▐█████  ▀███▄
399▐█▀█▌  ▐█     ▐█    █▌▐█ █▌█▌▐█   █▌▐█     ▐█   █▌▐█   █▌     █▌
400▐█  █▌ ▐█     ▐█    █▌▐█ ▐██▌▐█   █▌▐█     ▐█ █▌█▌▐█   █▌     █▌
401▐█   █▌▐█████▌▐█    █▌▐█  ██▌ ▀███▀ ▐█      ▀███▀ ▐█   █▌ ▀███▀
402                                               ▀▀
403""", u"""
404TTTTTTTUUUUUUUVVVVVVVWWWWWWWWXXXXXXXYYYYYYYZZZZZZZ
405 █████▌▐█   █▌▐█   █▌▐█    █▌▐█   █▌ █▌  █▌▐█████▌
406   █▌  ▐█   █▌ █▌ ▐█ ▐█    █▌ ▐█ █▌  ▐█ ▐█     █▌
407   █▌  ▐█   █▌ ▐█ █▌ ▐█    █▌  ▐█▌    ▐██     █▌
408   █▌  ▐█   █▌  ███  ▐█ ▐▌ █▌  ███     █▌    █▌
409   █▌  ▐█   █▌  ▐█▌  ▐█ ▐▌ █▌ █▌ ▐█    █▌   █▌
410   █▌   ▀███▀    █    ▀█▌▐█▀ ▐█   █▌   █▌  ▐█████▌
411
412""", u"""
413aaaaaaabbbbbbbcccccccdddddddeeeeeeefffffggggggghhhhhhhiiijjjj
414       ▐█                 █▌         ▄█▌       ▐█      █▌  █▌
415       ▐█                 █▌        ▐█         ▐█
416 ▄███▄ ▐████▄  ▄███▄  ▄████▌ ▄███▄ ▐███  ▄███▄ ▐████▄ ▐█▌ ▐█▌
417  ▄▄▄█▌▐█   █▌▐█     ▐█   █▌▐█▄▄▄█▌ ▐█  ▐█   █▌▐█   █▌ █▌  █▌
418▐█▀▀▀█▌▐█   █▌▐█     ▐█   █▌▐█▀▀▀   ▐█  ▐█▄▄▄█▌▐█   █▌ █▌  █▌
419 ▀████▌▐████▀  ▀███▀  ▀████▌ ▀███▀  ▐█    ▀▀▀█▌▐█   █▌ █▌  █▌
420                                         ▀███▀           ▐██
421""", u"""
422kkkkkkkllllmmmmmmmmnnnnnnnooooooopppppppqqqqqqqrrrrrrsssssss
423▐█      ██
424▐█      ▐█
425▐█  ▄█▌ ▐█  ▄█▌▐█▄ ▐████▄  ▄███▄ ▐████▄  ▄████▌ ▄███▌ ▄███▄
426▐█▄█▀   ▐█ ▐█ ▐▌ █▌▐█   █▌▐█   █▌▐█   █▌▐█   █▌▐█    ▐█▄▄▄
427▐█▀▀█▄  ▐█ ▐█ ▐▌ █▌▐█   █▌▐█   █▌▐█   █▌▐█   █▌▐█      ▀▀▀█▌
428▐█   █▌ ▐█▌▐█    █▌▐█   █▌ ▀███▀ ▐████▀  ▀████▌▐█     ▀███▀
429                                 ▐█          █▌
430""", u"""
431tttttuuuuuuuvvvvvvvwwwwwwwwxxxxxxxyyyyyyyzzzzzzz
432  █▌
433  █▌
434 ███▌▐█   █▌▐█   █▌▐█    █▌▐█   █▌▐█   █▌▐█████▌
435  █▌ ▐█   █▌ █▌ ▐█ ▐█    █▌ ▀█▄█▀ ▐█   █▌   ▄█▀
436  █▌ ▐█   █▌  ███  ▐█ ▐▌ █▌ ▄█▀█▄ ▐█▄▄▄█▌ ▄█▀
437  █▌  ▀███▀   ▐█▌   ▀█▌▐█▀ ▐█   █▌  ▀▀▀█▌▐█████▌
438                                   ▀███▀
439"""]
440add_font("Half Block 7x7",HalfBlock7x7Font)
441
442
443if __name__ == "__main__":
444    l = get_all_fonts()
445    all_ascii = "".join([chr(x) for x in range(32, 127)])
446    print("Available Fonts:     (U) = UTF-8 required")
447    print("----------------")
448    for n,cls in l:
449        f = cls()
450        u = ""
451        if f.utf8_required:
452            u = "(U)"
453        print(("%-20s %3s " % (n,u)), end=' ')
454        c = f.characters()
455        if c == all_ascii:
456            print("Full ASCII")
457        elif c.startswith(all_ascii):
458            print("Full ASCII + " + c[len(all_ascii):])
459        else:
460            print("Characters: " + c)
461