@@ -403,7 +403,7 @@ def get_kern(self, font1, fontclass1, sym1, fontsize1,
403403
404404 *fontX*: one of the TeX font names::
405405
406- tt, it, rm, cal, sf, bf or default (non-math)
406+ tt, it, rm, cal, sf, bf or default/regular (non-math)
407407
408408 *fontclassX*: TODO
409409
@@ -419,7 +419,7 @@ def get_metrics(self, font, font_class, sym, fontsize, dpi):
419419 """
420420 *font*: one of the TeX font names::
421421
422- tt, it, rm, cal, sf, bf or default (non-math)
422+ tt, it, rm, cal, sf, bf or default/regular (non-math)
423423
424424 *font_class*: TODO
425425
@@ -543,6 +543,7 @@ def __init__(self, default_font_prop, mathtext_backend):
543543 filename = findfont (default_font_prop )
544544 default_font = self .CachedFont (FT2Font (str (filename )))
545545 self ._fonts ['default' ] = default_font
546+ self ._fonts ['regular' ] = default_font
546547
547548 def destroy (self ):
548549 self .glyphd = None
@@ -616,7 +617,7 @@ def get_xheight(self, font, fontsize, dpi):
616617 pclt = cached_font .font .get_sfnt_table ('pclt' )
617618 if pclt is None :
618619 # Some fonts don't store the xHeight, so we do a poor man's xHeight
619- metrics = self .get_metrics (font , 'it' , 'x' , fontsize , dpi )
620+ metrics = self .get_metrics (font , rcParams [ 'mathtext.default' ] , 'x' , fontsize , dpi )
620621 return metrics .iceberg
621622 xHeight = (pclt ['xHeight' ] / 64.0 ) * (fontsize / 12.0 ) * (dpi / 100.0 )
622623 return xHeight
@@ -936,7 +937,7 @@ def _map_virtual_font(self, fontname, font_class, uniindex):
936937 elif not doing_sans_conversion :
937938 # This will generate a dummy character
938939 uniindex = 0x1
939- fontname = 'it'
940+ fontname = rcParams [ 'mathtext.default' ]
940941
941942 # Handle private use area glyphs
942943 if (fontname in ('it' , 'rm' , 'bf' ) and
@@ -1007,6 +1008,7 @@ def __init__(self, default_font_prop):
10071008 default_font .fname = filename
10081009
10091010 self .fonts ['default' ] = default_font
1011+ self .fonts ['regular' ] = default_font
10101012 self .pswriter = StringIO ()
10111013
10121014 def _get_font (self , font ):
@@ -2064,7 +2066,7 @@ class Parser(object):
20642066
20652067 _dropsub_symbols = set (r'''\int \oint''' .split ())
20662068
2067- _fontnames = set ("rm cal it tt sf bf default bb frak circled scr" .split ())
2069+ _fontnames = set ("rm cal it tt sf bf default bb frak circled scr regular " .split ())
20682070
20692071 _function_names = set ("""
20702072 arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim
@@ -2294,7 +2296,7 @@ def copy(self):
22942296 def _get_font (self ):
22952297 return self ._font
22962298 def _set_font (self , name ):
2297- if name in ( 'it' , 'rm' , 'bf' ) :
2299+ if name in Parser . _fontnames :
22982300 self .font_class = name
22992301 self ._font = name
23002302 font = property (_get_font , _set_font )
@@ -2336,7 +2338,7 @@ def non_math(self, s, loc, toks):
23362338 hlist = Hlist (symbols )
23372339 # We're going into math now, so set font to 'it'
23382340 self .push_state ()
2339- self .get_state ().font = 'it'
2341+ self .get_state ().font = rcParams [ 'mathtext.default' ]
23402342 return [hlist ]
23412343
23422344 def _make_space (self , percentage ):
@@ -2346,7 +2348,7 @@ def _make_space(self, percentage):
23462348 width = self ._em_width_cache .get (key )
23472349 if width is None :
23482350 metrics = state .font_output .get_metrics (
2349- state .font , 'it' , 'm' , state .fontsize , state .dpi )
2351+ state .font , rcParams [ 'mathtext.default' ] , 'm' , state .fontsize , state .dpi )
23502352 width = metrics .advance
23512353 self ._em_width_cache [key ] = width
23522354 return Kern (width * percentage )
@@ -2665,7 +2667,7 @@ def frac(self, s, loc, toks):
26652667 # Shift so the fraction line sits in the middle of the
26662668 # equals sign
26672669 metrics = state .font_output .get_metrics (
2668- state .font , 'it' , '=' , state .fontsize , state .dpi )
2670+ state .font , rcParams [ 'mathtext.default' ] , '=' , state .fontsize , state .dpi )
26692671 shift = (cden .height -
26702672 ((metrics .ymax + metrics .ymin ) / 2 -
26712673 thickness * 3.0 ))
0 commit comments