Handle \not better (produce proper unicode points for negated characters, when possible, use \u0338 when possible, and do \mathrel{\rlap{/}} otherwise). Add remappings to convert unavailable combinations back to combining characters for web-based fonts (this also makes it possible to handle double and tripple prime unicode code points).

This commit is contained in:
Davide P. Cervone 2012-01-14 15:05:47 -05:00
parent 1b20e06e30
commit 9763b5754f
17 changed files with 127 additions and 36 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -311,6 +311,39 @@
}
});
STACKITEM.not = STACKITEM.Subclass({
type: "not",
checkItem: function (item) {
var mml, c;
if (item.type === "open" || item.type === "left") {return true}
if (item.type === "mml" && item.data[0].type.match(/^(mo|mi|mtext)$/)) {
mml = item.data[0].CoreMO(), c = mml.data.join("");
if (c.length === 1 && !mml.movesupsub) {
c = STACKITEM.not.remap[c.charCodeAt(0)];
if (c) {mml.SetData(0,MML.chars(String.fromCharCode(c)))}
else {mml.Append(MML.chars("\u0338"))}
return item;
}
}
// \mathrel{\rlap{\notChar}}
mml = MML.mpadded(MML.mtext("\u29F8")).With({width:0});
mml = MML.TeXAtom(mml).With({texClass:MML.TEXCLASS.REL});
return [mml,item];
}
});
STACKITEM.not.remap = {
0x2208:0x2209, 0x220B:0x220C, 0x2223:0x2224, 0x2225:0x2226,
0x223C:0x2241, 0x007E:0x2241, 0x2243:0x2244, 0x2245:0x2247,
0x2248:0x2249, 0x003D:0x2260, 0x2261:0x2262,
0x003C:0x226E, 0x003E:0x226F, 0x2264:0x2270, 0x2265:0x2271,
0x2272:0x2274, 0x2273:0x2275, 0x2276:0x2278, 0x2277:0x2279,
0x227A:0x2280, 0x227B:0x2281, 0x2282:0x2284, 0x2283:0x2285,
0x2286:0x2288, 0x2287:0x2289, 0x22A2:0x22AC, 0x22A8:0x22AD,
0x22A9:0x22AE, 0x22AB:0x22AF, 0x227C:0x22E0, 0x227D:0x22E1,
0x2291:0x22E2, 0x2292:0x22E3, 0x22B2:0x22EA, 0x22B3:0x22EB,
0x22B4:0x22EC, 0x22B5:0x22ED, 0x2203:0x2204
};
var TEXDEF = {
//
@ -527,7 +560,7 @@
bowtie: '22C8',
models: '22A8',
notChar: '0338',
notChar: '29F8',
// Arrows
@ -864,8 +897,10 @@
pmb: ['Macro','\\rlap{#1}\\kern1px{#1}',1],
TeX: ['Macro','T\\kern-.14em\\lower.5ex{E}\\kern-.115em X'],
LaTeX: ['Macro','L\\kern-.325em\\raise.21em{\\scriptstyle{A}}\\kern-.17em\\TeX'],
not: ['Macro','\\mathrel{\\rlap{\\kern.5em\\notChar}}'],
' ': ['Macro','\\text{ }'],
// Specially handled
not: 'Not',
space: 'Tilde',
@ -1442,6 +1477,10 @@
this.Push(MML.menclose.apply(MML,this.InternalMath(this.GetArgument(name))).With({notation:"box"}));
},
Not: function (name) {
this.Push(STACKITEM.not());
},
Require: function (name) {
var file = this.GetArgument(name); // @@@ FIXME: check for OK URL
this.Extension(null,file);

View File

@ -71,7 +71,7 @@
offsetG: 0x03B1, variantG: "italic",
remap: {0x391:0x41, 0x392:0x42, 0x395:0x45, 0x396:0x5A, 0x397:0x48,
0x399:0x49, 0x39A:0x4B, 0x39C:0x4D, 0x39D:0x4E, 0x39F:0x4F,
0x3A1:0x50, 0x3A4:0x54, 0x3A7:0x58}},
0x3A1:0x50, 0x3A4:0x54, 0x3A7:0x58, 0x29F8:[0x002F,"italic"]}},
"bold": {fonts:[BOLD,SIZE1,AMS], bold:true,
offsetG: 0x03B1, variantG: "bold-italic",
remap: {0x391:0x41, 0x392:0x42, 0x395:0x45, 0x396:0x5A, 0x397:0x48,
@ -113,7 +113,7 @@
RULECHAR: 0x2212,
REMAP: {
REMAP: {
0x203E: 0x2C9, // overline
0x20D0: 0x21BC, 0x20D1: 0x21C0, // combining left and right harpoons
0x20D6: 0x2190, 0x20E1: 0x2194, // combining left arrow and lef-right arrow
@ -134,7 +134,32 @@
0x2329: 0x27E8, 0x232A: 0x27E9, // langle, rangle
0x3008: 0x27E8, 0x3009: 0x27E9, // langle, rangle
0x2758: 0x2223, // VerticalSeparator
0x2A2F: 0xD7 // cross product
0x2A2F: 0xD7, // cross product
0x2247: 0x2246, // wrong placement of this character
//
// compound symbols not in these fonts
//
0x2204: "\u2203\u0338", // \not\exists
0x220C: "\u220B\u0338", // \not\ni
0x2244: "\u2243\u0338", // \not\cong
0x2249: "\u2248\u0338", // \not\approx
0x2262: "\u2261\u0338", // \not\equiv
0x2274: "\u2272\u0338", // \not\lesssim
0x2275: "\u2273\u0338", // \not\gtrsim
0x2278: "\u2276\u0338", // \not\lessgtr
0x2279: "\u2277\u0338", // \not\gtrless
0x2284: "\u2282\u0338", // \not\subset
0x2285: "\u2283\u0338", // \not\supset
0x22E2: "\u2291\u0338", // \not\sqsubseteq
0x22E3: "\u2292\u0338", // \not\sqsupseteq
0x2033: "\u2032\u2032", // double prime
0x2034: "\u2032\u2032\u2032", // triple prime
0x2036: "\u2035\u2035", // double back prime
0x2037: "\u2035\u2035\u2035", // trile back prime
0x2057: "\u2032\u2032\u2032\u2032" // quadruple prime
},
PLANE1MAP: [
@ -495,12 +520,6 @@
TEX.Definitions.mathchar0mi.ell = ['2113',{mathvariant: MML.VARIANT.NORMAL}];
TEX.Definitions.mathchar0mi.hbar = ['210F',{mathvariant: MML.VARIANT.NORMAL}];
TEX.Definitions.mathchar0mi.S = ['00A7',{mathvariant: MML.VARIANT.SCRIPT}];
if (MathJax.Hub.Browser.isOpera) {
TEX.Definitions.macros.not = ['Macro','\\mathrel{\\rlap{\\hphantom{\\mathrel{\\subset}}\\notChar}}'];
} else {
TEX.Definitions.mathchar0mo.notChar = ['002F',{mathvariant: MML.VARIANT.ITALIC}];
TEX.Definitions.macros.not = ['Macro','\\mathrel{\\rlap{\\notChar}}'];
}
});
HTMLCSS.FONTDATA.FONTS['MathJax_Caligraphic'] = {

View File

@ -1247,7 +1247,14 @@
if (variant.remap.variant) {variant = this.FONTDATA.VARIANT[variant.remap.variant]}
}
}
if (this.FONTDATA.REMAP[n] && !variant.noRemap) {n = this.FONTDATA.REMAP[n]}
if (this.FONTDATA.REMAP[n] && !variant.noRemap) {
n = this.FONTDATA.REMAP[n];
if (typeof(n) === "string") {
text = n+text.substr(i+1);
i = 0; m = text.length;
n = n.charCodeAt(0);
}
}
font = this.lookupChar(variant,n); c = font[n]; SPAN = span;
if ((variant !== SPANV || font.family !== span.style.fontFamily) && !c[5].img) {
if (newtext.length) {this.addText(span,newtext); newtext = ""}

View File

@ -69,7 +69,7 @@
offsetG: 0x03B1, variantG: "italic",
remap: {0x391:0x41, 0x392:0x42, 0x395:0x45, 0x396:0x5A, 0x397:0x48,
0x399:0x49, 0x39A:0x4B, 0x39C:0x4D, 0x39D:0x4E, 0x39F:0x4F,
0x3A1:0x50, 0x3A4:0x54, 0x3A7:0x58}},
0x3A1:0x50, 0x3A4:0x54, 0x3A7:0x58, 0x29F8:[0x002F,"italic"]}},
"bold": {fonts:[BOLD,SIZE1,AMS], bold:true,
offsetG: 0x03B1, variantG: "bold-italic",
remap: {0x391:0x41, 0x392:0x42, 0x395:0x45, 0x396:0x5A, 0x397:0x48,
@ -133,7 +133,32 @@
0x2329: 0x27E8, 0x232A: 0x27E9, // langle, rangle
0x3008: 0x27E8, 0x3009: 0x27E9, // langle, rangle
0x2758: 0x2223, // VerticalSeparator
0x2A2F: 0xD7 // cross product
0x2A2F: 0xD7, // cross product
0x2247: 0x2246, // wrong placement of this character
//
// compound symbols not in these fonts
//
0x2204: "\u2203\u0338", // \not\exists
0x220C: "\u220B\u0338", // \not\ni
0x2244: "\u2243\u0338", // \not\cong
0x2249: "\u2248\u0338", // \not\approx
0x2262: "\u2261\u0338", // \not\equiv
0x2274: "\u2272\u0338", // \not\lesssim
0x2275: "\u2273\u0338", // \not\gtrsim
0x2278: "\u2276\u0338", // \not\lessgtr
0x2279: "\u2277\u0338", // \not\gtrless
0x2284: "\u2282\u0338", // \not\subset
0x2285: "\u2283\u0338", // \not\supset
0x22E2: "\u2291\u0338", // \not\sqsubseteq
0x22E3: "\u2292\u0338", // \not\sqsupseteq
0x2033: "\u2032\u2032", // double prime
0x2034: "\u2032\u2032\u2032", // triple prime
0x2036: "\u2035\u2035", // double back prime
0x2037: "\u2035\u2035\u2035", // trile back prime
0x2057: "\u2032\u2032\u2032\u2032" // quadruple prime
},
PLANE1MAP: [
@ -477,12 +502,6 @@
TEX.Definitions.mathchar0mi.ell = ['2113',{mathvariant: MML.VARIANT.NORMAL}];
TEX.Definitions.mathchar0mi.hbar = ['210F',{mathvariant: MML.VARIANT.NORMAL}];
TEX.Definitions.mathchar0mi.S = ['00A7',{mathvariant: MML.VARIANT.SCRIPT}];
if (MathJax.Hub.Browser.isOpera) {
TEX.Definitions.macros.not = ['Macro','\\mathrel{\\rlap{\\hphantom{\\mathrel{\\subset}}\\notChar}}'];
} else {
TEX.Definitions.mathchar0mo.notChar = ['002F',{mathvariant: MML.VARIANT.ITALIC}];
TEX.Definitions.macros.not = ['Macro','\\mathrel{\\rlap{\\notChar}}'];
}
});
SVG.FONTDATA.FONTS['MathJax_Main'] = {

View File

@ -507,7 +507,14 @@
if (variant.remap.variant) {variant = this.FONTDATA.VARIANT[variant.remap.variant]}
}
}
if (this.FONTDATA.REMAP[n] && !variant.noRemap) {n = this.FONTDATA.REMAP[n]}
if (this.FONTDATA.REMAP[n] && !variant.noRemap) {
n = this.FONTDATA.REMAP[n];
if (typeof(n) === "string") {
text = n+text.substr(i+1);
i = 0; m = text.length;
n = n.charCodeAt(0);
}
}
font = this.lookupChar(variant,n); c = font[n];
if (c) {
c = [scale,font.id+"-"+n.toString(16).toUpperCase()].concat(c);