1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-24 09:13:07 +02:00
This commit is contained in:
Pomax
2016-01-02 08:41:28 -08:00
parent 4f3227793a
commit 15523da391
2 changed files with 69 additions and 68 deletions

View File

@@ -45,13 +45,14 @@ function escapeBlockLaTeX(source) {
// Make sure we hardcode the size of this LaTeX SVG image, because we absolutely
// do not want the page to resize in any possible noticable way if we can help it.
// The SVG contains values in "ex" units, but to maximise rendering compatibility
// with things like older Android tables etc. we convert these to "em" instead.
// The SVG contains values in "ex" units, but to maximise legibility we convert
// these to "rem" instead, so that formulae are always sized the same, no matter
// the textsize around them.
var svg = fs.readFileSync(filename).toString();
var exem = 0.45;
var w = parseFloat(svg.match(/width="([^"]+)"/)[1]) * exem;
var h = parseFloat(svg.match(/height="([^"]+)"/)[1]) * exem;
var rewrite = `<img className="LaTeX SVG" src="${filename}" style={{width:"${w}em", height:"${h}em"}} />`;
var ex2rem = 0.45;
var w = parseFloat(svg.match(/width="([^"]+)"/)[1]) * ex2rem;
var h = parseFloat(svg.match(/height="([^"]+)"/)[1]) * ex2rem;
var rewrite = `<img className="LaTeX SVG" src="${filename}" style={{width:"${w}rem", height:"${h}rem"}} />`;
newsource += rewrite;
}