Skip to content

Commit a30432f

Browse files
authored
Merge pull request #374 from mathjax/develop
1.3.0 release
2 parents b1618f8 + fd83f71 commit a30432f

File tree

12 files changed

+30
-266
lines changed

12 files changed

+30
-266
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ node_js:
44
- '5'
55
- '6'
66
- '7'
7+
- '8'
8+
- '9'
79
- stable
810
sudo: false
911
script:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ The following are the default input options.
114114
useGlobalCache: false, // use common <defs> for all equations?
115115
linebreaks: false, // automatic linebreaking
116116
equationNumbers: "none", // automatic equation numbering ("none", "AMS" or "all")
117+
cjkCharWidth: 13, // width of CJK character
117118

118119
math: "", // the math string to typeset
119120
format: "TeX", // the input format (TeX, inline-TeX, AsciiMath, or MathML)

lib/main.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var fs = require('fs');
3131
var path = require('path');
3232
var url = require('url');
3333
var jsdom = require('jsdom').jsdom;
34+
var isFullwidthCodePoint = require('is-fullwidth-code-point');
3435

3536
require('./patch/jsdom.js').patch(jsdom); // Fix some bugs in jsdom
3637

@@ -47,6 +48,7 @@ var defaults = {
4748
useGlobalCache: false, // use common <defs> for all equations?
4849
linebreaks: false, // do linebreaking?
4950
equationNumbers: "none", // or "AMS" or "all"
51+
cjkCharWidth: 13, // width of CJK character
5052

5153
math: "", // the math to typeset
5254
format: "TeX", // the input format (TeX, inline-TeX, AsciiMath, or MathML)
@@ -309,7 +311,11 @@ function ConfigureMathJax() {
309311
if (def["font-weight"] === "") delete def["font-weight"];
310312
this.SUPER(arguments).Init.call(this,def);
311313
SVG.addText(this.element,text);
312-
var bbox = {width: text.length * 8.5, height: 18, y: -12};
314+
// tweaking font fallback behavior: https://github.com/mathjax/MathJax-node/issues/299
315+
var textWidth = text.split('')
316+
.map(function(c) { return isFullwidthCodePoint(c.codePointAt()) ? data.cjkCharWidth : 8.5 })
317+
.reduce(function(a, b) { return a + b }, 0);
318+
var bbox = {width: textWidth, height: 18, y: -12};
313319
scale *= 1000/SVG.em;
314320
this.element.setAttribute("font-family","monospace");
315321
this.element.setAttribute("transform","scale("+scale+") matrix(1 0 0 -1 0 0)");

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mathjax-node",
3-
"version": "1.2.1",
3+
"version": "1.3.0",
44
"description": "API's for calling MathJax from node.js",
55
"keywords": [
66
"MathJax",
@@ -23,8 +23,9 @@
2323
"url": "git://github.com/mathjax/MathJax-node.git"
2424
},
2525
"dependencies": {
26+
"is-fullwidth-code-point": "^2.0.0",
2627
"jsdom": "7.0 - 9.12",
27-
"mathjax": "*"
28+
"mathjax": "^2.7.2"
2829
},
2930
"scripts": {
3031
"test": "tape test/*.js"

test-files/sample-mml.html

Lines changed: 0 additions & 116 deletions
This file was deleted.

test-files/sample-tex.html

Lines changed: 0 additions & 96 deletions
This file was deleted.

test-files/test-am.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

test-files/test-mml.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

test-files/test-mml2.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

test-files/test-tex.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)