Skip to content

Fix sized delimiters for regular-sized mathtext (#5863) #5871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions lib/matplotlib/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,6 @@ def __init__(self, *args, **kwargs):
self.fontmap = {}
# Include Stix sized alternatives for glyphs
self._fontmap.update({
0 : 'STIXGeneral',
1 : 'STIXSizeOneSym',
2 : 'STIXSizeTwoSym',
3 : 'STIXSizeThreeSym',
Expand Down Expand Up @@ -932,6 +931,7 @@ class DejaVuSerifFonts(DejaVuFonts):
'sf' : 'DejaVu Sans',
'tt' : 'DejaVu Sans Mono',
'ex' : 'DejaVu Serif Display',
0 : 'DejaVu Serif',
}

class DejaVuSansFonts(DejaVuFonts):
Expand All @@ -946,6 +946,7 @@ class DejaVuSansFonts(DejaVuFonts):
'sf' : 'DejaVu Sans',
'tt' : 'DejaVu Sans Mono',
'ex' : 'DejaVu Sans Display',
0 : 'DejaVu Sans',
}

class StixFonts(UnicodeFonts):
Expand Down Expand Up @@ -1996,20 +1997,28 @@ def __init__(self, c, height, depth, state, always=False, factor=None):
alternatives = state.font_output.get_sized_alternatives_for_symbol(
state.font, c)

xHeight = state.font_output.get_xheight(
state.font, state.fontsize, state.dpi)

state = state.copy()
target_total = height + depth
for fontname, sym in alternatives:
state.font = fontname
char = Char(sym, state)
if char.height + char.depth >= target_total:
# Ensure that size 0 is chosen when the text is regular sized but
# with descender glyphs by subtracting 0.2 * xHeight
if char.height + char.depth >= target_total - 0.2 * xHeight:
break

if factor is None:
factor = target_total / (char.height + char.depth)
state.fontsize *= factor
char = Char(sym, state)
shift = 0
if state.font != 0:
if factor is None:
factor = (target_total) / (char.height + char.depth)
state.fontsize *= factor
char = Char(sym, state)

shift = (depth - char.depth)

shift = (depth - char.depth)
Hlist.__init__(self, [char])
self.shift_amount = shift

Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading