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 ouptut] API for stylesheet #283

Closed
pkra opened this issue Dec 29, 2016 · 6 comments
Closed

[SVG ouptut] API for stylesheet #283

pkra opened this issue Dec 29, 2016 · 6 comments
Labels

Comments

@pkra
Copy link
Contributor

pkra commented Dec 29, 2016

This came up on pkra/mathjax-node-page#18.

There's currently an API to get the stylesheet needed for the CommonHTML output but no API for the stylesheet used for SVG output. It used to be that mjpage added a slimmed down stylesheet when using the SVG output.

Should there be a way to generate it or should this be handled differently?

@dpvc
Copy link
Member

dpvc commented Dec 29, 2016

A quick look at the code suggests that for the "self-contained" SVG images that were generated by mj-single, there are only three styles that affect the SVG elements themselves (the ones that handle the font for monospace and sans-serif fonts, and the one for the color of href links). The rest all have to do with the surrounding machinery of MathJax, and its preventing bleed-through of CSS from the surrounding page into the SVG.

Your current mjpage implementation does not incorporate the container elements that MathJax uses for things like centering displayed equations, and so on, so I'm not sure how useful obtaining the rest of the CSS would be. It seems that, under the new organization, it is the role of mjpage to insert whatever container elements it thinks are needed, and so the CSS to control them should be handled through mjpage, not MathJax itself. That is, mjpage should manage the stylesheet that handles centering and so on (though it should probably include the three rules needed for the fonts and the links) since it will depend on the DOM elements that it inserts; the CSS from MathJax probably won't be what is needed. Also, the selectors for the rules for the fonts probably will need to be modified (since they depend on the SVG being inside a MathJax container element with class MathJax_SVG, and that may not be what mjpage uses). So it might not even be useful to get those three rules from MathJax.

@MissMyCat
Copy link

@dpvc hi I wonder generate sgv from Latex which contains Chinese chacater, but the error is
SVG - Unknown character: U+FF08 in STIXMathJax_SansSerif
SVG - Unknown character: U+5728 in STIXMathJax_SansSerif
SVG - Unknown character: U+8303 in STIXMathJax_SansSerif
SVG - Unknown character: U+56F4 in STIXMathJax_SansSerif
SVG - Unknown character: U+5185 in STIXMathJax_SansSerif
SVG - Unknown character: U+5747 in STIXMathJax_SansSerif
SVG - Unknown character: U+7ED9 in STIXMathJax_SansSerif
SVG - Unknown character: U+5206 in STIXMathJax_SansSerif
SVG - Unknown character: U+FF09 in STIXMathJax_SansSerif

cmd is
node D:/node_modules/mathjax-node/bin/tex2svg2 "\text{1}.\text{844}\mathsf{(在}\text{1}.\text{842}\sim \text{1}.\text{846}\mathsf{范围内均给分)}"
may I add new fonts to support it ?
Or do something

@pkra
Copy link
Contributor Author

pkra commented Jan 16, 2017

@MissMyCat please don't post unrelated issues on existing issue threads.

the error is
SVG - Unknown character: U+FF08 in STIXMathJax_SansSerif

that's only a warning; system fonts will be used for characters not provided by the chosen font.

may I add new fonts to support it ?

This is #80; that's a difficult problem though.

@MissMyCat
Copy link

@pkra
thanks for your reply.
I post problem here because when I used those characters Unknown for SVG, the result style is mess
mess

As you can see, Characters overlap each other.

Is this relate to style or font?

@dpvc
Copy link
Member

dpvc commented Jan 16, 2017

I post problem here because

I think Peter meant that you should start a new issue when you have a new problem rather than adding to an existing issue that has already been answered (and in this case is pretty much unrelated to the issue you are having).

As for the font warning messages, you could edit the bin/tex2svg file to change

mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});

to

mjAPI.config({
  MathJax: {SVG: {font: argv.font}},
  extensions: argv.extensions,
  undefinedCharError: false
});

to prevent them from being reported.

As for the characters themselves, mathjax-node will not be able to place these properly, because it doesn't have the bounding box data required to know how much space they take up (that is one reason you get the warning). Because mathjax-node can not find out the sizes as it can in a browser (that has a DOM whose elements can be measured), it tries to use a monospaced font for unknown characters, and assumes the width of those characters to all be the same and relatively small (1ex as I recall). Your characters probably aren't in your system's monospace font, and when you view the file, you are getting them from a variable-width font where they take up more space. So they aren't placed properly.

Unfortunately, there is very little that mathjax-node can do about that without having a more fully-featured DOM implementation to work with.

@pkra
Copy link
Contributor Author

pkra commented Jan 27, 2017

Realized I never responded to the actual topic.

mjpage should manage the stylesheet that handles centering and so on (though it should probably include the three rules needed for the fonts and the links)

Makes sense.

@pkra pkra closed this as completed Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants