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

Skip to content

Commit 1e7da72

Browse files
committed
Add bfit bolditalic tex command
1 parent c948e90 commit 1e7da72

32 files changed

+38
-7
lines changed
Lines 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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@
220220
``\mathfrak{Fraktur}`` :math-stix:`\mathfrak{Fraktur}`
221221
``\mathsf{sansserif}`` :math-stix:`\mathsf{sansserif}`
222222
``\mathrm{\mathsf{sansserif}}`` :math-stix:`\mathrm{\mathsf{sansserif}}`
223+
``\mathbfit{bolditalic}`` :math-stix:`\mathbfit{bolditalic}`
223224
================================ =========================================
224225
225226
There are also five global "font sets" to choose from, which are
@@ -281,7 +282,8 @@
281282
``mathtext.it`` ``\mathit{}`` or default italic
282283
``mathtext.rm`` ``\mathrm{}`` Roman (upright)
283284
``mathtext.tt`` ``\mathtt{}`` Typewriter (monospace)
284-
``mathtext.bf`` ``\mathbf{}`` bold italic
285+
``mathtext.bf`` ``\mathbf{}`` bold
286+
``mathtext.bfit`` ``\mathbfit{}`` bold italic
285287
``mathtext.cal`` ``\mathcal{}`` calligraphic
286288
``mathtext.sf`` ``\mathsf{}`` sans-serif
287289
============================== =================================

lib/matplotlib/_mathtext.py

Lines 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

Lines 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

Lines 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

Lines 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

lib/matplotlib/tests/test_mathtext.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@
167167
(['mathscr'], [uppercase, lowercase]),
168168
(['mathsf'], [digits, uppercase, lowercase]),
169169
(['mathrm', 'mathsf'], [digits, uppercase, lowercase]),
170-
(['mathbf', 'mathsf'], [digits, uppercase, lowercase])
170+
(['mathbf', 'mathsf'], [digits, uppercase, lowercase]),
171+
(['mathbfit'], all)
171172
]
172173

173174
font_tests = []
@@ -421,6 +422,7 @@ def test_mathtext_fallback(fallback, fontlist):
421422
mpl.rcParams['mathtext.rm'] = 'mpltest'
422423
mpl.rcParams['mathtext.it'] = 'mpltest:italic'
423424
mpl.rcParams['mathtext.bf'] = 'mpltest:bold'
425+
mpl.rcParams['mathtext.bfit'] = 'mpltest:italic:bold'
424426
mpl.rcParams['mathtext.fallback'] = fallback
425427

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

0 commit comments

Comments
 (0)