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

valign not working on mglyph #2360

Closed
wspilot opened this issue Feb 28, 2020 · 4 comments
Closed

valign not working on mglyph #2360

wspilot opened this issue Feb 28, 2020 · 4 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3
Milestone

Comments

@wspilot
Copy link

wspilot commented Feb 28, 2020

I am using an svg (also tried an .png) as mglyph and it has to align with the descender line of the preceding character. Whatever value or unit I use, the glyph stays on the base line.
Ubuntu 19.10
Firefox 73.0.1
Chrome Version 80.0.3987.87 (Official Build) (64-bit)
See attached html and svg file. Note: I had to rename the files toto .txt because .svg and .html are not accepted as type. Please remove the .txt extension.
bugTest0.svg.txt
bugtest0.html.txt

@wspilot wspilot changed the title valign not working om mglyph valign not working on mglyph Feb 28, 2020
@wspilot wspilot closed this as completed Feb 28, 2020
@wspilot wspilot reopened this Feb 28, 2020
@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Ready for Development v3 labels Feb 28, 2020
@dpvc
Copy link
Member

dpvc commented Feb 28, 2020

OK, it turns out that the mglyph code is looking for voffset rather than valign, and that the alignment direction is reversed. Not sure how that happened, but thanks for reporting the issue. I will fix it in the next release.

In the meantime, you can use the following code

    <script>
      MathJax = {
        startup: {
          ready() {
            MathJax.startup.defaultReady();
            MathJax.startup.input[1].postFilters.add((args) => {
              args.data.walkTree((node) => {
                if (node.isKind('mglyph')) {
                  const attributes = node.attributes;
                  if (attributes.isSet('valign')) {
                    const y = attributes.get('valign');
                    attributes.set('voffset', y.charAt(0) === '-' ? y.slice(1) : '-' + y);
                  }
                }
              });
            });
          }
        }
      }
    </script>

to post-filter the MathML input to look for mglyph elements and convert the valign attributes to voffset (switching the direction of the shift so that it displays properly).

@dpvc
Copy link
Member

dpvc commented Feb 28, 2020

I've made a pull request to resolve the issue.

@wspilot
Copy link
Author

wspilot commented Mar 3, 2020

FYI
I just found out that it does work in V 2.7.5

@dpvc
Copy link
Member

dpvc commented Mar 3, 2020

Yes, the error occurred during the v3 rewrite. The name of the attribute was incorrectly entered in the v3 code.

@dpvc dpvc added this to the 3.0.2 milestone Mar 5, 2020
dpvc added a commit to mathjax/MathJax-src that referenced this issue Mar 30, 2020
Fix mglyph attribute from offset to align.  (mathjax/MathJax#2360)
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Mar 30, 2020
@dpvc dpvc added the Fixed label Apr 10, 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