Skip to content

Commit 8b37a99

Browse files
committed
Emoji support via --font=NotoEmoji-Regular
1 parent 468e873 commit 8b37a99

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ include MANIFEST.in
55
include ez_setup.py
66
include fabulous/_xterm256.c
77
include fabulous/fonts/LICENSE
8+
include fabulous/fonts/NotoEmoji-Regular.ttf
89
include fabulous/fonts/NotoSans-Bold.ttf

fabulous/fonts/NotoEmoji-Regular.ttf

409 KB
Binary file not shown.

fabulous/text.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
#
13
# Copyright 2016 The Fabulous Authors. All rights reserved.
24
#
35
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,9 +32,11 @@
3032
from fabulous import text
3133
print text.Text("Fabulous!", color='#0099ff', shadow=True, scew=5)
3234
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
3640
3741
For other fonts, Fabulous will do its best to figure out where they are
3842
stored. If Fabulous has trouble finding your font, try using an absolute
@@ -50,7 +54,7 @@
5054

5155

5256
class Text(image.Image):
53-
"""Renders TrueType Text to Terminal
57+
u"""Renders TrueType Text to Terminal
5458
5559
I'm a sub-class of :class:`fabulous.image.Image`. My job is
5660
limited to simply getting things ready. I do this by:
@@ -67,6 +71,9 @@ class Text(image.Image):
6771
>>> txt = Text("lorem ipsum", font="NotoSans-Bold")
6872
>>> len(str(txt)) > 0
6973
True
74+
>>> txt = Text(u"😃", font="NotoSans-Bold")
75+
>>> len(str(txt)) > 0
76+
True
7077
7178
:param text: The text you want to display as a string.
7279
@@ -170,9 +177,9 @@ def get_font_files():
170177
For example::
171178
172179
>>> fonts = get_font_files()
173-
>>> 'DejaVuSansMono' in fonts
180+
>>> 'NotoSans-Bold' in fonts
174181
True
175-
>>> fonts['DejaVuSansMono'].endswith('/DejaVuSansMono.ttf')
182+
>>> fonts['NotoSans-Bold'].endswith('/NotoSans-Bold.ttf')
176183
True
177184
178185
"""
@@ -215,9 +222,9 @@ def main():
215222
parser.add_option(
216223
"-F", "--font", dest="font", default='NotoSans-Bold',
217224
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"))
221228
parser.add_option(
222229
"-Z", "--size", dest="fsize", type="int", default=23,
223230
help=("Size of font in points. Default: %default"))
@@ -230,7 +237,7 @@ def main():
230237
return
231238
if options.term_color:
232239
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"):
234241
fab_text = Text(line, skew=options.skew, color=options.color,
235242
font=options.font, fsize=options.fsize,
236243
shadow=options.shadow)

0 commit comments

Comments
 (0)