Skip to content

Commit 84046cb

Browse files
committed
Clarify family-names vs generic-families
1 parent bcc1ce8 commit 84046cb

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

tutorials/text/text_props.py

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@
149149
# +---------------------+----------------------------------------------------+
150150
# | rcParam | usage |
151151
# +=====================+====================================================+
152-
# | ``'font.family'`` | List of either names of font or ``{'cursive', |
153-
# | | 'fantasy', 'monospace', 'sans', 'sans serif', |
154-
# | | 'sans-serif', 'serif'}``. |
152+
# | ``'font.family'`` | List of font families (installed on user's machine)|
153+
# | | and/or ``{'cursive', 'fantasy', 'monospace', |
154+
# | | 'sans', 'sans serif', 'sans-serif', 'serif'}``. |
155155
# | | |
156156
# +---------------------+----------------------------------------------------+
157157
# | ``'font.style'`` | The default style, ex ``'normal'``, |
@@ -174,13 +174,18 @@
174174
# | | this size. |
175175
# +---------------------+----------------------------------------------------+
176176
#
177-
# The mapping between the family aliases (``{'cursive', 'fantasy',
178-
# 'monospace', 'sans', 'sans serif', 'sans-serif', 'serif'}``) and actual font names
177+
# Matplotlib can use font families installed on the user's computer, i.e.
178+
# Helvetica, Times, etc. Font families can also be specified with
179+
# generic-family aliases like (``{'cursive', 'fantasy', 'monospace',
180+
# 'sans', 'sans serif', 'sans-serif', 'serif'}``).
181+
#
182+
# The mapping between the generic family aliases and actual font families
183+
# (mentioned at :doc:`default rcParams </tutorials/introductory/customizing>`)
179184
# is controlled by the following rcParams:
180185
#
181186
#
182187
# +------------------------------------------+--------------------------------+
183-
# | family alias | rcParam with mappings |
188+
# | CSS-based generic-family alias | rcParam with mappings |
184189
# +==========================================+================================+
185190
# | ``'serif'`` | ``'font.serif'`` |
186191
# +------------------------------------------+--------------------------------+
@@ -194,7 +199,15 @@
194199
# +------------------------------------------+--------------------------------+
195200
#
196201
#
197-
# which are lists of font names.
202+
# If any of generic family names appear in ``'font.family'``, we replace that entry
203+
# by all the entries in the corresponding rcParam mapping.
204+
# For example: ::
205+
#
206+
# matplotlib.rcParams['font.family'] = ['Family1', 'serif', 'Family2']
207+
# matplotlib.rcParams['font.serif'] = ['SerifFamily1', 'SerifFamily2']
208+
#
209+
# # This is effectively translated to:
210+
# matplotlib.rcParams['font.family'] = ['Family1', 'SerifFamily1', 'SerifFamily2', 'Family2']
198211
#
199212
# Text with non-latin glyphs
200213
# ==========================
@@ -204,14 +217,26 @@
204217
# Korean, or Japanese.
205218
#
206219
# To set the default font to be one that supports the code points you
207-
# need, prepend the font name to ``'font.family'`` or the desired alias
208-
# lists ::
220+
# need, prepend the font name to ``'font.family'`` (recommended), or to the
221+
# desired alias lists. ::
222+
#
223+
# # first method
224+
# matplotlib.rcParams['font.family'] = ['Source Han Sans TW', 'sans-serif']
225+
#
226+
# # second method
227+
# matplotlib.rcParams['font.family'] = ['sans-serif']
228+
# matplotlib.rcParams['sans-serif'] = ['Source Han Sans TW', ...]
229+
#
230+
# The generic family alias lists contain fonts that are either shipped
231+
# alongside Matplotlib (so they have 100% chance of being found), or fonts
232+
# which have a very high probability of being present in most systems.
209233
#
210-
# matplotlib.rcParams['font.sans-serif'] = ['Source Han Sans TW', 'sans-serif']
234+
# A good practice when setting custom font families is to append
235+
# a generic-family to the font-family list as a last resort.
211236
#
212-
# or set it in your :file:`.matplotlibrc` file::
237+
# You can also set it in your :file:`.matplotlibrc` file::
213238
#
214-
# font.sans-serif: Source Han Sans TW, Arial, sans-serif
239+
# font.family: Source Han Sans TW, Arial, sans-serif
215240
#
216241
# To control the font used on per-artist basis use the *name*, *fontname* or
217242
# *fontproperties* keyword arguments documented :doc:`above

0 commit comments

Comments
 (0)