@@ -306,6 +306,12 @@ def render_rect_filled(self, output: Output,
306306 """
307307 output .rects .append ((x , y , w , h ))
308308
309+ def get_axis_height (self , font : str , fontsize : float , dpi : float ) -> float :
310+ """
311+ Get the axis height for the given *font* and *fontsize*.
312+ """
313+ raise NotImplementedError ()
314+
309315 def get_xheight (self , font : str , fontsize : float , dpi : float ) -> float :
310316 """
311317 Get the xheight for the given *font* and *fontsize*.
@@ -407,6 +413,13 @@ def _get_info(self, fontname: str, font_class: str, sym: str, fontsize: float,
407413 offset = offset
408414 )
409415
416+ def get_axis_height (self , fontname : str , fontsize : float , dpi : float ) -> float :
417+ # The fraction line (if present) must be aligned with the minus sign. Therefore,
418+ # the height of the latter from the baseline is the axis height.
419+ metrics = self .get_metrics (
420+ fontname , mpl .rcParams ['mathtext.default' ], '\u2212 ' , fontsize , dpi )
421+ return (metrics .ymax + metrics .ymin ) / 2
422+
410423 def get_xheight (self , fontname : str , fontsize : float , dpi : float ) -> float :
411424 # Some fonts report the wrong x-height, while some don't store it, so
412425 # we do a poor man's x-height.
@@ -2659,12 +2672,8 @@ def _genfrac(self, ldelim: str, rdelim: str, rule: float | None, style: _MathSty
26592672 state = self .get_state ()
26602673 thickness = state .get_current_underline_thickness ()
26612674
2662- # The fraction line (if present) must be aligned with the minus sign. Therefore,
2663- # the height of the latter from the baseline is the axis height.
2664- metrics = state .fontset .get_metrics (
2665- state .font , mpl .rcParams ['mathtext.default' ],
2666- '\u2212 ' , state .fontsize , state .dpi )
2667- axis_height = (metrics .ymax + metrics .ymin ) / 2
2675+ axis_height = state .fontset .get_axis_height (
2676+ state .font , state .fontsize , state .dpi )
26682677 consts = _get_font_constant_set (state )
26692678 x_height = state .fontset .get_xheight (state .font , state .fontsize , state .dpi )
26702679
0 commit comments