-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
Font changes on its own within log-scale tick label #1296
Comments
Using e.g. LaTeX you can observe that some fonts distinguish between digits occuring in text and in math mode. Some digits decent below the baseline when in text mode but don't when in math mode. I suspect that tick labels are rendered like classical strings (cf #1560 (comment)), i.e. in text mode only, and the exponents are "text mode superscripts". As a hotfix, maybe there is a different variant of your font that is identical up to this particular handling of digits. |
There is evidently a font-selection problem, but it's not just a baseline issue, or that the the base and exponent are in different fonts, it's that the font changes within the superscript! For example, if you zoom in on the The 1 and the 5 in the exponent are clearly different fonts — not just at different positions relative to the baseline. In fact, if I crop that little section out of the PDF, For reference, here is what Note that the bottoms of 1 and 5 are aligned in all three fonts, and the results are consistent with what |
I've just tried this code again with a fresh julia (1.7.2) project, in which the only dependency was And again, I should clarify that this pattern is the same for the exponents in all the y ticklabels: everything uses CMU Serif except for the last digit in the exponent, which is in DejaVu Sans — whether it's the final 0 in |
At least for GLMakie, a fallback font gets used if a certain glyph can't be found in the font. |
@SimonDanisch, how did you find which glyphs are included in a particular font? I was trying to find out which digit glyphs are included for Utopia, but could only find the "normal" digits. Could the issue be related to superscript 1, 2, 3 being in the Latin-1 Supplement group while 4-9, 0 are in the Superscripts and Subscripts range? Maybe, for the Latin-1 Supplement, some fonts know how to transform the default character set, while for the other group they just pass. cf https://github.com/SimonDanisch/UnicodeFun.jl/blob/master/src/sub_super_scripts.jl#L76-L90 |
Yeah, haven't looked it up, but sounds about right that they're in different groups. using FreeTypeAbstraction
font = FreeTypeAbstraction.findfont("Dejavu Sans")
FreeTypeAbstraction.FT_Get_Char_Index(font, '⁷') !== 0 |
Thanks! FYI, Utopia has glyphs for Latin-1 Supplement only (i.e. superscript 1,2,3; I fixed my comment above). I don't have CMU Serif installed, so I can't check. |
Ah, I didn't realize it was trying to use unicode to do superscripts. Indeed, on my system at least, lualatex can only find superscript glyphs in CMU Serif for 1, 2, and 3. But it can actually create superscripts in the usual tex way. So I guess the problem is to get ticklabels created using LaTeXStrings... |
When using a font different from the default, and using a log scale, it is obvious that the font changes within the superscript of the tick labels. Here's an MWE simplified from the BeautifulMakie example:
As you can see, the last digit in the exponents of the tick labels on the y scale are in the wrong font, and seemingly incorrectly aligned vertically:
logscale.pdf
(Note that the "last" digit is the only digit in the 10^0 and 10^-5 superscripts, but their heights are clearly inconsistent with the other superscripts, and at least the 5 is obviously sans serif.)
It seems that a workaround is to add the argument
to the
Axis
call, though that makes the superscripts a little lighter and harder to read.Here's my version info:
The text was updated successfully, but these errors were encountered: