@@ -1500,8 +1500,7 @@ class Hrule(Rule):
15001500
15011501 def __init__ (self , state , thickness = None ):
15021502 if thickness is None :
1503- thickness = state .font_output .get_underline_thickness (
1504- state .font , state .fontsize , state .dpi )
1503+ thickness = state .get_current_underline_thickness ()
15051504 height = depth = thickness * 0.5
15061505 super ().__init__ (np .inf , height , depth , state )
15071506
@@ -1510,8 +1509,7 @@ class Vrule(Rule):
15101509 """Convenience class to create a vertical rule."""
15111510
15121511 def __init__ (self , state ):
1513- thickness = state .font_output .get_underline_thickness (
1514- state .font , state .fontsize , state .dpi )
1512+ thickness = state .get_current_underline_thickness ()
15151513 super ().__init__ (thickness , np .inf , np .inf , state )
15161514
15171515
@@ -2255,6 +2253,11 @@ def font(self, name):
22552253 self .font_class = name
22562254 self ._font = name
22572255
2256+ def get_current_underline_thickness (self ):
2257+ """Return the underline thickness for this state."""
2258+ return self .font_output .get_underline_thickness (
2259+ self .font , self .fontsize , self .dpi )
2260+
22582261 def get_state (self ):
22592262 """Get the current `State` of the parser."""
22602263 return self ._state_stack [- 1 ]
@@ -2401,8 +2404,7 @@ def unknown_symbol(self, s, loc, toks):
24012404
24022405 def accent (self , s , loc , toks ):
24032406 state = self .get_state ()
2404- thickness = state .font_output .get_underline_thickness (
2405- state .font , state .fontsize , state .dpi )
2407+ thickness = state .get_current_underline_thickness ()
24062408 (accent , sym ), = toks
24072409 if accent in self ._wide_accents :
24082410 accent_box = AutoWidthChar (
@@ -2687,8 +2689,7 @@ def subsuper(self, s, loc, toks):
26872689
26882690 def _genfrac (self , ldelim , rdelim , rule , style , num , den ):
26892691 state = self .get_state ()
2690- thickness = state .font_output .get_underline_thickness (
2691- state .font , state .fontsize , state .dpi )
2692+ thickness = state .get_current_underline_thickness ()
26922693
26932694 rule = float (rule )
26942695
@@ -2731,17 +2732,13 @@ def genfrac(self, s, loc, toks):
27312732 return self ._genfrac (* args )
27322733
27332734 def frac (self , s , loc , toks ):
2734- state = self .get_state ()
2735- thickness = state .font_output .get_underline_thickness (
2736- state .font , state .fontsize , state .dpi )
2735+ thickness = self .get_state ().get_current_underline_thickness ()
27372736 (num , den ), = toks
27382737 return self ._genfrac ('' , '' , thickness , self ._MathStyle .TEXTSTYLE ,
27392738 num , den )
27402739
27412740 def dfrac (self , s , loc , toks ):
2742- state = self .get_state ()
2743- thickness = state .font_output .get_underline_thickness (
2744- state .font , state .fontsize , state .dpi )
2741+ thickness = self .get_state ().get_current_underline_thickness ()
27452742 (num , den ), = toks
27462743 return self ._genfrac ('' , '' , thickness , self ._MathStyle .DISPLAYSTYLE ,
27472744 num , den )
@@ -2753,9 +2750,7 @@ def binom(self, s, loc, toks):
27532750
27542751 def _genset (self , s , loc , toks ):
27552752 (annotation , body ), = toks
2756- state = self .get_state ()
2757- thickness = state .font_output .get_underline_thickness (
2758- state .font , state .fontsize , state .dpi )
2753+ thickness = self .get_state ().get_current_underline_thickness ()
27592754
27602755 annotation .shrink ()
27612756 cannotation = HCentered ([annotation ])
@@ -2787,8 +2782,7 @@ def _genset(self, s, loc, toks):
27872782 def sqrt (self , s , loc , toks ):
27882783 (root , body ), = toks
27892784 state = self .get_state ()
2790- thickness = state .font_output .get_underline_thickness (
2791- state .font , state .fontsize , state .dpi )
2785+ thickness = state .get_current_underline_thickness ()
27922786
27932787 # Determine the height of the body, and add a little extra to
27942788 # the height so it doesn't seem cramped
@@ -2828,8 +2822,7 @@ def overline(self, s, loc, toks):
28282822 (body ,), = toks
28292823
28302824 state = self .get_state ()
2831- thickness = state .font_output .get_underline_thickness (
2832- state .font , state .fontsize , state .dpi )
2825+ thickness = state .get_current_underline_thickness ()
28332826
28342827 height = body .height - body .shift_amount + thickness * 3.0
28352828 depth = body .depth + body .shift_amount
0 commit comments