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

Svg refinement #1657

Merged
merged 25 commits into from
Sep 29, 2021
Merged

Svg refinement #1657

merged 25 commits into from
Sep 29, 2021

Conversation

brucemiller
Copy link
Owner

Overall refinement of SVG output from both TikZ and the picture environment. The main thrust is to avoid any scaling that causes the text within the SVG to be different size than the text in the containing document. This basically means to consistently use pixel units within the SVG, and avoid the viewBox attribute (which introduces an unknowable scaling).

Several other Tikz/picture improvements were snuck in along the way.
Thus this:
fixes #1646
fixes #1196
fixes #632

Note that we currently can only estimate the text size from TeX's perspective, and have no way of knowing the browser's fonts. Thus any such scaling compounds any alignment and sizing errors.

@dginev
Copy link
Collaborator

dginev commented Sep 25, 2021

Just to double-check, is this the kind of output you are seeing for the example in #1196 ?
(don't mind the purple color,that is from the background of the showcase editor)

image

The other examples seem quite pleasing, especially the one in #632 . The tikz examples from the showcase /editor set convert nicely too. Will read the code changes next.

@brucemiller
Copy link
Owner Author

Pretty much, yeah; it isn't perfect, but quite close given that the absolute dimensions and not having the same math font as TeX.

Copy link
Collaborator

@dginev dginev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive PR, lots of upgrades!

I have a limited understanding here, but tried to spot what I could, and remarked on what was hard to read through. Quite happy with the updated/added tests!

I'm even wondering if it's better to have some of those as HTML to easily preview if they look right using a browser... but I assume you did that with latexmlpost locally, which is fine.

lib/LaTeXML/Package/LaTeX.pool.ltxml Show resolved Hide resolved
lib/LaTeXML/Package/diagbox.sty.ltxml Show resolved Hide resolved
lib/LaTeXML/Package/diagbox.sty.ltxml Outdated Show resolved Hide resolved
$Ax = 0;
$Bx = $w->subtract($Bw)->ptValue;
$w = 2 * $maxw unless $w;
$h = $Ah + $Bh unless $h;
Copy link
Collaborator

@dginev dginev Sep 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the zero cases important here? i.e. compared to unless defined $h

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I've lost track by now.

lib/LaTeXML/Package/diagbox.sty.ltxml Show resolved Hide resolved
lib/LaTeXML/Package/pst-node.sty.ltxml Show resolved Hide resolved
AssignValue('\psorigin', Pair($c0->getX->negate, $c0->getY->negate));
my $org = getNecessaryTransform();
AssignValue('_psActiveCCTransform', $org);
ackTransform($org);
$whatsit->setProperties(need => 1, transform => $org->ptValue);

$whatsit->setProperties(need => 1, transform => $org->ptValue,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking: the transform here is still in ptValue even if all others are switching to px?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly; transform in this case is a simple dimension, not the css/svg one. Lack of testing.

lib/LaTeXML/Package/pstricks.sty.ltxml Outdated Show resolved Hide resolved
lib/LaTeXML/Post/SVG.pm Show resolved Hide resolved
lib/LaTeXML/Post/SVG.pm Outdated Show resolved Hide resolved
Copy link
Collaborator

@dginev dginev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@brucemiller brucemiller merged commit a32f62a into master Sep 29, 2021
@brucemiller brucemiller deleted the svg-refinement branch September 29, 2021 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants