Skip to content

Commit

Permalink
Merge pull request matplotlib#5871 from zblz/fix-sized-delims
Browse files Browse the repository at this point in the history
Fix sized delimiters for regular-sized mathtext (matplotlib#5863)
  • Loading branch information
mdboom authored and QuLogic committed Oct 16, 2016
1 parent e2fd2aa commit 944546c
Show file tree
Hide file tree
Showing 130 changed files with 4,080 additions and 4,096 deletions.
23 changes: 16 additions & 7 deletions lib/matplotlib/mathtext.py
Expand Up @@ -896,7 +896,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 @@ -938,6 +937,7 @@ class DejaVuSerifFonts(DejaVuFonts):
'sf' : 'DejaVu Sans',
'tt' : 'DejaVu Sans Mono',
'ex' : 'DejaVu Serif Display',
0 : 'DejaVu Serif',
}

class DejaVuSansFonts(DejaVuFonts):
Expand All @@ -952,6 +952,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 @@ -2003,20 +2004,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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 944546c

Please sign in to comment.