Add support for space characters, and adjust fuzz to work better with Chrome.

This commit is contained in:
Davide P. Cervone 2015-03-11 15:52:03 -04:00
parent ba50c5c690
commit a406adcb4d
2 changed files with 22 additions and 2 deletions

View File

@ -1548,6 +1548,17 @@
// Add some spacing characters
//
MathJax.Hub.Insert(CHTML.FONTDATA.FONTS[MAIN],{
0x2000: [0,0,500,0,0,{space:1}], // en space
0x2001: [0,0,1000,0,0,{space:1}], // em quad
0x2002: [0,0,500,0,0,{space:1}], // en quad
0x2003: [0,0,1000,0,0,{space:1}], // em space
0x2004: [0,0,333,0,0,{space:1}], // 3-per-em space
0x2005: [0,0,250,0,0,{space:1}], // 4-per-em space
0x2006: [0,0,167,0,0,{space:1}], // 6-per-em space
0x2009: [0,0,167,0,0,{space:1}], // thin space
0x200A: [0,0,100,0,0,{space:1}], // hair space
0x200B: [0,0,0,0,0,{space:1}], // zero-width space
0x200C: [0,0,0,0,0,{space:1}], // zero-width non-joiner space
0x2061: [0,0,0,0,0,{space:1}], // function application
0x2062: [0,0,0,0,0,{space:1}], // invisible times
0x2063: [0,0,0,0,0,{space:1}], // invisible separator

View File

@ -35,7 +35,7 @@
var SCRIPTFACTOR = Math.sqrt(1/2),
AXISHEIGHT = .25,
HFUZZ = .05, DFUZZ = 0; // adjustments to bounding box of character boxes
HFUZZ = .025, DFUZZ = .025; // adjustments to bounding box of character boxes
var STYLES = {
".MathJax_CHTML_Display": {
@ -494,7 +494,7 @@
// if (typeof(font) === "string") this.loadFont(font);
var C = font[n];
if (C) {
// ### FIXME: implement aliases, spaces, etc.
// ### FIXME: implement aliases
if (C.length === 5) C[5] = {};
if (C.c == null) {
C[0] /= 1000; C[1] /= 1000; C[2] /= 1000; C[3] /= 1000; C[4] /= 1000;
@ -506,6 +506,7 @@
+ String.fromCharCode((N&0x3FF)+0xDC00);
}
}
if (C[5].space) return {type:"space", w:C[2]};
return {type:"char", font:font, n:n};
} // else load block files?
}
@ -536,6 +537,14 @@
if (bbox.r < bbox.w+C[4]) bbox.r = bbox.w+C[4];
bbox.w += C[2];
if (m == 1 && font.skew && font.skew[item.n]) bbox.skew = font.skew[item.n];
break;
case "space":
if (item.w) {
HTML.addElement(node,"mjx-space",{style:{"margin-left":CHTML.Em(item.w)}});
bbox.w += item.w;
}
break;
}
}
if (node.childNodes.length) {