README.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. |CI Build Status| |Coverage Status| |PyPI| |Gitter Chat|
  2. What is this?
  3. ~~~~~~~~~~~~~
  4. | fontTools is a library for manipulating fonts, written in Python. The
  5. project includes the TTX tool, that can convert TrueType and OpenType
  6. fonts to and from an XML text format, which is also called TTX. It
  7. supports TrueType, OpenType, AFM and to an extent Type 1 and some
  8. Mac-specific formats. The project has an `MIT open-source
  9. licence <LICENSE>`__.
  10. | Among other things this means you can use it free of charge.
  11. `User documentation <https://fonttools.readthedocs.io/en/latest/>`_ and
  12. `developer documentation <https://fonttools.readthedocs.io/en/latest/developer.html>`_
  13. are available at `Read the Docs <https://fonttools.readthedocs.io/>`_.
  14. Installation
  15. ~~~~~~~~~~~~
  16. FontTools requires `Python <http://www.python.org/download/>`__ 3.8
  17. or later. We try to follow the same schedule of minimum Python version support as
  18. NumPy (see `NEP 29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`__).
  19. The package is listed in the Python Package Index (PyPI), so you can
  20. install it with `pip <https://pip.pypa.io>`__:
  21. .. code:: sh
  22. pip install fonttools
  23. If you would like to contribute to its development, you can clone the
  24. repository from GitHub, install the package in 'editable' mode and
  25. modify the source code in place. We recommend creating a virtual
  26. environment, using `virtualenv <https://virtualenv.pypa.io>`__ or
  27. Python 3 `venv <https://docs.python.org/3/library/venv.html>`__ module.
  28. .. code:: sh
  29. # download the source code to 'fonttools' folder
  30. git clone https://github.com/fonttools/fonttools.git
  31. cd fonttools
  32. # create new virtual environment called e.g. 'fonttools-venv', or anything you like
  33. python -m virtualenv fonttools-venv
  34. # source the `activate` shell script to enter the environment (Unix-like); to exit, just type `deactivate`
  35. . fonttools-venv/bin/activate
  36. # to activate the virtual environment in Windows `cmd.exe`, do
  37. fonttools-venv\Scripts\activate.bat
  38. # install in 'editable' mode
  39. pip install -e .
  40. Optional Requirements
  41. ---------------------
  42. The ``fontTools`` package currently has no (required) external dependencies
  43. besides the modules included in the Python Standard Library.
  44. However, a few extra dependencies are required by some of its modules, which
  45. are needed to unlock optional features.
  46. The ``fonttools`` PyPI distribution also supports so-called "extras", i.e. a
  47. set of keywords that describe a group of additional dependencies, which can be
  48. used when installing via pip, or when specifying a requirement.
  49. For example:
  50. .. code:: sh
  51. pip install fonttools[ufo,lxml,woff,unicode]
  52. This command will install fonttools, as well as the optional dependencies that
  53. are required to unlock the extra features named "ufo", etc.
  54. - ``Lib/fontTools/misc/etree.py``
  55. The module exports a ElementTree-like API for reading/writing XML files, and
  56. allows to use as the backend either the built-in ``xml.etree`` module or
  57. `lxml <https://lxml.de>`__. The latter is preferred whenever present,
  58. as it is generally faster and more secure.
  59. *Extra:* ``lxml``
  60. - ``Lib/fontTools/ufoLib``
  61. Package for reading and writing UFO source files; it requires:
  62. * `fs <https://pypi.org/pypi/fs>`__: (aka ``pyfilesystem2``) filesystem
  63. abstraction layer.
  64. * `enum34 <https://pypi.org/pypi/enum34>`__: backport for the built-in ``enum``
  65. module (only required on Python < 3.4).
  66. *Extra:* ``ufo``
  67. - ``Lib/fontTools/ttLib/woff2.py``
  68. Module to compress/decompress WOFF 2.0 web fonts; it requires:
  69. * `brotli <https://pypi.python.org/pypi/Brotli>`__: Python bindings of
  70. the Brotli compression library.
  71. *Extra:* ``woff``
  72. - ``Lib/fontTools/ttLib/sfnt.py``
  73. To better compress WOFF 1.0 web fonts, the following module can be used
  74. instead of the built-in ``zlib`` library:
  75. * `zopfli <https://pypi.python.org/pypi/zopfli>`__: Python bindings of
  76. the Zopfli compression library.
  77. *Extra:* ``woff``
  78. - ``Lib/fontTools/unicode.py``
  79. To display the Unicode character names when dumping the ``cmap`` table
  80. with ``ttx`` we use the ``unicodedata`` module in the Standard Library.
  81. The version included in there varies between different Python versions.
  82. To use the latest available data, you can install:
  83. * `unicodedata2 <https://pypi.python.org/pypi/unicodedata2>`__:
  84. ``unicodedata`` backport for Python 3.x updated to the latest Unicode
  85. version 15.0.
  86. *Extra:* ``unicode``
  87. - ``Lib/fontTools/varLib/interpolatable.py``
  88. Module for finding wrong contour/component order between different masters.
  89. It requires one of the following packages in order to solve the so-called
  90. "minimum weight perfect matching problem in bipartite graphs", or
  91. the Assignment problem:
  92. * `scipy <https://pypi.python.org/pypi/scipy>`__: the Scientific Library
  93. for Python, which internally uses `NumPy <https://pypi.python.org/pypi/numpy>`__
  94. arrays and hence is very fast;
  95. * `munkres <https://pypi.python.org/pypi/munkres>`__: a pure-Python
  96. module that implements the Hungarian or Kuhn-Munkres algorithm.
  97. To plot the results to a PDF or HTML format, you also need to install:
  98. * `pycairo <https://pypi.org/project/pycairo/>`__: Python bindings for the
  99. Cairo graphics library. Note that wheels are currently only available for
  100. Windows, for other platforms see pycairo's `installation instructions
  101. <https://pycairo.readthedocs.io/en/latest/getting_started.html>`__.
  102. *Extra:* ``interpolatable``
  103. - ``Lib/fontTools/varLib/plot.py``
  104. Module for visualizing DesignSpaceDocument and resulting VariationModel.
  105. * `matplotlib <https://pypi.org/pypi/matplotlib>`__: 2D plotting library.
  106. *Extra:* ``plot``
  107. - ``Lib/fontTools/misc/symfont.py``
  108. Advanced module for symbolic font statistics analysis; it requires:
  109. * `sympy <https://pypi.python.org/pypi/sympy>`__: the Python library for
  110. symbolic mathematics.
  111. *Extra:* ``symfont``
  112. - ``Lib/fontTools/t1Lib.py``
  113. To get the file creator and type of Macintosh PostScript Type 1 fonts
  114. on Python 3 you need to install the following module, as the old ``MacOS``
  115. module is no longer included in Mac Python:
  116. * `xattr <https://pypi.python.org/pypi/xattr>`__: Python wrapper for
  117. extended filesystem attributes (macOS platform only).
  118. *Extra:* ``type1``
  119. - ``Lib/fontTools/ttLib/removeOverlaps.py``
  120. Simplify TrueType glyphs by merging overlapping contours and components.
  121. * `skia-pathops <https://pypi.python.org/pypy/skia-pathops>`__: Python
  122. bindings for the Skia library's PathOps module, performing boolean
  123. operations on paths (union, intersection, etc.).
  124. *Extra:* ``pathops``
  125. - ``Lib/fontTools/pens/cocoaPen.py`` and ``Lib/fontTools/pens/quartzPen.py``
  126. Pens for drawing glyphs with Cocoa ``NSBezierPath`` or ``CGPath`` require:
  127. * `PyObjC <https://pypi.python.org/pypi/pyobjc>`__: the bridge between
  128. Python and the Objective-C runtime (macOS platform only).
  129. - ``Lib/fontTools/pens/qtPen.py``
  130. Pen for drawing glyphs with Qt's ``QPainterPath``, requires:
  131. * `PyQt5 <https://pypi.python.org/pypi/PyQt5>`__: Python bindings for
  132. the Qt cross platform UI and application toolkit.
  133. - ``Lib/fontTools/pens/reportLabPen.py``
  134. Pen to drawing glyphs as PNG images, requires:
  135. * `reportlab <https://pypi.python.org/pypi/reportlab>`__: Python toolkit
  136. for generating PDFs and graphics.
  137. - ``Lib/fontTools/pens/freetypePen.py``
  138. Pen to drawing glyphs with FreeType as raster images, requires:
  139. * `freetype-py <https://pypi.python.org/pypi/freetype-py>`__: Python binding
  140. for the FreeType library.
  141. - ``Lib/fontTools/ttLib/tables/otBase.py``
  142. Use the Harfbuzz library to serialize GPOS/GSUB using ``hb_repack`` method, requires:
  143. * `uharfbuzz <https://pypi.python.org/pypi/uharfbuzz>`__: Streamlined Cython
  144. bindings for the harfbuzz shaping engine
  145. *Extra:* ``repacker``
  146. How to make a new release
  147. ~~~~~~~~~~~~~~~~~~~~~~~~~
  148. 1) Update ``NEWS.rst`` with all the changes since the last release. Write a
  149. changelog entry for each PR, with one or two short sentences summarizing it,
  150. as well as links to the PR and relevant issues addressed by the PR. Do not
  151. put a new title, the next command will do it for you.
  152. 2) Use semantic versioning to decide whether the new release will be a 'major',
  153. 'minor' or 'patch' release. It's usually one of the latter two, depending on
  154. whether new backward compatible APIs were added, or simply some bugs were fixed.
  155. 3) From inside a venv, first do ``pip install -r dev-requirements.txt``, then run
  156. the ``python setup.py release`` command from the tip of the ``main`` branch.
  157. By default this bumps the third or 'patch' digit only, unless you pass ``--major``
  158. or ``--minor`` to bump respectively the first or second digit.
  159. This bumps the package version string, extracts the changes since the latest
  160. version from ``NEWS.rst``, and uses that text to create an annotated git tag
  161. (or a signed git tag if you pass the ``--sign`` option and your git and Github
  162. account are configured for `signing commits <https://docs.github.com/en/github/authenticating-to-github/managing-commit-signature-verification/signing-commits>`__
  163. using a GPG key).
  164. It also commits an additional version bump which opens the main branch for
  165. the subsequent developmental cycle
  166. 4) Push both the tag and commit to the upstream repository, by running the command
  167. ``git push --follow-tags``. Note: it may push other local tags as well, be
  168. careful.
  169. 5) Let the CI build the wheel and source distribution packages and verify both
  170. get uploaded to the Python Package Index (PyPI).
  171. 6) [Optional] Go to fonttools `Github Releases <https://github.com/fonttools/fonttools/releases>`__
  172. page and create a new release, copy-pasting the content of the git tag
  173. message. This way, the release notes are nicely formatted as markdown, and
  174. users watching the repo will get an email notification. One day we shall
  175. automate that too.
  176. Acknowledgements
  177. ~~~~~~~~~~~~~~~~
  178. In alphabetical order:
  179. aschmitz, Olivier Berten, Samyak Bhuta, Erik van Blokland, Petr van Blokland,
  180. Jelle Bosma, Sascha Brawer, Tom Byrer, Antonio Cavedoni, Frédéric Coiffier,
  181. Vincent Connare, David Corbett, Simon Cozens, Dave Crossland, Simon Daniels,
  182. Peter Dekkers, Behdad Esfahbod, Behnam Esfahbod, Hannes Famira, Sam Fishman,
  183. Matt Fontaine, Takaaki Fuji, Rob Hagemans, Yannis Haralambous, Greg Hitchcock,
  184. Jeremie Hornus, Khaled Hosny, John Hudson, Denis Moyogo Jacquerye, Jack Jansen,
  185. Tom Kacvinsky, Jens Kutilek, Antoine Leca, Werner Lemberg, Tal Leming, Peter
  186. Lofting, Cosimo Lupo, Olli Meier, Masaya Nakamura, Dave Opstad, Laurence Penney,
  187. Roozbeh Pournader, Garret Rieger, Read Roberts, Colin Rofls, Guido van Rossum,
  188. Just van Rossum, Andreas Seidel, Georg Seifert, Chris Simpkins, Miguel Sousa,
  189. Adam Twardoch, Adrien Tétar, Vitaly Volkov, Paul Wise.
  190. Copyrights
  191. ~~~~~~~~~~
  192. | Copyright (c) 1999-2004 Just van Rossum, LettError
  193. (just@letterror.com)
  194. | See `LICENSE <LICENSE>`__ for the full license.
  195. Copyright (c) 2000 BeOpen.com. All Rights Reserved.
  196. Copyright (c) 1995-2001 Corporation for National Research Initiatives.
  197. All Rights Reserved.
  198. Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All
  199. Rights Reserved.
  200. Have fun!
  201. .. |CI Build Status| image:: https://github.com/fonttools/fonttools/workflows/Test/badge.svg
  202. :target: https://github.com/fonttools/fonttools/actions?query=workflow%3ATest
  203. .. |Coverage Status| image:: https://codecov.io/gh/fonttools/fonttools/branch/main/graph/badge.svg
  204. :target: https://codecov.io/gh/fonttools/fonttools
  205. .. |PyPI| image:: https://img.shields.io/pypi/v/fonttools.svg
  206. :target: https://pypi.org/project/FontTools
  207. .. |Gitter Chat| image:: https://badges.gitter.im/fonttools-dev/Lobby.svg
  208. :alt: Join the chat at https://gitter.im/fonttools-dev/Lobby
  209. :target: https://gitter.im/fonttools-dev/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge