#include "InsetMathPhantom.h"
#include "InsetMathRef.h"
#include "InsetMathRoot.h"
+#include "InsetMathSideset.h"
#include "InsetMathSize.h"
#include "InsetMathSpace.h"
#include "InsetMathSpecialChar.h"
}
+bool canBeDisplayed(char_type c)
+{
+ if (!use_gui)
+ return true;
+ return theFontLoader().canBeDisplayed(c);
+}
+
+
+bool isUnicodeSymbolAvailable(docstring const & name, char_type & c)
+{
+ docstring cmd(from_ascii("\\") + name);
+ bool is_combining;
+ bool termination;
+ c = Encodings::fromLaTeXCommand(cmd, Encodings::MATH_CMD,
+ is_combining, termination);
+ if (c == 0 && name == "varOmega") {
+ // fallback for bug 7954, unicodesymbols does not list
+ // \\varOmega because of requirements, but this might change
+ cmd = from_ascii("\\mathit{\\Omega}");
+ c = Encodings::fromLaTeXCommand(cmd, Encodings::MATH_CMD,
+ is_combining, termination);
+ }
+ return c != 0 && !is_combining;
+}
+
+
void initSymbols()
{
FileName const filename = libFileSearch(string(), "symbols");
// symbol font is not available sometimes
docstring symbol_font = from_ascii("lyxsymbol");
+ char_type unicodesymbol = 0;
if (tmp.extra == "func" || tmp.extra == "funclim" || tmp.extra == "special") {
LYXERR(Debug::MATHED, "symbol abuse for " << to_utf8(tmp.name));
tmp.draw = tmp.name;
- } else if (isMathFontAvailable(tmp.inset)) {
+ } else if (isMathFontAvailable(tmp.inset) && canBeDisplayed(charid)) {
LYXERR(Debug::MATHED, "symbol available for " << to_utf8(tmp.name));
tmp.draw.push_back(char_type(charid));
- } else if (fallbackid && isMathFontAvailable(symbol_font)) {
+ } else if (fallbackid && isMathFontAvailable(symbol_font) &&
+ canBeDisplayed(fallbackid)) {
if (tmp.inset == "cmex")
tmp.inset = from_ascii("lyxsymbol");
else
tmp.inset = from_ascii("lyxboldsymbol");
LYXERR(Debug::MATHED, "symbol fallback for " << to_utf8(tmp.name));
tmp.draw.push_back(char_type(fallbackid));
+ } else if (isUnicodeSymbolAvailable(tmp.name, unicodesymbol)) {
+ LYXERR(Debug::MATHED, "unicode fallback for " << to_utf8(tmp.name));
+ tmp.inset = from_ascii("mathnormal");
+ tmp.draw.push_back(unicodesymbol);
} else {
LYXERR(Debug::MATHED, "faking " << to_utf8(tmp.name));
tmp.draw = tmp.name;
if (inset == "dots")
return MathAtom(new InsetMathDots(l));
if (inset == "mbox")
- // return MathAtom(new InsetMathMBox);
- // InsetMathMBox is proposed to replace InsetMathBox,
- // but is not ready yet (it needs a BufferView for
- // construction)
return MathAtom(new InsetMathBox(buf, l->name));
// if (inset == "fbox")
// return MathAtom(new InsetMathFBox(l));
if (s == "Diagram")
return MathAtom(new InsetMathDiagram(buf));
- if (s == "xrightarrow" || s == "xleftarrow")
+ if (s == "xrightarrow" || s == "xleftarrow" ||
+ s == "xhookrightarrow" || s == "xhookleftarrow" ||
+ s == "xRightarrow" || s == "xLeftarrow" ||
+ s == "xleftrightarrow" || s == "xLeftrightarrow" ||
+ s == "xrightharpoondown" || s == "xrightharpoonup" ||
+ s == "xleftharpoondown" || s == "xleftharpoonup" ||
+ s == "xleftrightharpoons" || s == "xrightleftharpoons" ||
+ s == "xmapsto")
return MathAtom(new InsetMathXArrow(buf, s));
if (s == "split" || s == "alignedat")
return MathAtom(new InsetMathSplit(buf, s));
return MathAtom(new InsetMathCancelto(buf));
if (s == "smash")
return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::smash));
+ // The following 2 string values are only for math toolbar use, no LaTeX names
+ if (s == "smashb")
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::smashb));
+ if (s == "smasht")
+ return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::smasht));
if (s == "mathclap")
return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::mathclap));
if (s == "mathllap")
return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::mathrlap));
if (s == "ensuremath")
return MathAtom(new InsetMathEnsureMath(buf));
+ if (s == "sideset")
+ return MathAtom(new InsetMathSideset(buf, true, true));
+ // The following 3 string values are only for math toolbar use, no LaTeX names
+ if (s == "sidesetr")
+ return MathAtom(new InsetMathSideset(buf, false, true));
+ if (s == "sidesetl")
+ return MathAtom(new InsetMathSideset(buf, true, false));
+ if (s == "sidesetn")
+ return MathAtom(new InsetMathSideset(buf, false, false));
if (isSpecialChar(s))
return MathAtom(new InsetMathSpecialChar(s));
if (s == " ")