1|CI Build Status| |Coverage Status| |PyPI| |Gitter Chat|
2
3What is this?
4~~~~~~~~~~~~~
5
6| fontTools is a library for manipulating fonts, written in Python. The
7 project includes the TTX tool, that can convert TrueType and OpenType
8 fonts to and from an XML text format, which is also called TTX. It
9 supports TrueType, OpenType, AFM and to an extent Type 1 and some
10 Mac-specific formats. The project has an `MIT open-source
11 licence <LICENSE>`__.
12| Among other things this means you can use it free of charge.
13
14`User documentation <https://fonttools.readthedocs.io/en/latest/>`_ and
15`developer documentation <https://fonttools.readthedocs.io/en/latest/developer.html>`_
16are available at `Read the Docs <https://fonttools.readthedocs.io/>`_.
17
18Installation
19~~~~~~~~~~~~
20
21FontTools 4.x requires `Python <http://www.python.org/download/>`__ 3.6
22or later. FontTools 3.x requires Python 2.7 or later.
23
24**NOTE** From August 2019, until no later than January 1 2020, the support
25for *Python 2.7* will be limited to only critical bug fixes, and no new features
26will be added to the ``py27`` branch. You can read more `here <https://python3statement.org>`__
27and `here <https://github.com/fonttools/fonttools/issues/765>`__ for the
28reasons behind this decision.
29
30The package is listed in the Python Package Index (PyPI), so you can
31install it with `pip <https://pip.pypa.io>`__:
32
33.. code:: sh
34
35 pip install fonttools
36
37If you would like to contribute to its development, you can clone the
38repository from GitHub, install the package in 'editable' mode and
39modify the source code in place. We recommend creating a virtual
40environment, using `virtualenv <https://virtualenv.pypa.io>`__ or
41Python 3 `venv <https://docs.python.org/3/library/venv.html>`__ module.
42
43.. code:: sh
44
45 # download the source code to 'fonttools' folder
46 git clone https://github.com/fonttools/fonttools.git
47 cd fonttools
48
49 # create new virtual environment called e.g. 'fonttools-venv', or anything you like
50 python -m virtualenv fonttools-venv
51
52 # source the `activate` shell script to enter the environment (Un*x); to exit, just type `deactivate`
53 . fonttools-venv/bin/activate
54
55 # to activate the virtual environment in Windows `cmd.exe`, do
56 fonttools-venv\Scripts\activate.bat
57
58 # install in 'editable' mode
59 pip install -e .
60
61Optional Requirements
62---------------------
63
64The ``fontTools`` package currently has no (required) external dependencies
65besides the modules included in the Python Standard Library.
66However, a few extra dependencies are required by some of its modules, which
67are needed to unlock optional features.
68The ``fonttools`` PyPI distribution also supports so-called "extras", i.e. a
69set of keywords that describe a group of additional dependencies, which can be
70used when installing via pip, or when specifying a requirement.
71For example:
72
73.. code:: sh
74
75 pip install fonttools[ufo,lxml,woff,unicode]
76
77This command will install fonttools, as well as the optional dependencies that
78are required to unlock the extra features named "ufo", etc.
79
80- ``Lib/fontTools/misc/etree.py``
81
82 The module exports a ElementTree-like API for reading/writing XML files, and
83 allows to use as the backend either the built-in ``xml.etree`` module or
84 `lxml <https://lxml.de>`__. The latter is preferred whenever present,
85 as it is generally faster and more secure.
86
87 *Extra:* ``lxml``
88
89- ``Lib/fontTools/ufoLib``
90
91 Package for reading and writing UFO source files; it requires:
92
93 * `fs <https://pypi.org/pypi/fs>`__: (aka ``pyfilesystem2``) filesystem
94 abstraction layer.
95
96 * `enum34 <https://pypi.org/pypi/enum34>`__: backport for the built-in ``enum``
97 module (only required on Python < 3.4).
98
99 *Extra:* ``ufo``
100
101- ``Lib/fontTools/ttLib/woff2.py``
102
103 Module to compress/decompress WOFF 2.0 web fonts; it requires:
104
105 * `brotli <https://pypi.python.org/pypi/Brotli>`__: Python bindings of
106 the Brotli compression library.
107
108 *Extra:* ``woff``
109
110- ``Lib/fontTools/ttLib/sfnt.py``
111
112 To better compress WOFF 1.0 web fonts, the following module can be used
113 instead of the built-in ``zlib`` library:
114
115 * `zopfli <https://pypi.python.org/pypi/zopfli>`__: Python bindings of
116 the Zopfli compression library.
117
118 *Extra:* ``woff``
119
120- ``Lib/fontTools/unicode.py``
121
122 To display the Unicode character names when dumping the ``cmap`` table
123 with ``ttx`` we use the ``unicodedata`` module in the Standard Library.
124 The version included in there varies between different Python versions.
125 To use the latest available data, you can install:
126
127 * `unicodedata2 <https://pypi.python.org/pypi/unicodedata2>`__:
128 ``unicodedata`` backport for Python 2.7 and 3.x updated to the latest
129 Unicode version 12.0. Note this is not necessary if you use Python 3.8
130 as the latter already comes with an up-to-date ``unicodedata``.
131
132 *Extra:* ``unicode``
133
134- ``Lib/fontTools/varLib/interpolatable.py``
135
136 Module for finding wrong contour/component order between different masters.
137 It requires one of the following packages in order to solve the so-called
138 "minimum weight perfect matching problem in bipartite graphs", or
139 the Assignment problem:
140
141 * `scipy <https://pypi.python.org/pypi/scipy>`__: the Scientific Library
142 for Python, which internally uses `NumPy <https://pypi.python.org/pypi/numpy>`__
143 arrays and hence is very fast;
144 * `munkres <https://pypi.python.org/pypi/munkres>`__: a pure-Python
145 module that implements the Hungarian or Kuhn-Munkres algorithm.
146
147 *Extra:* ``interpolatable``
148
149- ``Lib/fontTools/varLib/plot.py``
150
151 Module for visualizing DesignSpaceDocument and resulting VariationModel.
152
153 * `matplotlib <https://pypi.org/pypi/matplotlib>`__: 2D plotting library.
154
155 *Extra:* ``plot``
156
157- ``Lib/fontTools/misc/symfont.py``
158
159 Advanced module for symbolic font statistics analysis; it requires:
160
161 * `sympy <https://pypi.python.org/pypi/sympy>`__: the Python library for
162 symbolic mathematics.
163
164 *Extra:* ``symfont``
165
166- ``Lib/fontTools/t1Lib.py``
167
168 To get the file creator and type of Macintosh PostScript Type 1 fonts
169 on Python 3 you need to install the following module, as the old ``MacOS``
170 module is no longer included in Mac Python:
171
172 * `xattr <https://pypi.python.org/pypi/xattr>`__: Python wrapper for
173 extended filesystem attributes (macOS platform only).
174
175 *Extra:* ``type1``
176
177- ``Lib/fontTools/ttLib/removeOverlaps.py``
178
179 Simplify TrueType glyphs by merging overlapping contours and components.
180
181 * `skia-pathops <https://pypi.python.org/pypy/skia-pathops>`__: Python
182 bindings for the Skia library's PathOps module, performing boolean
183 operations on paths (union, intersection, etc.).
184
185 *Extra:* ``pathops``
186
187- ``Lib/fontTools/pens/cocoaPen.py`` and ``Lib/fontTools/pens/quartzPen.py``
188
189 Pens for drawing glyphs with Cocoa ``NSBezierPath`` or ``CGPath`` require:
190
191 * `PyObjC <https://pypi.python.org/pypi/pyobjc>`__: the bridge between
192 Python and the Objective-C runtime (macOS platform only).
193
194- ``Lib/fontTools/pens/qtPen.py``
195
196 Pen for drawing glyphs with Qt's ``QPainterPath``, requires:
197
198 * `PyQt5 <https://pypi.python.org/pypi/PyQt5>`__: Python bindings for
199 the Qt cross platform UI and application toolkit.
200
201- ``Lib/fontTools/pens/reportLabPen.py``
202
203 Pen to drawing glyphs as PNG images, requires:
204
205 * `reportlab <https://pypi.python.org/pypi/reportlab>`__: Python toolkit
206 for generating PDFs and graphics.
207
208Acknowledgements
209~~~~~~~~~~~~~~~~
210
211In alphabetical order:
212
213Olivier Berten, Samyak Bhuta, Erik van Blokland, Petr van Blokland,
214Jelle Bosma, Sascha Brawer, Tom Byrer, Antonio Cavedoni, Frédéric
215Coiffier, Vincent Connare, David Corbett, Simon Cozens, Dave Crossland,
216Simon Daniels, Peter Dekkers, Behdad Esfahbod, Behnam Esfahbod, Hannes
217Famira, Sam Fishman, Matt Fontaine, Yannis Haralambous, Greg Hitchcock,
218Jeremie Hornus, Khaled Hosny, John Hudson, Denis Moyogo Jacquerye, Jack
219Jansen, Tom Kacvinsky, Jens Kutilek, Antoine Leca, Werner Lemberg, Tal
220Leming, Peter Lofting, Cosimo Lupo, Masaya Nakamura, Dave Opstad,
221Laurence Penney, Roozbeh Pournader, Garret Rieger, Read Roberts, Guido
222van Rossum, Just van Rossum, Andreas Seidel, Georg Seifert, Chris
223Simpkins, Miguel Sousa, Adam Twardoch, Adrien Tétar, Vitaly Volkov,
224Paul Wise.
225
226Copyrights
227~~~~~~~~~~
228
229| Copyright (c) 1999-2004 Just van Rossum, LettError
230 (just@letterror.com)
231| See `LICENSE <LICENSE>`__ for the full license.
232
233Copyright (c) 2000 BeOpen.com. All Rights Reserved.
234
235Copyright (c) 1995-2001 Corporation for National Research Initiatives.
236All Rights Reserved.
237
238Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All
239Rights Reserved.
240
241Have fun!
242
243.. |CI Build Status| image:: https://github.com/fonttools/fonttools/workflows/Test/badge.svg
244 :target: https://github.com/fonttools/fonttools/actions?query=workflow%3ATest
245.. |Coverage Status| image:: https://codecov.io/gh/fonttools/fonttools/branch/master/graph/badge.svg
246 :target: https://codecov.io/gh/fonttools/fonttools
247.. |PyPI| image:: https://img.shields.io/pypi/v/fonttools.svg
248 :target: https://pypi.org/project/FontTools
249.. |Gitter Chat| image:: https://badges.gitter.im/fonttools-dev/Lobby.svg
250 :alt: Join the chat at https://gitter.im/fonttools-dev/Lobby
251 :target: https://gitter.im/fonttools-dev/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
252