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

Skip to content

Add bfit bolditalic tex cmd #25359

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 1 commit into from
Apr 21, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/users/next_whats_new/updated_mathtext.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Bold-italic mathtext command ``\mathbfit``
-----------------------------------------------------

Supports use of bold-italic font style in mathtext using the ``\mathbfit{}`` command:

To change font to bold and italic enclose the text in a font command as
shown:

.. code-block::

r'$\mathbfit{\eta \leq C(\delta(\eta))}$

.. math::
\mathbfit{\eta \leq C(\delta(\eta))}
4 changes: 3 additions & 1 deletion galleries/users_explain/text/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
``\mathfrak{Fraktur}`` :math-stix:`\mathfrak{Fraktur}`
``\mathsf{sansserif}`` :math-stix:`\mathsf{sansserif}`
``\mathrm{\mathsf{sansserif}}`` :math-stix:`\mathrm{\mathsf{sansserif}}`
``\mathbfit{bolditalic}`` :math-stix:`\mathbfit{bolditalic}`
================================ =========================================

There are also five global "font sets" to choose from, which are
Expand Down Expand Up @@ -290,7 +291,8 @@
``mathtext.it`` ``\mathit{}`` or default italic
``mathtext.rm`` ``\mathrm{}`` Roman (upright)
``mathtext.tt`` ``\mathtt{}`` Typewriter (monospace)
``mathtext.bf`` ``\mathbf{}`` bold italic
``mathtext.bf`` ``\mathbf{}`` bold
``mathtext.bfit`` ``\mathbfit{}`` bold italic
``mathtext.cal`` ``\mathcal{}`` calligraphic
``mathtext.sf`` ``\mathsf{}`` sans-serif
============================== =================================
Expand Down
12 changes: 8 additions & 4 deletions lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def __init__(self, *args, **kwargs):

super().__init__(*args, **kwargs)
self.fontmap = {}
for texfont in "cal rm tt it bf sf".split():
for texfont in "cal rm tt it bf sf bfit".split():
prop = mpl.rcParams['mathtext.' + texfont]
font = findfont(prop)
self.fontmap[texfont] = font
Expand Down Expand Up @@ -631,6 +631,7 @@ class DejaVuSerifFonts(DejaVuFonts):
'rm': 'DejaVu Serif',
'it': 'DejaVu Serif:italic',
'bf': 'DejaVu Serif:weight=bold',
'bfit': 'DejaVu Serif:italic:bold',
'sf': 'DejaVu Sans',
'tt': 'DejaVu Sans Mono',
'ex': 'DejaVu Serif Display',
Expand All @@ -648,6 +649,7 @@ class DejaVuSansFonts(DejaVuFonts):
'rm': 'DejaVu Sans',
'it': 'DejaVu Sans:italic',
'bf': 'DejaVu Sans:weight=bold',
'bfit': 'DejaVu Sans:italic:bold',
'sf': 'DejaVu Sans',
'tt': 'DejaVu Sans Mono',
'ex': 'DejaVu Sans Display',
Expand All @@ -671,6 +673,7 @@ class StixFonts(UnicodeFonts):
'rm': 'STIXGeneral',
'it': 'STIXGeneral:italic',
'bf': 'STIXGeneral:weight=bold',
'bfit': 'STIXGeneral:italic:bold',
'nonunirm': 'STIXNonUnicode',
'nonuniit': 'STIXNonUnicode:italic',
'nonunibf': 'STIXNonUnicode:weight=bold',
Expand Down Expand Up @@ -736,7 +739,7 @@ def _map_virtual_font(self, fontname, font_class, uniindex):
uniindex = stix_glyph_fixes.get(uniindex, uniindex)

# Handle private use area glyphs
if fontname in ('it', 'rm', 'bf') and 0xe000 <= uniindex <= 0xf8ff:
if fontname in ('it', 'rm', 'bf', 'bfit') and 0xe000 <= uniindex <= 0xf8ff:
fontname = 'nonuni' + fontname

return fontname, uniindex
Expand Down Expand Up @@ -1665,7 +1668,7 @@ def font(self):

@font.setter
def font(self, name):
if name in ('rm', 'it', 'bf'):
if name in ('rm', 'it', 'bf', 'bfit'):
self.font_class = name
self._font = name

Expand Down Expand Up @@ -1771,7 +1774,8 @@ class _MathStyle(enum.Enum):

_dropsub_symbols = set(r'''\int \oint'''.split())

_fontnames = set("rm cal it tt sf bf default bb frak scr regular".split())
_fontnames = set("rm cal it tt sf bf bfit "
"default bb frak scr regular".split())

_function_names = set("""
arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim
Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/_mathtext_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,13 @@
(0x2202, 0x2202, 'bf', 0x1d789), # partial differential
(0x2207, 0x2207, 'bf', 0x1d76f), # \Nabla
],
'bfit':
[
(0x0041, 0x005a, 'bfit', 0x1d468), # A-Z
(0x0061, 0x007a, 'bfit', 0x1d482), # a-z
(0x0393, 0x03a9, 'bfit', 0x1d71e), # \Gamma-\Omega
(0x03b1, 0x03c9, 'bfit', 0x1d736), # \alpha-\omega
],
},
'tt':
[
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/mpl-data/matplotlibrc
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
## settings which map a TeX font name to a fontconfig font pattern. (These
## settings are not used for other font sets.)
#mathtext.bf: sans:bold
#mathtext.bfit: sans:italic:bold
#mathtext.cal: cursive
#mathtext.it: sans:italic
#mathtext.rm: sans
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,10 +937,11 @@ def _convert_validator_spec(key, conv):
"mathtext.tt": validate_font_properties,
"mathtext.it": validate_font_properties,
"mathtext.bf": validate_font_properties,
"mathtext.bfit": validate_font_properties,
"mathtext.sf": validate_font_properties,
"mathtext.fontset": ["dejavusans", "dejavuserif", "cm", "stix",
"stixsans", "custom"],
"mathtext.default": ["rm", "cal", "it", "tt", "sf", "bf", "default",
"mathtext.default": ["rm", "cal", "bfit", "it", "tt", "sf", "bf", "default",
"bb", "frak", "scr", "regular"],
"mathtext.fallback": _validate_mathtext_fallback,

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion lib/matplotlib/tests/test_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@
(['mathscr'], [uppercase, lowercase]),
(['mathsf'], [digits, uppercase, lowercase]),
(['mathrm', 'mathsf'], [digits, uppercase, lowercase]),
(['mathbf', 'mathsf'], [digits, uppercase, lowercase])
(['mathbf', 'mathsf'], [digits, uppercase, lowercase]),
(['mathbfit'], all),
]

font_tests: list[None | str] = []
Expand Down Expand Up @@ -426,6 +427,7 @@ def test_mathtext_fallback(fallback, fontlist):
mpl.rcParams['mathtext.rm'] = 'mpltest'
mpl.rcParams['mathtext.it'] = 'mpltest:italic'
mpl.rcParams['mathtext.bf'] = 'mpltest:bold'
mpl.rcParams['mathtext.bfit'] = 'mpltest:italic:bold'
mpl.rcParams['mathtext.fallback'] = fallback

test_str = r'a$A\AA\breve\gimel$'
Expand Down