Repository: matplotlib/matplotlib
File: galleries/users_explain/text/fonts.py (Python)

Code before:
fonts.  See :ref:`Customizing text properties <text_props>` for
details and :ref:`font-nonlatin` in particular for glyphs not supported by
DejaVu Sans.

Matplotlib also provides an option to offload text rendering to a TeX engine
(``usetex=True``), see :ref:`Text rendering with LaTeX
<usetex>`.

Fonts in PDF and PostScript
---------------------------

Fonts have a long (and sometimes incompatible) history in computing, leading to
different platforms supporting different types of fonts.  In practice,
Matplotlib supports three font specifications (in addition to pdf 'core fonts',
which are explained later in the guide):

.. table:: Type of Fonts

  +--------------------------+----------------------------+----------------------------+
  | Type 1 (PDF with usetex) | Type 3 (PDF/PS)            | TrueType (PDF)             |
  +==========================+============================+============================+
  | One of the oldest types, | Similar to Type 1 in       | Newer than previous types, |
  | introduced by Adobe      | terms of introduction      | used commonly today,       |
  |                          |                            | introduced by Apple        |
  +--------------------------+----------------------------+----------------------------+
  | Restricted subset of     | Full PostScript language,  | Include a virtual machine  |
  | PostScript, charstrings  | allows embedding arbitrary | that can execute code!     |
  | are in bytecode          | code (in theory, even      |                            |
  |                          | render fractals when       |                            |
  |                          | rasterizing!)              |                            |
  +--------------------------+----------------------------+----------------------------+
  | These fonts support font | Do not support font hinting| Hinting supported (virtual |
  | hinting                  |                            | machine processes the      |
  |                          |                            | "hints")                   |
  +--------------------------+----------------------------+----------------------------+
  | Subsetted by code in     | Subsetted via external module                           |
  | `matplotlib._type1font`  | `fontTools <https://github.com/fonttools/fonttools>`__  |
  +--------------------------+----------------------------+----------------------------+

.. note::

   Adobe disabled__ support for authoring with Type 1 fonts in January 2023.
   Matplotlib uses Type 1 fonts for compatibility with TeX: when the usetex
   feature is used with the PDF backend, Matplotlib reads the fonts used by
   the TeX engine, which are usually Type 1.

   __ https://helpx.adobe.com/fonts/kb/postscript-type-1-fonts-end-of-support.html

Other font specifications which Matplotlib supports:

- Type 42 fonts (PS):

Review comment (suggestion):
```suggestion
  | Restricted subset of     | Full PostScript language,  | Includes a virtual machine  |
```

Code after:
fonts.  See :ref:`Customizing text properties <text_props>` for
details and :ref:`font-nonlatin` in particular for glyphs not supported by
DejaVu Sans.

Matplotlib also provides an option to offload text rendering to a TeX engine
(``usetex=True``), see :ref:`Text rendering with LaTeX
<usetex>`.

Fonts in PDF and PostScript
---------------------------

Fonts have a long (and sometimes incompatible) history in computing, leading to
different platforms supporting different types of fonts.  In practice,
Matplotlib supports three font specifications (in addition to pdf 'core fonts',
which are explained later in the guide):

.. table:: Type of Fonts

  +--------------------------+----------------------------+----------------------------+
  | Type 1 (PDF with usetex) | Type 3 (PDF/PS)            | TrueType (PDF)             |
  +==========================+============================+============================+
  | One of the oldest types, | Similar to Type 1 in       | Newer than previous types, |
  | introduced by Adobe      | terms of introduction      | used commonly today,       |
  |                          |                            | introduced by Apple        |
  +--------------------------+----------------------------+----------------------------+
  | Restricted subset of     | Full PostScript language,  | Includes a virtual machine |
  | PostScript, charstrings  | allows embedding arbitrary | that can execute code!     |
  | are in bytecode          | code (in theory, even      |                            |
  |                          | render fractals when       |                            |
  |                          | rasterizing!)              |                            |
  +--------------------------+----------------------------+----------------------------+
  | Supports font            | Does not support font      | Supports font hinting      |
  | hinting                  | hinting                    | (virtual machine processes |
  |                          |                            | the "hints")               |
  +--------------------------+----------------------------+----------------------------+
  | Subsetted by code in     | Subsetted via external module                           |
  | `matplotlib._type1font`  | `fontTools <https://github.com/fonttools/fonttools>`__  |
  +--------------------------+----------------------------+----------------------------+

.. note::

   Adobe disabled__ support for authoring with Type 1 fonts in January 2023.
   Matplotlib uses Type 1 fonts for compatibility with TeX; when the usetex
   feature is used with the PDF backend, Matplotlib reads the fonts used by
   the TeX engine, which are usually Type 1.

   __ https://helpx.adobe.com/fonts/kb/postscript-type-1-fonts-end-of-support.html

Other font specifications which Matplotlib supports:

- Type 42 fonts (PS):