|
766 | 766 |
|
767 | 767 | /********************************************************/
|
768 | 768 |
|
| 769 | + // |
| 770 | + // True if text holds a single (unicode) glyph |
| 771 | + // |
| 772 | + isChar: function (text) { |
| 773 | + if (text.length === 1) return true; |
| 774 | + if (text.length !== 2) return false; |
| 775 | + var n = text.charCodeAt(0); |
| 776 | + return (n >= 0xD800 && n < 0xDBFF); |
| 777 | + }, |
769 | 778 | //
|
770 | 779 | // Get a unicode character by number (even when it takes two character)
|
771 | 780 | //
|
|
1874 | 1883 | toCommonHTML: function (node) {
|
1875 | 1884 | node = this.CHTMLdefaultNode(node);
|
1876 | 1885 | var bbox = this.CHTML, text = this.data.join("");
|
1877 |
| - if (bbox.skew != null && text.length !== 1) delete bbox.skew; |
1878 |
| - if (bbox.r > bbox.w && text.length === 1 && !this.CHTMLvariant.noIC) { |
| 1886 | + if (bbox.skew != null && !CHTML.isChar(text)) delete bbox.skew; |
| 1887 | + if (bbox.r > bbox.w && CHTML.isChar(text) && !this.CHTMLvariant.noIC) { |
1879 | 1888 | bbox.ic = bbox.r - bbox.w; bbox.w = bbox.r;
|
1880 | 1889 | node.lastChild.style.paddingRight = CHTML.Em(bbox.ic);
|
1881 | 1890 | }
|
|
1890 | 1899 | toCommonHTML: function (node) {
|
1891 | 1900 | node = this.CHTMLdefaultNode(node,{childOptions:{remap:this.CHTMLremapMinus}});
|
1892 | 1901 | var bbox = this.CHTML, text = this.data.join("");
|
1893 |
| - if (bbox.skew != null && text.length !== 1) delete bbox.skew; |
1894 |
| - if (bbox.r > bbox.w && text.length === 1 && !this.CHTMLvariant.noIC) { |
| 1902 | + if (bbox.skew != null && !CHTML.isChar(text)) delete bbox.skew; |
| 1903 | + if (bbox.r > bbox.w && CHTML.isChar(text) && !this.CHTMLvariant.noIC) { |
1895 | 1904 | bbox.ic = bbox.r - bbox.w; bbox.w = bbox.r;
|
1896 | 1905 | node.lastChild.style.paddingRight = CHTML.Em(bbox.ic);
|
1897 | 1906 | }
|
|
1925 | 1934 | remapchars: values.remapchars
|
1926 | 1935 | }});
|
1927 | 1936 | }
|
1928 |
| - if (values.text.length !== 1) delete this.CHTML.skew; |
| 1937 | + if (!CHTML.isChar(values.text)) delete this.CHTML.skew; |
1929 | 1938 | else if (this.CHTML.w === 0 && this.CHTML.l < 0) this.CHTMLfixCombiningChar(node);
|
1930 | 1939 | if (values.largeop) this.CHTMLcenterOp(node);
|
1931 | 1940 | }
|
|
1958 | 1967 | },
|
1959 | 1968 | CHTMLadjustAccent: function (data) {
|
1960 | 1969 | var parent = this.CoreParent(); data.parent = parent;
|
1961 |
| - if (data.text.length === 1 && parent && parent.isa(MML.munderover)) { |
| 1970 | + if (CHTML.isChar(data.text) && parent && parent.isa(MML.munderover)) { |
1962 | 1971 | var over = parent.data[parent.over], under = parent.data[parent.under];
|
1963 | 1972 | if (over && this === over.CoreMO() && parent.Get("accent")) {
|
1964 | 1973 | data.remapchars = CHTML.FONTDATA.REMAPACCENT;
|
|
1998 | 2007 | },
|
1999 | 2008 | CHTMLcanStretch: function (direction,H,D) {
|
2000 | 2009 | if (!this.Get("stretchy")) return false;
|
2001 |
| - var c = this.data.join(""); if (c.length !== 1) return false; |
| 2010 | + var c = this.data.join(""); if (!CHTML.isChar(c)) return false; |
2002 | 2011 | var values = {text: c};
|
2003 | 2012 | this.CHTMLadjustAccent(values);
|
2004 | 2013 | if (values.remapchars) c = values.remapchars[c]||c;
|
|
2469 | 2478 | if (bmml) {
|
2470 | 2479 | if ((bmml.type === "mrow" || bmml.type === "mstyle") && bmml.data.length === 1) bmml = bmml.data[0];
|
2471 | 2480 | if (bmml.type === "mi" || bmml.type === "mo") {
|
2472 |
| - if (bmml.data.join("").length === 1 && bbox.rscale === 1 && !bbox.sH && |
| 2481 | + if (CHTML.isChar(bmml.data.join("")) && bbox.rscale === 1 && !bbox.sH && |
2473 | 2482 | !bmml.Get("largeop")) {u = v = 0}
|
2474 | 2483 | }
|
2475 | 2484 | }
|
|
0 commit comments