8000 Merge pull request #5871 from zblz/fix-sized-delims · matplotlib/matplotlib@944546c · GitHub
[go: up one dir, main page]

Skip to content

Commit 944546c

Browse files
mdboomQuLogic
authored andcommitted
Merge pull request #5871 from zblz/fix-sized-delims
Fix sized delimiters for regular-sized mathtext (#5863)
1 parent e2fd2aa commit 944546c

File tree

130 files changed

+4080
-4096
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+4080
-4096
lines changed

lib/matplotlib/mathtext.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,6 @@ def __init__(self, *args, **kwargs):
896896
self.fontmap = {}
897897
# Include Stix sized alternatives for glyphs
898898
self._fontmap.update({
899-
0 : 'STIXGeneral',
900899
1 : 'STIXSizeOneSym',
901900
2 : 'STIXSizeTwoSym',
902901
3 : 'STIXSizeThreeSym',
@@ -938,6 +937,7 @@ class DejaVuSerifFonts(DejaVuFonts):
938937
'sf' : 'DejaVu Sans',
939938
'tt' : 'DejaVu Sans Mono',
940939
'ex' : 'DejaVu Serif Display',
940+
0 : 'DejaVu Serif',
941941
}
942942

943943
class DejaVuSansFonts(DejaVuFonts):
@@ -952,6 +952,7 @@ class DejaVuSansFonts(DejaVuFonts):
952952
'sf' : 'DejaVu Sans',
953953
'tt' : 'DejaVu Sans Mono',
954954
'ex' : 'DejaVu Sans Display',
955+
0 : 'DejaVu Sans',
955956
}
956957

957958
class StixFonts(UnicodeFonts):
@@ -2003,20 +2004,28 @@ def __init__(self, c, height, depth, state, always=False, factor=None):
20032004
alternatives = state.font_output.get_sized_alternatives_for_symbol(
20042005
state.font, c)
20052006

2007+
xHeight = state.font_output.get_xheight(
2008+
state.font, state.fontsize, state.dpi)
2009+
20062010
state = state.copy()
20072011
target_total = height + depth
20082012
for fontname, sym in alternatives:
20092013
state.font = fontname
20102014
char = Char(sym, state)
2011-
if char.height + char.depth >= target_total:
2015+
# Ensure that size 0 is chosen when the text is regular sized but
2016+
# with descender glyphs by subtracting 0.2 * xHeight
2017+
if char.height + char.depth >= target_total - 0.2 * xHeight:
20122018
break
20132019

2014-
if factor is None:
2015-
factor = target_total / (char.height + char.depth)
2016-
state.fontsize *= factor
2017-
char = Char(sym, state)
2020+
shift = 0
2021+
if state.font != 0:
2022+
if factor is None:
2023+
factor = (target_total) / (char.height + char.depth)
2024+
state.fontsize *= factor
2025+
char = Char(sym, state)
2026+
2027+
shift = (depth - char.depth)
20182028

2019-
shift = (depth - char.depth)
20202029
Hlist.__init__(self, [char])
20212030
self.shift_amount = shift
20222031

Binary file not shown.
Loading

0 commit comments

Comments
 (0)
0