-
Notifications
You must be signed in to change notification settings - Fork 45
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
Customize font size and font family for STEM expressions #45
Comments
As far as I know, mathematical converts fonts into paths in the resultant svg file. So it is impossible to change the font without help from mathematical, which does not provide such support yet. For the STEM size, it is possible to let asciidoctor-pdf scale the image to the same height as the surrounding lines? |
@ProgramFan Thanks a lot for your quick response! I am more interested in configuring the font size right now. I am trying to do exactly what you said in asciidoctor-pdf: trying to scale image to the line height Unfortunately, I haven't found a way yet... |
I do not use asciidoctor-pdf often so you'd better refer to @mojavelinux. |
@mojavelinux Hey Dan, do you have any hint how I can achieve this? Thanks! |
If my understanding is correct, asciidoctor-mathemetical produces an SVG which is embedded into the PDF. If that's the case, then you'll need to set the dimensions of the SVG to match the line height. See https://github.com/asciidoctor/asciidoctor-pdf/blob/master/README.adoc#image-scaling I'll do a quick test to see if I can figure out what setting to use. |
(I didn't mean to close the issue. I accidentally hit the button trying to focus the text area). |
In short, you'd need to influence the dimensions of the image macro that asciidoctor-mathematical produces. Unfortunately, there's no way to express height=1em (or pdfheight=1em) in Asciidoctor PDF currently. The only dimension you can control is width (which would depend on the length of the equation). So we'd first need to add support for controlling the height of an image in Asciidoctor PDF. Then asciidoctor-mathematical could output that preference. I suppose in the meantime, asciidoctor-mathematical could support some sort of scale factor so you can size all images up by a certain amount. That would certainly address the issue in the short-term. |
Perhaps something like mathematical-scale? It would need to scale the width and height proportionally (or just not set the height, since the height of an image is never used in Asciidoctor). |
Are there any ways to scale an image in asciidoctor-pdf so that the image height is identical to the line height? If possible, asciidoctor can export special attributes to the image macro, and asciidoctor-mathematical can make use of it. This approach can also solve the height-mismatches when using equations in titles. |
As I mentioned, we would need a change to Asciidoctor PDF. |
Thanks a lot again for your replies @mojavelinux and @ProgramFan! I tried to go over the route: |
I hacked a scale factor into my local copy of asciidoctor-mathematical and used it with asciidoctor-pdf. It looks much better, but the baseline of the image is still wrong, giving the appearance that the equation is floating in the air. I haven't done any hacking on asciidoctor-pdf. Does anyone have any insights about where in its codebase the changes would need to go so that it passed enough information to asciidoctor-mathematical? Or does anyone know who works on asciidoctor-pdf who might be interested in helping with this problem? I'm surprised more people aren't bothered by this problem, since weak LaTeX support seems to be a significant drawback of the PDF backend relative to the HTML backend. |
There isn't a direct integration between Asciidoctor PDF and asciidoctor-mathematical. asciidoctor-mathematical produces an SVG, which Asciidoctor PDF then embeds. But Asciidoctor PDF doesn't even really handle that either. That's the job of prawn-svg. So you might want to try the generated SVG with prawn-svg first to see if that's working. If that works, but it doesn't work in Asciidoctor PDF, then we can look deeper. At that point, I would encourage you to open an issue in Asciidoctor PDF. |
Hi guys,
I have two questions/issues:
In the screenshot, I am rendering the PDF using asciidoctor-pdf. Also, I customized
base.font_size= 15
in a custom theme. As we can see, the size of the text is 15 and is much bigger than the size of the STEM expression.How can I configure the font size of a STEM expression?
The font used in the STEM expression is different from the font for text. How can I configure the font family for STEM expressions?
Thanks a lot!
Screenshot below:
The text was updated successfully, but these errors were encountered: