Skip to content
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

restore viewBox in pgf pictures #2396

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xworld21
Copy link
Contributor

Fix #2376 for PGF/TikZ.

The commit that removed @viewBox said 'AVOID scaling, in particular viewBox so that text size matches containing document'. I can't quite tell what issue was being addressed: if @viewBox and @width, @height agree, no scaling happens. Rather, having the correct @viewBox enables CSS to change width and height, and that can only happen intentionally. So I am guessing this PR is fine.

@brucemiller
Copy link
Owner

No, sadly just adding the viewbox line alone doesn't work, even though you'd reasonably think that it should. When there are graphics and text combined into the figure, somehow, somewhere, inconsistencies between the dimensions & ems used in the TeX processing clashes with the dimensions & ems used by the browser, and stuff ends up looking sometimes quite horrible. I'll have to go dig through my sample set to find an example.
Forcing px and omitting the viewbox was the only way I got things to look decent, although I'll freely admit that I doubt this is the Correct solution. Maybe rem is part of it?

@xworld21
Copy link
Contributor Author

xworld21 commented Sep 5, 2024

sadly just adding the viewbox line alone doesn't work, even though you'd reasonably think that it should. When there are graphics and text combined into the figure, somehow, somewhere, inconsistencies between the dimensions & ems used in the TeX processing clashes with the dimensions & ems used by the browser, and stuff ends up looking sometimes quite horrible. I'll have to go dig through my sample set to find an example

Thanks, the example would be really helpful! I really struggle to see how adding the viewbox can affect the output (or rather, how omitting it helps in any way). As far as I understand, the viewbox 0 0 width height is essentially the 'default' value of the SVG anyway, so it is a no-op. Provided CSS is not manipulating the images further.

(I have enabled the viewbox in BookML a few weeks ago with no problems, but it's not too significant... most of my few users are still using dvisvgm for TikZ so they won't notice the difference.)

@xworld21
Copy link
Contributor Author

xworld21 commented Sep 5, 2024

Forcing px and omitting the viewbox was the only way I got things to look decent, although I'll freely admit that I doubt this is the Correct solution. Maybe rem is part of it?

PS: I have done some tweaks in BookML about this by saving the 8/9/10/11/12pt class option, the dpi (default 100 in LaTeXML), and readjusting the SVGs in CSS (requires viewbox). The results are reasonable as long as the fonts are similar enough. I specifically tested with Latin Modern in both PDF and HTML, and got a perfect match, of course.

@dginev
Copy link
Collaborator

dginev commented Sep 5, 2024

I also need to learn more about viewBox and the CSS interplay. This PR is likely to have very significant impact over arXiv, where almost 10% of current user reports have to deal with SVG not fitting its precomputed size (although I'm sure there are multiple separate causes in different articles and packages).

Having more opportunity for CSS customization would be a net good, if we could pull it off...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add viewBox to inline SVGs
3 participants