1- All about Matplotlib and Fonts!
1+ Fonts in Matplotlib Text Engine
22===============================
33
4- The story of fonts has been quite eventful throughout time. It involves
5- contributions of tech giants such as the likes of Adobe, Apple and Microsoft.
4+ Matplotlib needs fonts to work with its text engine, some of which are shipped
5+ alongside the installation. Users can configure the default fonts, or even
6+ provide their own custom fonts! Follow this guide.
67
7- Types
8- -----
9- In practice, there are 3 types Matplotlib supports (in addition to
10- 'core fonts', more about which is explained later in the guide):
8+ However, Matplotlib also provides an option to offload text rendering to a TeX
9+ engine (``usetex=True ``). Consult this guide.
10+
11+ Fonts have a long and sometimes incompatible history in computing, leading to
12+ different platforms supporting different types of fonts. In practice, there are
13+ 3 types of font specifications Matplotlib supports (in addition to 'core
14+ fonts', more about which is explained later in the guide):
1115
1216.. list-table :: Type of Fonts
1317 :header-rows: 1
@@ -57,13 +61,14 @@ a way that when these documents are visually scaled, the text does not appear
5761pixelated.
5862
5963This can be achieved by virtually embedding the *whole * font file within the
60- output document. However, this can lead to **very large documents **, wherein
61- most of the size bandwidth is captured by that font file data.
64+ output document. However, this can lead to very large documents, as some
65+ fonts (for instance, CJK - Chinese/Japanese/Korean fonts) can contain a large
66+ number of glyphs, and thus their embedded size can be quite huge.
6267
63- Font Subsetting is a way to embed only the * required * glyphs within the
64- documents. Fonts can be considered as a collection of glyphs, so ultimately the
65- goal is to find out *which * glyphs are required for a certain array of
66- characters, and embed only those within the output.
68+ Font Subsetting can be used before generating documents, to embed only the
69+ * required * glyphs within the documents. Fonts can be considered as a collection
70+ of glyphs, so ultimately the goal is to find out *which * glyphs are required
71+ for a certain array of characters, and embed only those within the output.
6772
6873.. note ::
6974 The role of subsetter really shines when we encounter characters like **ä **
@@ -73,8 +78,8 @@ characters, and embed only those within the output.
7378
7479Luckily, Matplotlib uses a fork of an external dependency called
7580`ttconv <https://github.com/sandflow/ttconv >`_, which helps in embedding and
76- subsetting stuff . (however, recent versions have moved away from ttconv to pure
77- Python for certain types: for more details visit
81+ subsetting font data . (however, recent versions have moved away from ttconv to
82+ pure Python for certain types: for more details visit
7883`these <https://github.com/matplotlib/matplotlib/pull/18370 >`_, `links <https://github.com/matplotlib/matplotlib/pull/18181 >`_)
7984
8085| *Type 1 fonts are still non-subsetted* through Matplotlib. (though one will encounter these mostly via *usetex*/*dviread* in PDF backend)
0 commit comments