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.
Conversation
I don't remember the exact semantics of _get_glyph off the top of my head, but from a quick look at it, did you mean "returns" instead of "expects" (emphasis mine in the quote above)? |
Right yes. In fact, I meant that itscallers expect the character codes (they use |
b019f76
to2b0fd80
CompareAfter a bit of checking, I've found that for 12pt@100dpi, the multi-sized glyphs are 20, 30, 40, and 50 pixels, with regular text size being 16.671875 pixels (if available). So the text in the tests should look for an interior of 8.915625, 18.320833333333333, 25.156041666666667, 32.16734375, 42.03599479166666, which should hit all sizes of glyphs. Also, removed the regular sized braces |
I like the new implementation a lot, it's very clear (well, relative to the complexity of the task).
|
@@ -473,57 +473,37 @@ def _get_glyph(self, fontname: str, font_class: str, | |||
# The Bakoma fonts contain many pre-sized alternatives for the | |||
# delimiters. The AutoSizedChar class 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 comment
The 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.
If the larger glyphs for an auto-sized character in `cmex10` uses acharacter that is in the `latex_to_bakoma` table, then it will be mappedan extra time into `cmr10` (usually). Thus we end up with a largeversion of a "normal" character, such as an exclamation point.Instead map these glyphs through the `latex_to_bakoma` table by usingtheir glyph names as "commands". This ensures they don't getdouble-mapped to the wrong font and fixes the following issues:- slash (/) uses a comma at the larger sizes- right parenthesis uses an exclamation point at the largest size- left and right braces use parentheses at the largest size- right floor uses a percentage sign at the largest size- left ceiling uses an ampersand at the largest sizeAlso, drop the regular size braces, as they are the same as the first`big`-sized version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I guess it would be OK to test only one of the output formats, as we only care that the right glyphs are selected?
Do we have anything for that yet? There's |
There's svgastext? |
Uh oh!
There was an error while loading.Please reload this page.
PR summary
If the larger glyphs for an auto-sized character in
cmex10
uses a character that is in thelatex_to_bakoma
table, then it will be mapped an extra time intocmr10
(usually). Thus we end up with a large version of a "normal" character, such as an exclamation point.Instead map these glyphs through the
latex_to_bakoma
table by using their glyph names as "commands". This ensures they don't get double-mapped to the wrong font and fixes the following issues:It also found the missing
[
size, so it and the corresponding]
are now available again (causing the one test image change.)In the future, it may make sense to only use the glyph names (using
FT2Font.get_name_index
instead ofFT2Font.get_char_index
), and not have a mapping to character codes in our code. Unfortunately,TruetypeFonts._get_glyph
expects a font+character code, so this would be a much larger refactor than this bugfix.I'm turning the above images into tests, but I'm finding that characters that have a "regular" glyph may not be able to select the smallest "big" glyph, because it's actually smaller that the regular one. I'm not yet sure if that's a bug in the selection logic fromSince I'll be adding some test images, this PR can wait until after the FreeType 2.13 change.AutoHeightChar
or whether regular glyphs shouldn't count.Fixes#5210 (and#18740 and#29886)
PR checklist