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 output ignores the scale configuration option #2376

Closed
dpvc opened this issue Mar 21, 2020 · 5 comments
Closed

SVG output ignores the scale configuration option #2376

dpvc opened this issue Mar 21, 2020 · 5 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3
Milestone

Comments

@dpvc
Copy link
Member

dpvc commented Mar 21, 2020

The SVG output is not taking the scale configuration option into account. This should be done in the SVG output jax setScale() method, but that was override because the default includes the MathItem's metric scaling as well, which isn't needed for SVG output.

@working-name
Copy link

How can I help with testing? I'm seeing this on Safari (iOS 13, macOS 10.15) - chose _SVG to get away from _CHTML which doesn't render all MML items.

@dpvc
Copy link
Member Author

dpvc commented Mar 23, 2020

How can I help with testing?

You could try out the issue2376 branch of the MathJax-src repository, but you would have to clone the repository locally, checkout the branch, and then run the compile and make-components npm scripts in order to create the es5/tex-svg.js file that needs to be tested. If that doesn't make sense to you, I can spell it out in more detail.

Alternatively, this is a sample file that patches the CDN copy of MathJax, and you can check that this does scale properly when you set the scaling factor.

<!DOCTYPE html>
<html>
  <head>
    <meta content="width=device-width, initial-scale=1" name="viewport"/>
    <meta charset="utf-8"/>
    <title>SVG scale option</title>
    <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
    <script>
    MathJax = {
      svg: {
        scale: 2
      },
      startup: {
        ready() {
          const SVG = MathJax._.output.svg_ts.SVG;
          const percent = MathJax._.util.lengths.percent;
          SVG.prototype.setScale = function (node) {
            if (this.options.scale !== 1) {
              this.adaptor.setStyle(node, 'fontSize', percent(this.options.scale));
            }
          }
          MathJax.startup.defaultReady();
        }
      }
    };
    </script>
    <script id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
  </head>
  <body>
  
  Scaled math: \(x+1\).

  </body>
</html>

If it works for you, you could indicate that in the pull request for this issue.

@dpvc
Copy link
Member Author

dpvc commented Mar 23, 2020

chose SVG to get away from CHTML which doesn't render all MML items.

Both SVG and CHTML should process exactly the same MathML items. Can you give an example of one that CHTML doesn't process but SVG does?

@working-name
Copy link

Sorry that comment was probably out of line/scope. I am experiencing rendering issues with 2.7.x not 3.0 but that's on a site which is subscription only with tests, not entirely easy to provide examples. I'll open a specific issue if I can recreate it in a vanilla HTML.

Will report back about the scaling.

@dpvc
Copy link
Member Author

dpvc commented Mar 23, 2020

No problem. Thanks for being willing to help check.

@dpvc dpvc removed their assignment Apr 1, 2020
dpvc added a commit to mathjax/MathJax-src that referenced this issue Apr 3, 2020
Make SVG honor the scale configuration option.  (mathjax/MathJax#2376)
@dpvc dpvc added Merged Merged into develop branch Fixed and removed Ready for Review labels Apr 3, 2020
@dpvc dpvc closed this as completed Apr 10, 2020
@dpvc dpvc removed the Merged Merged into develop branch label Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3
Projects
None yet
Development

No branches or pull requests

2 participants