Handle pseudo-scripts better (don't translate <mo>'s that aren't in superscripts, and do translate the ones that are)

This commit is contained in:
Davide P. Cervone 2012-01-14 20:30:13 -05:00
parent 65892262ac
commit db55f22ba7
8 changed files with 38 additions and 16 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

View File

@ -1858,8 +1858,13 @@
var values = this.getValues("largeop","displaystyle");
if (values.largeop)
{variant = HTMLCSS.FONTDATA.VARIANT[values.displaystyle ? "-largeOp" : "-smallOp"]}
var parent = this.Parent(),
isScript = (parent.isa(MML.msubsup) && this !== parent.data[0]),
mapchars = (isScript?this.HTMLremapChars:null);
if (isScript && HTMLCSS.fontInUse === "STIX" && text.match(/['`"\u00B4]/))
{variant = HTMLCSS.FONTDATA.VARIANT["-STIX-variant"]}
for (var i = 0, m = this.data.length; i < m; i++)
{if (this.data[i]) {this.data[i].toHTML(span,variant,this.HTMLremap,this.HTMLremapChars)}}
{if (this.data[i]) {this.data[i].toHTML(span,variant,this.HTMLremap,mapchars)}}
if (!span.bbox) {span.bbox = {w:0, h:0, d:0, rw:0, lw:0}}
if (text.length !== 1) {delete span.bbox.skew}
if (HTMLCSS.AccentBug && span.bbox.w === 0 && text.length === 1 && span.firstChild) {
@ -1891,13 +1896,20 @@
return span;
},
HTMLremapChars: {
'-':"\u2212",
'*':"\u2217",
'"':"\u2033"
'"':"\u2033",
"\u00B0":"\u2218",
"\u00B2":"2",
"\u00B3":"3",
"\u00B4":"\u2032",
"\u00B9":"1"
},
HTMLremap: function (text,map) {
text = text.replace(/'/g,"\u2032");
if (text.length === 1) {text = map[text]||text}
text = text.replace(/-/g,"\u2212");
if (map) {
text = text.replace(/'/g,"\u2032").replace(/`/g,"\u2035");
if (text.length === 1) {text = map[text]||text}
}
return text;
},
HTMLcanStretch: function (direction) {

View File

@ -1224,9 +1224,12 @@
var values = this.getValues("largeop","displaystyle");
if (values.largeop)
{variant = SVG.FONTDATA.VARIANT[values.displaystyle ? "-largeOp" : "-smallOp"]}
var parent = this.Parent(),
isScript = (parent.isa(MML.msubsup) && this !== parent.data[0]),
mapchars = (isScript?this.SVGremapChars:null);
for (var i = 0, m = this.data.length; i < m; i++) {
if (this.data[i]) {
var text = this.data[i].toSVG(variant,scale,this.SVGremap,this.SVGremapChars), x = svg.w;
var text = this.data[i].toSVG(variant,scale,this.SVGremap,mapchars), x = svg.w;
if (x === 0 && -text.l > 10*text.w) {x += -text.l} // initial combining character doesn't combine
svg.Add(text,x,0,true);
if (text.skew) {svg.skew = text.skew}
@ -1243,13 +1246,20 @@
return svg;
},
SVGremapChars: {
'-':"\u2212",
'*':"\u2217",
'"':"\u2033"
'"':"\u2033",
"\u00B0":"\u2218",
"\u00B2":"2",
"\u00B3":"3",
"\u00B4":"\u2032",
"\u00B9":"1"
},
SVGremap: function (text,map) {
text = text.replace(/'/g,"\u2032");
if (text.length === 1) {text = map[text]||text}
text = text.replace(/-/g,"\u2212");
if (map) {
text = text.replace(/'/g,"\u2032").replace(/`/g,"\u2035");
if (text.length === 1) {text = map[text]||text}
}
return text;
},
SVGcanStretch: function (direction) {