Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fix auto-sized glyphs with BaKoMa fonts#29936
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -470,60 +470,40 @@ def _get_glyph(self, fontname: str, font_class: str, | ||
else: | ||
return self._stix_fallback._get_glyph(fontname, font_class, sym) | ||
# The Bakoma fonts contain many pre-sized alternatives for the delimiters. The | ||
# Auto(Height|Width)Char classes will use these alternatives and select the best | ||
# (closest sized) glyph. | ||
_latex_sizes = ('big', 'Big', 'bigg', 'Bigg') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. minor typo two lines above, while you're at it: it's AutoHeightChar, not AutoSizedChar. | ||
_size_alternatives = { | ||
'(': [('rm', '('), *[('ex', fr'\__parenleft{s}__') for s in _latex_sizes]], | ||
')': [('rm', ')'), *[('ex', fr'\__parenright{s}__') for s in _latex_sizes]], | ||
'{': [('ex', fr'\__braceleft{s}__') for s in _latex_sizes], | ||
'}': [('ex', fr'\__braceright{s}__') for s in _latex_sizes], | ||
'[': [('rm', '['), *[('ex', fr'\__bracketleft{s}__') for s in _latex_sizes]], | ||
']': [('rm', ']'), *[('ex', fr'\__bracketright{s}__') for s in _latex_sizes]], | ||
'<': [('cal', r'\__angbracketleft__'), | ||
*[('ex', fr'\__angbracketleft{s}__') for s in _latex_sizes]], | ||
'>': [('cal', r'\__angbracketright__'), | ||
*[('ex', fr'\__angbracketright{s}__') for s in _latex_sizes]], | ||
r'\lfloor': [('ex', fr'\__floorleft{s}__') for s in _latex_sizes], | ||
r'\rfloor': [('ex', fr'\__floorright{s}__') for s in _latex_sizes], | ||
r'\lceil': [('ex', fr'\__ceilingleft{s}__') for s in _latex_sizes], | ||
r'\rceil': [('ex', fr'\__ceilingright{s}__') for s in _latex_sizes], | ||
r'\__sqrt__': [('ex', fr'\__radical{s}__') for s in _latex_sizes], | ||
r'\backslash': [('ex', fr'\__backslash{s}__') for s in _latex_sizes], | ||
r'/': [('rm', '/'), *[('ex', fr'\__slash{s}__') for s in _latex_sizes]], | ||
r'\widehat': [('rm', '\x5e'), ('ex', r'\__hatwide__'), ('ex', r'\__hatwider__'), | ||
('ex', r'\__hatwidest__')], | ||
r'\widetilde': [('rm', '\x7e'), ('ex', r'\__tildewide__'), | ||
('ex', r'\__tildewider__'), ('ex', r'\__tildewidest__')], | ||
} | ||
for alias, target in [(r'\leftparen', '('), (r'\rightparen', ')'), | ||
(r'\leftbrace', '{'), (r'\rightbrace', '}'), | ||
(r'\leftbracket', '['), (r'\rightbracket', ']'), | ||
(r'\langle', '<'), (r'\rangle', '>'), | ||
(r'\{', '{'), (r'\}', '}'), | ||
(r'\[', '['), (r'\]', ']')]: | ||
_size_alternatives[alias] = _size_alternatives[target] | ||
def get_sized_alternatives_for_symbol(self, fontname: str, | ||
@@ -1524,7 +1504,7 @@ class AutoHeightChar(Hlist): | ||
""" | ||
def __init__(self, c: str, height: float, depth: float, state: ParserState, | ||
factor: float | None = None): | ||
alternatives = state.fontset.get_sized_alternatives_for_symbol( | ||
state.font, c) | ||
@@ -1563,7 +1543,7 @@ class AutoWidthChar(Hlist): | ||
always just return a scaled version of the glyph. | ||
""" | ||
def __init__(self, c: str, width: float, state: ParserState, | ||
char_class: type[Char] = Char): | ||
alternatives = state.fontset.get_sized_alternatives_for_symbol( | ||
state.font, c) | ||
@@ -2712,7 +2692,7 @@ def sqrt(self, toks: ParseResults) -> T.Any: | ||
# the height so it doesn't seem cramped | ||
height = body.height - body.shift_amount + thickness * 5.0 | ||
depth = body.depth + body.shift_amount | ||
check = AutoHeightChar(r'\__sqrt__', height, depth, state) | ||
height = check.height - check.shift_amount | ||
depth = check.depth + check.shift_amount | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.