Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 70e674e

Browse filesBrowse files
authored
Merge pull request #25359 from devRD/combotex
Add bfit bolditalic tex cmd
2 parents f95aaa5 + 08aabca commit 70e674e
Copy full SHA for 70e674e

32 files changed

+38
-7
lines changed
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Bold-italic mathtext command ``\mathbfit``
2+
-----------------------------------------------------
3+
4+
Supports use of bold-italic font style in mathtext using the ``\mathbfit{}`` command:
5+
6+
To change font to bold and italic enclose the text in a font command as
7+
shown:
8+
9+
.. code-block::
10+
11+
r'$\mathbfit{\eta \leq C(\delta(\eta))}$
12+
13+
.. math::
14+
\mathbfit{\eta \leq C(\delta(\eta))}

‎galleries/users_explain/text/mathtext.py

Copy file name to clipboardExpand all lines: galleries/users_explain/text/mathtext.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@
225225
``\mathfrak{Fraktur}`` :math-stix:`\mathfrak{Fraktur}`
226226
``\mathsf{sansserif}`` :math-stix:`\mathsf{sansserif}`
227227
``\mathrm{\mathsf{sansserif}}`` :math-stix:`\mathrm{\mathsf{sansserif}}`
228+
``\mathbfit{bolditalic}`` :math-stix:`\mathbfit{bolditalic}`
228229
================================ =========================================
229230
230231
There are also five global "font sets" to choose from, which are
@@ -290,7 +291,8 @@
290291
``mathtext.it`` ``\mathit{}`` or default italic
291292
``mathtext.rm`` ``\mathrm{}`` Roman (upright)
292293
``mathtext.tt`` ``\mathtt{}`` Typewriter (monospace)
293-
``mathtext.bf`` ``\mathbf{}`` bold italic
294+
``mathtext.bf`` ``\mathbf{}`` bold
295+
``mathtext.bfit`` ``\mathbfit{}`` bold italic
294296
``mathtext.cal`` ``\mathcal{}`` calligraphic
295297
``mathtext.sf`` ``\mathsf{}`` sans-serif
296298
============================== =================================

‎lib/matplotlib/_mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_mathtext.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def __init__(self, *args, **kwargs):
484484

485485
super().__init__(*args, **kwargs)
486486
self.fontmap = {}
487-
for texfont in "cal rm tt it bf sf".split():
487+
for texfont in "cal rm tt it bf sf bfit".split():
488488
prop = mpl.rcParams['mathtext.' + texfont]
489489
font = findfont(prop)
490490
self.fontmap[texfont] = font
@@ -631,6 +631,7 @@ class DejaVuSerifFonts(DejaVuFonts):
631631
'rm': 'DejaVu Serif',
632632
'it': 'DejaVu Serif:italic',
633633
'bf': 'DejaVu Serif:weight=bold',
634+
'bfit': 'DejaVu Serif:italic:bold',
634635
'sf': 'DejaVu Sans',
635636
'tt': 'DejaVu Sans Mono',
636637
'ex': 'DejaVu Serif Display',
@@ -648,6 +649,7 @@ class DejaVuSansFonts(DejaVuFonts):
648649
'rm': 'DejaVu Sans',
649650
'it': 'DejaVu Sans:italic',
650651
'bf': 'DejaVu Sans:weight=bold',
652+
'bfit': 'DejaVu Sans:italic:bold',
651653
'sf': 'DejaVu Sans',
652654
'tt': 'DejaVu Sans Mono',
653655
'ex': 'DejaVu Sans Display',
@@ -671,6 +673,7 @@ class StixFonts(UnicodeFonts):
671673
'rm': 'STIXGeneral',
672674
'it': 'STIXGeneral:italic',
673675
'bf': 'STIXGeneral:weight=bold',
676+
'bfit': 'STIXGeneral:italic:bold',
674677
'nonunirm': 'STIXNonUnicode',
675678
'nonuniit': 'STIXNonUnicode:italic',
676679
'nonunibf': 'STIXNonUnicode:weight=bold',
@@ -736,7 +739,7 @@ def _map_virtual_font(self, fontname, font_class, uniindex):
736739
uniindex = stix_glyph_fixes.get(uniindex, uniindex)
737740

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

742745
return fontname, uniindex
@@ -1665,7 +1668,7 @@ def font(self):
16651668

16661669
@font.setter
16671670
def font(self, name):
1668-
if name in ('rm', 'it', 'bf'):
1671+
if name in ('rm', 'it', 'bf', 'bfit'):
16691672
self.font_class = name
16701673
self._font = name
16711674

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

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

1774-
_fontnames = set("rm cal it tt sf bf default bb frak scr regular".split())
1777+
_fontnames = set("rm cal it tt sf bf bfit "
1778+
"default bb frak scr regular".split())
17751779

17761780
_function_names = set("""
17771781
arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim

‎lib/matplotlib/_mathtext_data.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_mathtext_data.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,13 @@
12101210
(0x2202, 0x2202, 'bf', 0x1d789), # partial differential
12111211
(0x2207, 0x2207, 'bf', 0x1d76f), # \Nabla
12121212
],
1213+
'bfit':
1214+
[
1215+
(0x0041, 0x005a, 'bfit', 0x1d468), # A-Z
1216+
(0x0061, 0x007a, 'bfit', 0x1d482), # a-z
1217+
(0x0393, 0x03a9, 'bfit', 0x1d71e), # \Gamma-\Omega
1218+
(0x03b1, 0x03c9, 'bfit', 0x1d736), # \alpha-\omega
1219+
],
12131220
},
12141221
'tt':
12151222
[

‎lib/matplotlib/mpl-data/matplotlibrc

Copy file name to clipboardExpand all lines: lib/matplotlib/mpl-data/matplotlibrc
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@
340340
## settings which map a TeX font name to a fontconfig font pattern. (These
341341
## settings are not used for other font sets.)
342342
#mathtext.bf: sans:bold
343+
#mathtext.bfit: sans:italic:bold
343344
#mathtext.cal: cursive
344345
#mathtext.it: sans:italic
345346
#mathtext.rm: sans

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,10 +937,11 @@ def _convert_validator_spec(key, conv):
937937
"mathtext.tt": validate_font_properties,
938938
"mathtext.it": validate_font_properties,
939939
"mathtext.bf": validate_font_properties,
940+
"mathtext.bfit": validate_font_properties,
940941
"mathtext.sf": validate_font_properties,
941942
"mathtext.fontset": ["dejavusans", "dejavuserif", "cm", "stix",
942943
"stixsans", "custom"],
943-
"mathtext.default": ["rm", "cal", "it", "tt", "sf", "bf", "default",
944+
"mathtext.default": ["rm", "cal", "bfit", "it", "tt", "sf", "bf", "default",
944945
"bb", "frak", "scr", "regular"],
945946
"mathtext.fallback": _validate_mathtext_fallback,
946947

Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

‎lib/matplotlib/tests/test_mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_mathtext.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@
172172
(['mathscr'], [uppercase, lowercase]),
173173
(['mathsf'], [digits, uppercase, lowercase]),
174174
(['mathrm', 'mathsf'], [digits, uppercase, lowercase]),
175-
(['mathbf', 'mathsf'], [digits, uppercase, lowercase])
175+
(['mathbf', 'mathsf'], [digits, uppercase, lowercase]),
176+
(['mathbfit'], all),
176177
]
177178

178179
font_tests: list[None | str] = []
@@ -426,6 +427,7 @@ def test_mathtext_fallback(fallback, fontlist):
426427
mpl.rcParams['mathtext.rm'] = 'mpltest'
427428
mpl.rcParams['mathtext.it'] = 'mpltest:italic'
428429
mpl.rcParams['mathtext.bf'] = 'mpltest:bold'
430+
mpl.rcParams['mathtext.bfit'] = 'mpltest:italic:bold'
429431
mpl.rcParams['mathtext.fallback'] = fallback
430432

431433
test_str = r'a$A\AA\breve\gimel$'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.