1
+ # -*- coding: utf-8 -*-
2
+ #
1
3
# Copyright 2016 The Fabulous Authors. All rights reserved.
2
4
#
3
5
# Licensed under the Apache License, Version 2.0 (the "License");
30
32
from fabulous import text
31
33
print text.Text("Fabulous!", color='#0099ff', shadow=True, scew=5)
32
34
33
- To make things simple, Fabulous bundles the ``NotoSans-Bold`` bold font
34
- which was created by Google. This font looks good and is guaranteed to
35
- work no matter what.
35
+ To make things simple, Fabulous bundles the following Google Noto Fonts
36
+ which look good and are guaranteed to work no matter what:
37
+
38
+ - NotoSans-Bold
39
+ - NotoEmoji-Regular
36
40
37
41
For other fonts, Fabulous will do its best to figure out where they are
38
42
stored. If Fabulous has trouble finding your font, try using an absolute
50
54
51
55
52
56
class Text (image .Image ):
53
- """Renders TrueType Text to Terminal
57
+ u """Renders TrueType Text to Terminal
54
58
55
59
I'm a sub-class of :class:`fabulous.image.Image`. My job is
56
60
limited to simply getting things ready. I do this by:
@@ -67,6 +71,9 @@ class Text(image.Image):
67
71
>>> txt = Text("lorem ipsum", font="NotoSans-Bold")
68
72
>>> len(str(txt)) > 0
69
73
True
74
+ >>> txt = Text(u"😃", font="NotoSans-Bold")
75
+ >>> len(str(txt)) > 0
76
+ True
70
77
71
78
:param text: The text you want to display as a string.
72
79
@@ -170,9 +177,9 @@ def get_font_files():
170
177
For example::
171
178
172
179
>>> fonts = get_font_files()
173
- >>> 'DejaVuSansMono ' in fonts
180
+ >>> 'NotoSans-Bold ' in fonts
174
181
True
175
- >>> fonts['DejaVuSansMono '].endswith('/DejaVuSansMono .ttf')
182
+ >>> fonts['NotoSans-Bold '].endswith('/NotoSans-Bold .ttf')
176
183
True
177
184
178
185
"""
@@ -215,9 +222,9 @@ def main():
215
222
parser .add_option (
216
223
"-F" , "--font" , dest = "font" , default = 'NotoSans-Bold' ,
217
224
help = ("Name of font file, or absolute path to one. Use the --list "
218
- "flag to see what fonts are available. The default font is "
219
- "bundled with Fabulous and guaranteed to work. "
220
- "Default: %default" ))
225
+ "flag to see what fonts are available. Fabulous bundles the "
226
+ "NotoSans-Bold and NotoEmoji-Regular fonts, which are guaranteed "
227
+ "to work. Default: %default" ))
221
228
parser .add_option (
222
229
"-Z" , "--size" , dest = "fsize" , type = "int" , default = 23 ,
223
230
help = ("Size of font in points. Default: %default" ))
@@ -230,7 +237,7 @@ def main():
230
237
return
231
238
if options .term_color :
232
239
utils .term .bgcolor = options .term_color
233
- for line in " " .join (args ).split ("\n " ):
240
+ for line in " " .join (args ).decode ( 'utf-8' ). split ("\n " ):
234
241
fab_text = Text (line , skew = options .skew , color = options .color ,
235
242
font = options .font , fsize = options .fsize ,
236
243
shadow = options .shadow )
0 commit comments