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

Skip to content

Commit 4a2a186

Browse files
committed
Merge pull request #5214 from zblz/dejavu-mathtext
Use DejaVu fonts as default for text and mathtext
1 parent bf51375 commit 4a2a186

File tree

650 files changed

+30203
-1360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

650 files changed

+30203
-1360
lines changed

doc/users/mathtext.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ in Donald Knuth's TeX, so the quality is quite good (matplotlib also
1313
provides a ``usetex`` option for those who do want to call out to TeX
1414
to generate their text (see :ref:`usetex-tutorial`).
1515

16-
Any text element can use math text. You should use raw strings
17-
(precede the quotes with an ``'r'``), and surround the math text with
18-
dollar signs ($), as in TeX. Regular text and mathtext can be
19-
interleaved within the same string. Mathtext can use the Computer
20-
Modern fonts (from (La)TeX), `STIX <http://www.aip.org/stixfonts/>`_
21-
fonts (with are designed to blend well with Times) or a Unicode font
22-
that you provide. The mathtext font can be selected with the
23-
customization variable ``mathtext.fontset`` (see
16+
Any text element can use math text. You should use raw strings (precede the
17+
quotes with an ``'r'``), and surround the math text with dollar signs ($), as in
18+
TeX. Regular text and mathtext can be interleaved within the same string.
19+
Mathtext can use DejaVu Sans (default), DejaVu Serif, the Computer Modern fonts
20+
(from (La)TeX), `STIX <http://www.aip.org/stixfonts/>`_ fonts (with are designed
21+
to blend well with Times), or a Unicode font that you provide. The mathtext
22+
font can be selected with the customization variable ``mathtext.fontset`` (see
2423
:ref:`customizing-matplotlib`)
2524

2625
.. note::

doc/users/plotting/colormaps/Lfunction.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,6 @@
1414

1515

1616
mpl.rcParams.update({'font.size': 12})
17-
mpl.rcParams['font.sans-serif'] = ('Arev Sans, Bitstream Vera Sans, '
18-
'Lucida Grande, Verdana, Geneva, Lucid, '
19-
'Helvetica, Avant Garde, sans-serif')
20-
mpl.rcParams['mathtext.fontset'] = 'custom'
21-
mpl.rcParams['mathtext.cal'] = 'cursive'
22-
mpl.rcParams['mathtext.rm'] = 'sans'
23-
mpl.rcParams['mathtext.tt'] = 'monospace'
24-
mpl.rcParams['mathtext.it'] = 'sans:italic'
25-
mpl.rcParams['mathtext.bf'] = 'sans:bold'
26-
mpl.rcParams['mathtext.sf'] = 'sans'
27-
mpl.rcParams['mathtext.fallback_to_cm'] = 'True'
2817

2918

3019
### Red, original Albers plot

doc/users/plotting/colormaps/grayscale.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@
1616
import matplotlib as mpl
1717

1818
mpl.rcParams.update({'font.size': 14})
19-
mpl.rcParams['font.sans-serif'] = ('Arev Sans, Bitstream Vera Sans, '
20-
'Lucida Grande, Verdana, Geneva, Lucid, '
21-
'Helvetica, Avant Garde, sans-serif')
22-
mpl.rcParams['mathtext.fontset'] = 'custom'
23-
mpl.rcParams['mathtext.cal'] = 'cursive'
24-
mpl.rcParams['mathtext.rm'] = 'sans'
25-
mpl.rcParams['mathtext.tt'] = 'monospace'
26-
mpl.rcParams['mathtext.it'] = 'sans:italic'
27-
mpl.rcParams['mathtext.bf'] = 'sans:bold'
28-
mpl.rcParams['mathtext.sf'] = 'sans'
29-
mpl.rcParams['mathtext.fallback_to_cm'] = 'True'
3019

3120

3221
# indices to step through colormap

doc/users/plotting/colormaps/lightness.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@
1616
import matplotlib as mpl
1717

1818
mpl.rcParams.update({'font.size': 12})
19-
mpl.rcParams['font.sans-serif'] = ('Arev Sans, Bitstream Vera Sans, '
20-
'Lucida Grande, Verdana, Geneva, Lucid, '
21-
'Helvetica, Avant Garde, sans-serif')
22-
mpl.rcParams['mathtext.fontset'] = 'custom'
23-
mpl.rcParams['mathtext.cal'] = 'cursive'
24-
mpl.rcParams['mathtext.rm'] = 'sans'
25-
mpl.rcParams['mathtext.tt'] = 'monospace'
26-
mpl.rcParams['mathtext.it'] = 'sans:italic'
27-
mpl.rcParams['mathtext.bf'] = 'sans:bold'
28-
mpl.rcParams['mathtext.sf'] = 'sans'
29-
mpl.rcParams['mathtext.fallback_to_cm'] = 'True'
3019

3120
# indices to step through colormap
3221
x = np.linspace(0.0, 1.0, 100)

doc/users/screenshots.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ Mathtext_examples
253253
Below is a sampling of the many TeX expressions now supported by matplotlib's
254254
internal mathtext engine. The mathtext module provides TeX style mathematical
255255
expressions using `FreeType <http://www.freetype.org/>`_
256-
and the BaKoMa computer modern or `STIX <http://www.stixfonts.org>`_ fonts.
257-
See the :mod:`matplotlib.mathtext` module for additional details.
256+
and the DejaVu, BaKoMa computer modern, or `STIX <http://www.stixfonts.org>`_
257+
fonts. See the :mod:`matplotlib.mathtext` module for additional details.
258258

259259
.. plot:: mpl_examples/pylab_examples/mathtext_examples.py
260260

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Change in default font
2+
----------------------
3+
4+
The default font used by matplotlib in text has been changed to DejaVu Sans and
5+
DejaVu Serif for the sans-serif and serif families, respectively. The DejaVu
6+
font family is based on the previous matplotlib default --Bitstream Vera-- but
7+
includes a much wider range of characters.
8+
9+
The default mathtext font has been changed from Computer Modern to the DejaVu
10+
family to maintain consistency with regular text. Two new options for the
11+
``mathtext.fontset`` configuration parameter have been added: ``dejavusans``
12+
(default) and ``dejavuserif``. Both of these options use DejaVu glyphs whenever
13+
possible and fall back to STIX symbols when a glyph is not found in DejaVu. To
14+
return to the previous behavior, set the rcParam ``mathtext.fontset`` to ``cm``.

examples/api/font_family_rc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
and for the font.family you set a list of font styles to try to find
1212
in order::
1313
14-
rcParams['font.sans-serif'] = ['Tahoma', 'Bitstream Vera Sans',
14+
rcParams['font.sans-serif'] = ['Tahoma', 'DejaVu Sans',
1515
'Lucida Grande', 'Verdana']
1616
1717
"""

examples/misc/font_indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
#fname = '/usr/share/fonts/sfd/FreeSans.ttf'
12-
fname = matplotlib.get_data_path() + '/fonts/ttf/Vera.ttf'
12+
fname = matplotlib.get_data_path() + '/fonts/ttf/DejaVuSans.ttf'
1313
font = FT2Font(fname)
1414
font.set_charmap(0)
1515

examples/misc/ftface_props.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
#fname = '/usr/local/share/matplotlib/VeraIt.ttf'
15-
fname = matplotlib.get_data_path() + '/fonts/ttf/VeraIt.ttf'
15+
fname = matplotlib.get_data_path() + '/fonts/ttf/DejaVuSans-Oblique.ttf'
1616
#fname = '/usr/local/share/matplotlib/cmr10.ttf'
1717

1818
font = ft.FT2Font(fname)

examples/pylab_examples/font_table_ttf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
fontname = sys.argv[1]
3030
else:
3131
fontname = os.path.join(matplotlib.get_data_path(),
32-
'fonts', 'ttf', 'Vera.ttf')
32+
'fonts', 'ttf', 'DejaVuSans.ttf')
3333

3434
font = FT2Font(fontname)
3535
codes = list(font.get_charmap().items())

examples/pylab_examples/logo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
ax = plt.subplot(111, axisbg='y')
1919
plt.plot(t, x)
2020
plt.text(0.5, 0.5, 'matplotlib', color='r',
21-
fontsize=40, fontname=['Courier', 'Bitstream Vera Sans Mono'],
21+
fontsize=40, fontname=['Courier', 'DejaVu Sans Mono'],
2222
horizontalalignment='center',
2323
verticalalignment='center',
2424
transform=ax.transAxes,

examples/pylab_examples/text_handles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def f(t):
2525
xtext = plt.xlabel('time (s)')
2626

2727
plt.setp(ttext, size='large', color='r', style='italic')
28-
plt.setp(xtext, size='medium', name=['Courier', 'Bitstream Vera Sans Mono'],
28+
plt.setp(xtext, size='medium', name=['Courier', 'DejaVu Sans Mono'],
2929
weight='bold', color='g')
30-
plt.setp(ytext, size='medium', name=['Helvetica', 'Bitstream Vera Sans'],
30+
plt.setp(ytext, size='medium', name=['Helvetica', 'DejaVu Sans'],
3131
weight='light', color='b')
3232
plt.show()

lib/matplotlib/font_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ def __init__(self, size=None, weight='normal'):
10481048

10491049
self.ttffiles = findSystemFonts(paths) + findSystemFonts()
10501050
self.defaultFamily = {
1051-
'ttf': 'Bitstream Vera Sans',
1051+
'ttf': 'DejaVu Sans',
10521052
'afm': 'Helvetica'}
10531053
self.defaultFont = {}
10541054

@@ -1231,7 +1231,7 @@ def findfont(self, prop, fontext='ttf', directory=None,
12311231
font is given a similarity score to the target font
12321232
properties. The first font with the highest score is
12331233
returned. If no matches below a certain threshold are found,
1234-
the default font (usually Vera Sans) is returned.
1234+
the default font (usually DejaVu Sans) is returned.
12351235
12361236
`directory`, is specified, will only return fonts from the
12371237
given directory (or subdirectory of that directory).
@@ -1240,7 +1240,7 @@ def findfont(self, prop, fontext='ttf', directory=None,
12401240
perform the O(n) nearest neighbor search.
12411241
12421242
If `fallback_to_default` is True, will fallback to the default
1243-
font family (usually "Bitstream Vera Sans" or "Helvetica") if
1243+
font family (usually "DejaVu Sans" or "Helvetica") if
12441244
the first lookup hard-fails.
12451245
12461246
See the `W3C Cascading Style Sheet, Level 1

0 commit comments

Comments
 (0)