@@ -1500,8 +1500,7 @@ class Hrule(Rule):
1500
1500
1501
1501
def __init__ (self , state , thickness = None ):
1502
1502
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 ()
1505
1504
height = depth = thickness * 0.5
1506
1505
super ().__init__ (np .inf , height , depth , state )
1507
1506
@@ -1510,8 +1509,7 @@ class Vrule(Rule):
1510
1509
"""Convenience class to create a vertical rule."""
1511
1510
1512
1511
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 ()
1515
1513
super ().__init__ (thickness , np .inf , np .inf , state )
1516
1514
1517
1515
@@ -2255,6 +2253,11 @@ def font(self, name):
2255
2253
self .font_class = name
2256
2254
self ._font = name
2257
2255
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
+
2258
2261
def get_state (self ):
2259
2262
"""Get the current `State` of the parser."""
2260
2263
return self ._state_stack [- 1 ]
@@ -2401,8 +2404,7 @@ def unknown_symbol(self, s, loc, toks):
2401
2404
2402
2405
def accent (self , s , loc , toks ):
2403
2406
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 ()
2406
2408
(accent , sym ), = toks
2407
2409
if accent in self ._wide_accents :
2408
2410
accent_box = AutoWidthChar (
@@ -2687,8 +2689,7 @@ def subsuper(self, s, loc, toks):
2687
2689
2688
2690
def _genfrac (self , ldelim , rdelim , rule , style , num , den ):
2689
2691
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 ()
2692
2693
2693
2694
rule = float (rule )
2694
2695
@@ -2731,17 +2732,13 @@ def genfrac(self, s, loc, toks):
2731
2732
return self ._genfrac (* args )
2732
2733
2733
2734
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 ()
2737
2736
(num , den ), = toks
2738
2737
return self ._genfrac ('' , '' , thickness , self ._MathStyle .TEXTSTYLE ,
2739
2738
num , den )
2740
2739
2741
2740
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 ()
2745
2742
(num , den ), = toks
2746
2743
return self ._genfrac ('' , '' , thickness , self ._MathStyle .DISPLAYSTYLE ,
2747
2744
num , den )
@@ -2753,9 +2750,7 @@ def binom(self, s, loc, toks):
2753
2750
2754
2751
def _genset (self , s , loc , toks ):
2755
2752
(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 ()
2759
2754
2760
2755
annotation .shrink ()
2761
2756
cannotation = HCentered ([annotation ])
@@ -2787,8 +2782,7 @@ def _genset(self, s, loc, toks):
2787
2782
def sqrt (self , s , loc , toks ):
2788
2783
(root , body ), = toks
2789
2784
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 ()
2792
2786
2793
2787
# Determine the height of the body, and add a little extra to
2794
2788
# the height so it doesn't seem cramped
@@ -2828,8 +2822,7 @@ def overline(self, s, loc, toks):
2828
2822
(body ,), = toks
2829
2823
2830
2824
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 ()
2833
2826
2834
2827
height = body .height - body .shift_amount + thickness * 3.0
2835
2828
depth = body .depth + body .shift_amount
0 commit comments