Skip to content

Commit

Permalink
Bundle Google Noto Fonts and update licensing
Browse files Browse the repository at this point in the history
Fixed #2
  • Loading branch information
jart committed Jul 4, 2016
1 parent a059c8d commit ca8f402
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 57 deletions.
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ include COPYING
include MANIFEST.in
include ez_setup.py
include fabulous/_xterm256.c
include fabulous/fonts/DejaVuSansMono.ttf
include fabulous/fonts/IndUni-H-Bold.otf
include fabulous/fonts/cmr10.ttf
include fabulous/fonts/LICENSE
include fabulous/fonts/NotoSans-Bold.ttf
35 changes: 29 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

:Version: 0.1.8
:Copyright: Copyright (c) 2009-2016 Justine Tunney
:License: MIT
:License: MIT / OFL / Apache 2.0

Fabulous is a Python library (and command line tools) designed to make the
output of terminal applications look *fabulous*. Fabulous allows you to print
Expand Down Expand Up @@ -251,10 +251,10 @@ Alternatives

Here's how Fabulous compares to other similar libraries:

- fabulous_: Licensed MIT. Focuses on delivering useful features in
the simplest, most user-friendly way possible (without a repulsive
name.) Written in pure-python but will attempt to auto-magically
compile/link a speedup library. ~5,000 lines of code.
- fabulous_: Licensed mostly MIT. Focuses on delivering useful features in the
simplest, most user-friendly way possible (without a repulsive name.)
Written in pure-python but will attempt to auto-magically compile/link a
speedup library. ~5,000 lines of code.

- libcaca_: WTFPL. This is the established and respected standard for
doing totally insane things with ascii art (ever wanted to watch a
Expand Down Expand Up @@ -283,7 +283,30 @@ Here's how Fabulous compares to other similar libraries:
License
=======

Code and documentation are available according to the MIT License:
Fabulous code and documentation are available according to the MIT License:

.. include:: ../COPYING
:literal:

The bundled grapefruit library is licensed Apache 2.0::

Copyright (c) 2016, Justine Tunney
Copyright (c) 2008, Xavier Basty

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

The bundled Google Noto Fonts are licensed under the SIL Open Font License,
Version 1.1:

.. include:: ../fabulous/fonts/LICENSE
:literal:
Binary file removed fabulous/fonts/DejaVuSansMono.ttf
Binary file not shown.
Binary file removed fabulous/fonts/IndUni-H-Bold.otf
Binary file not shown.
92 changes: 92 additions & 0 deletions fabulous/fonts/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
This Font Software is licensed under the SIL Open Font License,
Version 1.1.

This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL

-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to
provide a free and open framework in which fonts may be shared and
improved in partnership with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software
components as distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created using
the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added fabulous/fonts/NotoSans-Bold.ttf
Binary file not shown.
9 changes: 9 additions & 0 deletions fabulous/fonts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Fabulous Fonts

Fabulous bundles [Google Noto Fonts](https://www.google.com/get/noto/) because
they they look good, support a vast number of unicode characters, and have a
sane permissive licence (unlike IndUni-H, DejaVu, MS Fonts, etc.) which is the
SIL Open Font License, Version 1.1.

Fabulous is still able to read system fonts. But it's nice to have a small set
here that's guaranteed to work.
Binary file removed fabulous/fonts/cmr10.ttf
Binary file not shown.
68 changes: 22 additions & 46 deletions fabulous/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,17 @@
from fabulous import text
print text.Text("Fabulous!", color='#0099ff', shadow=True, scew=5)
To make things simple, Fabulous bundles three decent serif, sans-serif, and
monospace fonts:
- IndUni-H-Bold: Open Source Helvetica Bold clone (sans-serif)
This is the real deal and not some cheap ripoff like Verdana.
IndUni-H-Bold is the default because not only does it look
great, but also renders *perfectly*. and is also used for the
Fabulous logo. Commonly found on stret signs.
This font is licensed under the GPL. If you're developing
proprietary software you might want to ask its author or a
lawyer if Fabulous' use of IndUni-H would be considered a "GPL
Barrier."
- cmr10: Computer Modern (serif)
Donald Knuth wrote 23,000 lines for the sole purpose of
bestowing this jewel upon the world. This font is commonly seen
in scholarly papers.
- DejaVuSansMono: DejaVu Sans Mono (formerly Bitstream Vera Sans Mono)
At point size 8, this is my favorite programming/terminal font.
To make things simple, Fabulous bundles the ``NotoSans-Bold`` bold font
which was created by Google. This font looks good and is guaranteed to
work no matter what.
For other fonts, Fabulous will do its best to figure out where they are
stored. If Fabulous has trouble finding your font, try using an absolute
path *with* the extension. It's also possible to put the font in the
``~/.fonts`` directory and then running ``fc-cache -fv ~/.fonts``.
You can run ``fabulous-text --list`` to see what fonts are available.
"""

import os
Expand All @@ -69,13 +50,7 @@ class Text(image.Image):
>>> assert Text("Fabulous", shadow=True, skew=5)
>>> txt = Text("lorem ipsum", font="IndUni-H-Bold")
>>> len(str(txt)) > 0
True
>>> txt = Text("lorem ipsum", font="cmr10")
>>> len(str(txt)) > 0
True
>>> txt = Text("lorem ipsum", font="DejaVuSansMono")
>>> txt = Text("lorem ipsum", font="NotoSans-Bold")
>>> len(str(txt)) > 0
True
Expand All @@ -102,21 +77,22 @@ class Text(image.Image):
globbing the specified name in various directories.
"""

def __init__(self, text, fsize=20, color="#0099ff", shadow=False,
skew=None, font='IndUni-H-Bold'):
def __init__(self, text, fsize=23, color="#0099ff", shadow=False,
skew=None, font='NotoSans-Bold'):
utils.pil_check()
from PIL import Image, ImageFont, ImageDraw
self.text = text
self.color = grapefruit.Color.NewFromHtml(color)
self.font = ImageFont.truetype(resolve_font(font), fsize)
size = tuple([n + 3 for n in self.font.getsize(self.text)])
skew = skew or 0
size = tuple([n + 3 + skew for n in self.font.getsize(self.text)])
self.img = Image.new("RGBA", size, (0, 0, 0, 0))
cvs = ImageDraw.Draw(self.img)
if shadow:
cvs.text((2, 2), self.text,
cvs.text((2 + skew, 2), self.text,
font=self.font,
fill=(150, 150, 150, 150))
cvs.text((1, 1), self.text,
cvs.text((1 + skew, 1), self.text,
font=self.font,
fill=self.color.html)
if skew:
Expand All @@ -141,16 +117,16 @@ def resolve_font(name):
For example::
>>> path = resolve_font('IndUni-H-Bold')
>>> path = resolve_font('NotoSans-Bold')
>>> fontdir = os.path.join(os.path.dirname(__file__), 'fonts')
>>> indunih_path = os.path.join(fontdir, 'IndUni-H-Bold.otf')
>>> indunih_path = os.path.abspath(indunih_path)
>>> assert path == indunih_path
>>> noto_path = os.path.join(fontdir, 'NotoSans-Bold.ttf')
>>> noto_path = os.path.abspath(noto_path)
>>> assert path == noto_path
Absolute paths are allowed::
>>> resolve_font(indunih_path) == indunih_path
>>> resolve_font(noto_path) == noto_path
True
Raises :exc:`FontNotFound` on failure::
Expand Down Expand Up @@ -223,13 +199,13 @@ def main():
"this value to the proper background so semi-transparent "
"pixels will blend properly."))
parser.add_option(
"-F", "--font", dest="font", default='IndUni-H-Bold',
help=("Path to font file you wish to use. This defaults to a "
"free Helvetica-Bold clone which is included with Fabulous. "
"Included fonts: IndUni-H-Bold, cmr10, DejaVuSansMono. "
"-F", "--font", dest="font", default='NotoSans-Bold',
help=("Name of font file, or absolute path to one. Use the --list "
"flag to see what fonts are available. The default font is "
"bundled with Fabulous and guaranteed to work. "
"Default: %default"))
parser.add_option(
"-Z", "--size", dest="fsize", type="int", default=20,
"-Z", "--size", dest="fsize", type="int", default=23,
help=("Size of font in points. Default: %default"))
parser.add_option(
"-s", "--shadow", dest="shadow", action="store_true", default=False,
Expand Down
2 changes: 1 addition & 1 deletion python-fabulous.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Release: 2%{?dist}
Summary: Makes your terminal output totally fabulous

Group: Development/Languages
License: MIT
License: MIT / OFL / Apache 2.0
URL: https://jart.github.io/fabulous
Source0: /~https://github.com/jart/fabulous/releases/download/0.1.8/fabulous-0.1.8.tar.gz

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def read(fname):
'/download/' + version +
'/fabulous-' + version + '.tar.gz'),
long_description = read('README.rst'),
license = 'MIT',
license = 'MIT / OFL / Apache 2.0',
packages = ['fabulous', 'fabulous.experimental'],
zip_safe = False,
include_package_data = True,
Expand All @@ -44,6 +44,7 @@ def read(fname):
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: Apache Software License",
"Environment :: Console",
"Intended Audience :: Developers",
"Programming Language :: C",
Expand Down

0 comments on commit ca8f402

Please sign in to comment.