-
Notifications
You must be signed in to change notification settings - Fork 20
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
[FEATURE]? Is there a way to use different fonts in LaTeXStrings? #53
Comments
Currently there is none. Locating the correct symbols in the font files is done mostly manually, so for a new font we would have to create a mapping of commands to symbols in the font. So far I have not been able to make sense of what the latex packages are doing to provide new fonts. The ability to adapt fonts from latex packages would be of immense help for that. What could be possible without too much trouble is changing the font for everything but the maths. |
Thanks. At the moment that latter solution is what I do (Computer Modern for all fonts in Makie). And for the Physics journals that I publish in at the moment, that's ok. But more and more use sans-serif fonts. Would using the LaTeX maths fonts not mean that all the symbols would be in the same location/encoding within the font? It is possible in Matplotlib, btw., but that uses a LaTeX engine in the background. |
Should the mathematical symbols use sans-serif font in this case too? What I meant there is that in a LaTeX string mixing math and normal text, the text could use the font you need, while still falling back to Computer Modern for the math symbols.
Unfortunately, no. Computer Modern (which is also LaTeX default) distributes its symbols over several font files and I don't know if the ordering of it is otherwise standard for LaTeX fonts. It may or may not, the problem being that I find extremly difficult to understand what is going on, and I have not been able to find clear explanation about it (I did not search that much to be fair). On the other hand, newer system like LuaLaTex uses unicode fonts that should have a standard encoding and ordering, but the system they use to define alternative symbol (e.g. the two different symbols for integral, for inline math vs separate equation) is, as far as I understood, not supported by FreeType which is the backend we use to retrieve symbol informations (and that Makie and maybe Cairo use to render them). TL DR: Fonts are complicated, and I don't fully understand all the magic LaTeX is doing to make them work.
There has been discussion and some test about using a LaTeX engine for rendering the fonts see e.g. https://github.com/JuliaPlots/MakieTeX.jl I have not followed the exact developpement of the idea, and I am not sure where it actually stands. |
Hey @Kolaru, Do you have any references for that / any resources on that topic? I'd like to do some digging, but need a place to start :). |
@marcpabst The problem of grabbing alternative glyph has been solved \o/ (mostly, I still built a manual table to get what I need, but it works) One place to start to see what kind of unicode font is supported by latex(or by the On master we are currently using the New Computer Modern font listed there. There seems to be a bit more info about opentype fonts and where to find the math info here : https://tex.stackexchange.com/questions/360406/using-math-fonts-in-lualatex |
Nice! Is there someone currently working on supporting OpenType math fonts? I'm specifically interested in Fira Math, but I think the mechanics would be the same for all OpenType (math) fonts. If not, I would start looking into it :) |
The backend used by MathTeXEngine and Makie to handle font is FreeTypeAbstraction.jl. As the name indicates it provides support for FreeType fonts, but there is some level of interop between the two. As far as I know no one is trying to get a full support for OpenType in julia. |
I was under the impression that FreeType (I don't think there is a font format of that name btw) had support for OpenType fonts... But I'll play around with |
would it be easier to at least support |
What do you mean by This issue is rather frustrating, because the work has been done already for a bunch of fonts (mapping command to glyph and correctly placing them), but I just can't figure out where the info is stored. If I ever feel really bored, I plan to look at what MathJax is doing, apparently they have something going on (https://docs.mathjax.org/en/latest/output/fonts.html). |
I just mean that I only need mapping for the ascii sets in those other fonts |
Oh that should already kind-of work, only the placement could be off. I'll look into that. I suspect the main problem is that the interface to change the font is probably clunky and confusing. |
basically, when publisher requires some font, it's usually about the ASCII, for example they want the "unit" of some value to be in Helvetica. I mean Helvetica doesn't have math stuff anyway, right? ( |
Sorry for my uninformed and unsolicited comment! I am by no means an expert on fonts. I have tried to skim this discussion to offer a possible step forward if one actually wanted to implement OptenType fonts here: So from what I gather, the letter that LaTeX renders when using The unicode-math package has a huge TeX table here that defines the new unicode-math latex command, in the case of The unicode coordinate may then be lookup in the OFT files for a math font, e.g. the brilliant work by the TeX Gyre group and others:
In case of What I have no clue on are the environment characters such as Let me know if there was any useful information in my comment, I hope this may offer an angle of attack to continue the hunt for an automatised lookup table. |
No need to apologize, the point of making the code open source is to get unsolicited comments :) Finding the unicode-math table is already great! I did some work on that a while back, but other projects and issues are currently keeping me occupied. I hope to be able to delve into this again soonish. |
LaTeX itself allows to choose fonts for typeset maths. Is there a way to do that in LaTeXStrings / MathTexEngine.jl as well?
The text was updated successfully, but these errors were encountered: