Skip to content

Commit 0e7bf54

Browse files
committed
Always use the actual x-height instead of what the font tells us. [skip ci]
1 parent 775d643 commit 0e7bf54

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,10 @@ def _get_info(self, fontname, font_class, sym, fontsize, dpi):
254254
return result
255255

256256
def get_xheight(self, fontname, fontsize, dpi):
257-
font = self._get_font(fontname)
258-
font.set_size(fontsize, dpi)
259-
pclt = font.get_sfnt_table('pclt')
260-
if pclt is None:
261-
# Some fonts don't store the xHeight, so we do a poor man's xHeight
262-
metrics = self.get_metrics(
263-
fontname, mpl.rcParams['mathtext.default'], 'x', fontsize, dpi)
264-
return metrics.iceberg
265-
xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0) * (dpi / 100.0)
266-
return xHeight
257+
# Some fonts report the wrong x-height, so we do a poor man's x-height.
258+
metrics = self.get_metrics(
259+
fontname, mpl.rcParams['mathtext.default'], 'x', fontsize, dpi)
260+
return metrics.iceberg
267261

268262
def get_underline_thickness(self, font, fontsize, dpi):
269263
# This function used to grab underline thickness from the font

0 commit comments

Comments
 (0)