Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a886617

Browse files
authored
Merge pull request #24876 from meeseeksmachine/auto-backport-of-pr-24873-on-v3.6.x
Backport PR #24873 on branch v3.6.x (Copy-edit fonts docs.)
2 parents 119279d + 8db670d commit a886617

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

doc/users/explain/fonts.rst

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Fonts in PDF and PostScript
1919
---------------------------
2020

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

2626
.. list-table:: Type of Fonts
2727
:header-rows: 1
@@ -40,33 +40,35 @@ fonts' in pdf which is explained later in the guide):
4040
- Do not support font hinting
4141
- Hinting supported (virtual machine processes the "hints")
4242
* - Non-subsetted through Matplotlib
43-
- Subsetted via external module `ttconv <https://github.com/sandflow/ttconv>`_
44-
- Subsetted via external module `fonttools <https://github.com/fonttools/fonttools>`__
43+
- Subsetted via external module ttconv
44+
- Subsetted via external module `fontTools <https://github.com/fonttools/fonttools>`__
4545

46-
NOTE: Adobe will disable support for authoring with Type 1 fonts in
47-
January 2023. `Read more here. <https://helpx.adobe.com/fonts/kb/postscript-type-1-fonts-end-of-support.html>`_
46+
.. note::
4847

48+
Adobe disabled__ support for authoring with Type 1 fonts in January 2023.
49+
50+
__ https://helpx.adobe.com/fonts/kb/postscript-type-1-fonts-end-of-support.html
4951

5052
Other font specifications which Matplotlib supports:
5153

5254
- Type 42 fonts (PS):
5355

5456
- PostScript wrapper around TrueType fonts
5557
- 42 is the `Answer to Life, the Universe, and Everything! <https://en.wikipedia.org/wiki/Answer_to_Life,_the_Universe,_and_Everything>`_
56-
- Matplotlib uses an external library called `fonttools <https://github.com/fonttools/fonttools>`__
58+
- Matplotlib uses the external library `fontTools <https://github.com/fonttools/fonttools>`__
5759
to subset these types of fonts
5860

5961
- OpenType fonts:
6062

6163
- OpenType is a new standard for digital type fonts, developed jointly by
6264
Adobe and Microsoft
6365
- Generally contain a much larger character set!
64-
- Limited Support with Matplotlib
66+
- Limited support with Matplotlib
6567

66-
Font Subsetting
68+
Font subsetting
6769
~~~~~~~~~~~~~~~
6870

69-
The PDF and PostScript formats support embedding fonts in files allowing the
71+
The PDF and PostScript formats support embedding fonts in files, allowing the
7072
display program to correctly render the text, independent of what fonts are
7173
installed on the viewer's computer and without the need to pre-rasterize the text.
7274
This ensures that if the output is zoomed or resized the text does not become
@@ -79,10 +81,9 @@ only embed the glyphs actually used. This gets both vector text and small
7981
files sizes. Computing the subset of the font required and writing the new
8082
(reduced) font are both complex problem and thus Matplotlib relies on
8183
`fontTools <https://fonttools.readthedocs.io/en/latest/>`__ and a vendored fork
82-
of `ttconv <https://github.com/sandflow/ttconv>`_.
83-
84-
Currently Type 3, Type 42, and TrueType fonts are subseted. Type 1 fonts are not.
84+
of ttconv.
8585

86+
Currently Type 3, Type 42, and TrueType fonts are subsetted. Type 1 fonts are not.
8687

8788
Core Fonts
8889
~~~~~~~~~~
@@ -91,11 +92,11 @@ In addition to the ability to embed fonts, as part of the `PostScript
9192
<https://en.wikipedia.org/wiki/PostScript_fonts#Core_Font_Set>`_ and `PDF
9293
specification
9394
<https://docs.oracle.com/cd/E96927_01/TSG/FAQ/What%20are%20the%2014%20base%20fonts%20distributed%20with%20Acroba.html>`_
94-
there are 14 Core Font that compliant viewers must ensure are available. If
95+
there are 14 Core Fonts that compliant viewers must ensure are available. If
9596
you restrict your document to only these fonts you do not have to embed any
9697
font information in the document but still get vector text.
9798

98-
This is especially helpful to generate *really lightweight* documents.::
99+
This is especially helpful to generate *really lightweight* documents::
99100

100101
# trigger core fonts for PDF backend
101102
plt.rcParams["pdf.use14corefonts"] = True
@@ -109,7 +110,6 @@ This is especially helpful to generate *really lightweight* documents.::
109110
fig.savefig("AFM_PDF.pdf", format="pdf")
110111
fig.savefig("AFM_PS.ps", format="ps)
111112

112-
113113
Fonts in SVG
114114
------------
115115

@@ -118,12 +118,11 @@ Text can output to SVG in two ways controlled by :rc:`svg.fonttype`:
118118
- as a path (``'path'``) in the SVG
119119
- as string in the SVG with font styling on the element (``'none'``)
120120

121-
122121
When saving via ``'path'`` Matplotlib will compute the path of the glyphs used
123-
as vector paths and write those to the output. The advantage of this is that
124-
the SVG will look the same on all computers independent of what fonts are
122+
as vector paths and write those to the output. The advantage of doing so is
123+
that the SVG will look the same on all computers independent of what fonts are
125124
installed. However the text will not be editable after the fact.
126-
In contrast saving with ``'none'`` will result in smaller files and the
125+
In contrast, saving with ``'none'`` will result in smaller files and the
127126
text will appear directly in the markup. However, the appearance may vary
128127
based on the SVG viewer and what fonts are available.
129128

@@ -135,11 +134,10 @@ To output text to raster formats via Agg, Matplotlib relies on `FreeType
135134
changes between FreeType versions we pin to a specific version for our image
136135
comparison tests.
137136

138-
139137
How Matplotlib selects fonts
140138
----------------------------
141139

142-
Internally using a Font in Matplotlib is a three step process:
140+
Internally, using a font in Matplotlib is a three step process:
143141

144142
1. a `.FontProperties` object is created (explicitly or implicitly)
145143
2. based on the `.FontProperties` object the methods on `.FontManager` are used
@@ -153,16 +151,16 @@ specified by the `CSS1 Specifications
153151
<http://www.w3.org/TR/1998/REC-CSS2-19980512/>`_ which is used by web browsers.
154152
This algorithm takes into account the font family name (e.g. "Arial", "Noto
155153
Sans CJK", "Hack", ...), the size, style, and weight. In addition to family
156-
names that map directly to fonts there are five "generic font family names" (
157-
serif, monospace, fantasy, cursive, and sans-serif) that will internally be
154+
names that map directly to fonts there are five "generic font family names"
155+
(serif, monospace, fantasy, cursive, and sans-serif) that will internally be
158156
mapped to any one of a set of fonts.
159157

160158
Currently the public API for doing step 2 is `.FontManager.findfont` (and that
161159
method on the global `.FontManager` instance is aliased at the module level as
162160
`.font_manager.findfont`), which will only find a single font and return the absolute
163161
path to the font on the filesystem.
164162

165-
Font Fallback
163+
Font fallback
166164
-------------
167165

168166
There is no font that covers the entire Unicode space thus it is possible for the
@@ -173,7 +171,6 @@ same `.Text` instance (as a web browser does). As of Matplotlib 3.6 the Agg,
173171
SVG, PDF, and PS backends will "fallback" through multiple fonts in a single
174172
`.Text` instance:
175173

176-
177174
.. plot::
178175
:include-source:
179176
:caption: The string "There are 几个汉字 in between!" rendered with 2 fonts.
@@ -185,7 +182,6 @@ SVG, PDF, and PS backends will "fallback" through multiple fonts in a single
185182
ha='center'
186183
)
187184

188-
189185
Internally this is implemented by setting The "font family" on
190186
`.FontProperties` objects to a list of font families. A (currently)
191187
private API extracts a list of paths to all of the fonts found and then

0 commit comments

Comments
 (0)