Skip to content

Use DejaVu fonts as default for text and mathtext #5214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 7 additions & 8 deletions doc/users/mathtext.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ in Donald Knuth's TeX, so the quality is quite good (matplotlib also
provides a ``usetex`` option for those who do want to call out to TeX
to generate their text (see :ref:`usetex-tutorial`).

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

.. note::
Expand Down
11 changes: 0 additions & 11 deletions doc/users/plotting/colormaps/Lfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@


mpl.rcParams.update({'font.size': 12})
mpl.rcParams['font.sans-serif'] = ('Arev Sans, Bitstream Vera Sans, '
'Lucida Grande, Verdana, Geneva, Lucid, '
'Helvetica, Avant Garde, sans-serif')
mpl.rcParams['mathtext.fontset'] = 'custom'
mpl.rcParams['mathtext.cal'] = 'cursive'
mpl.rcParams['mathtext.rm'] = 'sans'
mpl.rcParams['mathtext.tt'] = 'monospace'
mpl.rcParams['mathtext.it'] = 'sans:italic'
mpl.rcParams['mathtext.bf'] = 'sans:bold'
mpl.rcParams['mathtext.sf'] = 'sans'
mpl.rcParams['mathtext.fallback_to_cm'] = 'True'


### Red, original Albers plot
Expand Down
11 changes: 0 additions & 11 deletions doc/users/plotting/colormaps/grayscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@
import matplotlib as mpl

mpl.rcParams.update({'font.size': 14})
mpl.rcParams['font.sans-serif'] = ('Arev Sans, Bitstream Vera Sans, '
'Lucida Grande, Verdana, Geneva, Lucid, '
'Helvetica, Avant Garde, sans-serif')
mpl.rcParams['mathtext.fontset'] = 'custom'
mpl.rcParams['mathtext.cal'] = 'cursive'
mpl.rcParams['mathtext.rm'] = 'sans'
mpl.rcParams['mathtext.tt'] = 'monospace'
mpl.rcParams['mathtext.it'] = 'sans:italic'
mpl.rcParams['mathtext.bf'] = 'sans:bold'
mpl.rcParams['mathtext.sf'] = 'sans'
mpl.rcParams['mathtext.fallback_to_cm'] = 'True'


# indices to step through colormap
Expand Down
11 changes: 0 additions & 11 deletions doc/users/plotting/colormaps/lightness.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@
import matplotlib as mpl

mpl.rcParams.update({'font.size': 12})
mpl.rcParams['font.sans-serif'] = ('Arev Sans, Bitstream Vera Sans, '
'Lucida Grande, Verdana, Geneva, Lucid, '
'Helvetica, Avant Garde, sans-serif')
mpl.rcParams['mathtext.fontset'] = 'custom'
mpl.rcParams['mathtext.cal'] = 'cursive'
mpl.rcParams['mathtext.rm'] = 'sans'
mpl.rcParams['mathtext.tt'] = 'monospace'
mpl.rcParams['mathtext.it'] = 'sans:italic'
mpl.rcParams['mathtext.bf'] = 'sans:bold'
mpl.rcParams['mathtext.sf'] = 'sans'
mpl.rcParams['mathtext.fallback_to_cm'] = 'True'

# indices to step through colormap
x = np.linspace(0.0, 1.0, 100)
Expand Down
4 changes: 2 additions & 2 deletions doc/users/screenshots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ Mathtext_examples
Below is a sampling of the many TeX expressions now supported by matplotlib's
internal mathtext engine. The mathtext module provides TeX style mathematical
expressions using `FreeType <http://www.freetype.org/>`_
and the BaKoMa computer modern or `STIX <http://www.stixfonts.org>`_ fonts.
See the :mod:`matplotlib.mathtext` module for additional details.
and the DejaVu, BaKoMa computer modern, or `STIX <http://www.stixfonts.org>`_
fonts. See the :mod:`matplotlib.mathtext` module for additional details.

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

Expand Down
14 changes: 14 additions & 0 deletions doc/users/whats_new/new_default_font.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Change in default font
----------------------

The default font used by matplotlib in text has been changed to DejaVu Sans and
DejaVu Serif for the sans-serif and serif families, respectively. The DejaVu
font family is based on the previous matplotlib default --Bitstream Vera-- but
includes a much wider range of characters.

The default mathtext font has been changed from Computer Modern to the DejaVu
family to maintain consistency with regular text. Two new options for the
``mathtext.fontset`` configuration parameter have been added: ``dejavusans``
(default) and ``dejavuserif``. Both of these options use DejaVu glyphs whenever
possible and fall back to STIX symbols when a glyph is not found in DejaVu. To
return to the previous behavior, set the rcParam ``mathtext.fontset`` to ``cm``.
2 changes: 1 addition & 1 deletion examples/api/font_family_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
and for the font.family you set a list of font styles to try to find
in order::

rcParams['font.sans-serif'] = ['Tahoma', 'Bitstream Vera Sans',
rcParams['font.sans-serif'] = ['Tahoma', 'DejaVu Sans',
'Lucida Grande', 'Verdana']

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/misc/font_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


#fname = '/usr/share/fonts/sfd/FreeSans.ttf'
fname = matplotlib.get_data_path() + '/fonts/ttf/Vera.ttf'
fname = matplotlib.get_data_path() + '/fonts/ttf/DejaVuSans.ttf'
font = FT2Font(fname)
font.set_charmap(0)

Expand Down
2 changes: 1 addition & 1 deletion examples/misc/ftface_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


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

font = ft.FT2Font(fname)
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/font_table_ttf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
fontname = sys.argv[1]
else:
fontname = os.path.join(matplotlib.get_data_path(),
'fonts', 'ttf', 'Vera.ttf')
'fonts', 'ttf', 'DejaVuSans.ttf')

font = FT2Font(fontname)
codes = list(font.get_charmap().items())
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ax = plt.subplot(111, axisbg='y')
plt.plot(t, x)
plt.text(0.5, 0.5, 'matplotlib', color='r',
fontsize=40, fontname=['Courier', 'Bitstream Vera Sans Mono'],
fontsize=40, fontname=['Courier', 'DejaVu Sans Mono'],
horizontalalignment='center',
verticalalignment='center',
transform=ax.transAxes,
Expand Down
4 changes: 2 additions & 2 deletions examples/pylab_examples/text_handles.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def f(t):
xtext = plt.xlabel('time (s)')

plt.setp(ttext, size='large', color='r', style='italic')
plt.setp(xtext, size='medium', name=['Courier', 'Bitstream Vera Sans Mono'],
plt.setp(xtext, size='medium', name=['Courier', 'DejaVu Sans Mono'],
weight='bold', color='g')
plt.setp(ytext, size='medium', name=['Helvetica', 'Bitstream Vera Sans'],
plt.setp(ytext, size='medium', name=['Helvetica', 'DejaVu Sans'],
weight='light', color='b')
plt.show()
6 changes: 3 additions & 3 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ def __init__(self, size=None, weight='normal'):

self.ttffiles = findSystemFonts(paths) + findSystemFonts()
self.defaultFamily = {
'ttf': 'Bitstream Vera Sans',
'ttf': 'DejaVu Sans',
'afm': 'Helvetica'}
self.defaultFont = {}

Expand Down Expand Up @@ -1251,7 +1251,7 @@ def findfont(self, prop, fontext='ttf', directory=None,
font is given a similarity score to the target font
properties. The first font with the highest score is
returned. If no matches below a certain threshold are found,
the default font (usually Vera Sans) is returned.
the default font (usually DejaVu Sans) is returned.

`directory`, is specified, will only return fonts from the
given directory (or subdirectory of that directory).
Expand All @@ -1260,7 +1260,7 @@ def findfont(self, prop, fontext='ttf', directory=None,
perform the O(n) nearest neighbor search.

If `fallback_to_default` is True, will fallback to the default
font family (usually "Bitstream Vera Sans" or "Helvetica") if
font family (usually "DejaVu Sans" or "Helvetica") if
the first lookup hard-fails.

See the `W3C Cascading Style Sheet, Level 1
Expand Down
Loading