From 01b6d7cee6246848d2493bc8c7b578e82c269ee1 Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sun, 30 Jun 2019 17:34:41 +0200 Subject: [PATCH] JKQTMathText: improved font-handling system + new fraktur and caligraphic, as well as special math sans/serif fonts-classes --- appveyor.yml | 22 +- examples/jkqtmathtext_test/testform.cpp | 101 +- examples/jkqtmathtext_test/testform.ui | 825 ++++---- lib/jkqtcommon/jkqtpmathparser.cpp | 20 +- lib/jkqtmathtext/jkqtmathtext.cpp | 2311 ++++++++++++++--------- lib/jkqtmathtext/jkqtmathtext.h | 857 +++------ 6 files changed, 2270 insertions(+), 1866 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3ee2b17c59..8dd55c28b1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,23 +17,23 @@ environment: CMAKE_GENERATOR: "MinGW Makefiles" USE_CMAKE: true MSBUILD_FLAGS: -# - QTABI: mingw53_32 -# ARCH: x86 -# QMAKESPEC: win32-g++ -# MAKETOOL: mingw32-make -# USE_CMAKE: false + - QTABI: mingw53_32 + ARCH: x86 + QMAKESPEC: win32-g++ + MAKETOOL: mingw32-make + USE_CMAKE: false - QTABI: msvc2017_64 ARCH: x64 VSVER: 2017 CMAKE_GENERATOR: "Visual Studio 15 2017 Win64" USE_CMAKE: true MSBUILD_FLAGS: /verbosity:minimal /maxcpucount -# - QTABI: msvc2017_64 -# ARCH: x64 -# VSVER: 2017 -# QMAKESPEC: win32-msvc -# MAKETOOL: jom -# USE_CMAKE: false + - QTABI: msvc2017_64 + ARCH: x64 + VSVER: 2017 + QMAKESPEC: win32-msvc + MAKETOOL: jom + USE_CMAKE: false - QTABI: msvc2015 ARCH: x86 VSVER: 14 diff --git a/examples/jkqtmathtext_test/testform.cpp b/examples/jkqtmathtext_test/testform.cpp index 1e83ac55f6..2062e98f30 100644 --- a/examples/jkqtmathtext_test/testform.cpp +++ b/examples/jkqtmathtext_test/testform.cpp @@ -8,6 +8,8 @@ TestForm::TestForm(QWidget *parent) : ui(new Ui::TestForm) { ui->setupUi(this); + ui->cmbTestset->addItem("fonts", "rm: \\textrm{ABCabc123}, sf: \\textsf{ABCabc123}, tt: \\texttt{ABCabc123}, cal: \\textcal{ABCabc123}, scr: \\textscr{ABCabc123}, bb: \\textbb{ABCabc123}, frak: \\textfrak{ABCabc123}, "); + ui->cmbTestset->addItem("math-fonts", "rm: $\\mathrm{ABCabc123}$, sf: $\\mathsf{ABCabc123}$, tt: $\\mathtt{ABCabc123}$, cal: $\\mathcal{ABCabc123}$, scr: $\\mathscr{ABCabc123}$, bb: $\\mathbb{ABCabc123}$, frak: $\\mathfrak{ABCabc123}$, "); ui->cmbTestset->addItem("simple relations", "$a{\\leq}b$, $a{\\geq}b$, $a{\\equiv}b$, $a=b$, $a{\\neq}b$, $ab$"); ui->cmbTestset->addItem("simple relations in different modes", "math: $a{\\leq}b$, math/no braces: $a\\leq b$, no math: a{\\leq}b, no math/no braces: a\\leq b"); ui->cmbTestset->addItem("named symbols 1", "ll: $\\ll$\\ gg: $\\gg$\\ leq: $\\leq$\\ geq: $\\geq$\\ pm: $\\pm$\\ mp: $\\mp$\\ "); @@ -40,15 +42,19 @@ TestForm::TestForm(QWidget *parent) : ui->cmbTestset->addItem("math: blackboard", "$\\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("math: bf", "$\\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("math: it", "$\\mathit{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); + ui->cmbTestset->addItem("math: frak", "$\\mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("math: sf", "$\\mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("math: rm", "$\\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("math: cal", "$\\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); + ui->cmbTestset->addItem("math: script", "$\\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("math: tt", "$\\mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("bf", "\\textbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}"); ui->cmbTestset->addItem("it", "\\textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}"); + ui->cmbTestset->addItem("frak", "\\textfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}"); ui->cmbTestset->addItem("sf", "\\textsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}"); ui->cmbTestset->addItem("rm", "\\textrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}"); ui->cmbTestset->addItem("cal", "\\textcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}"); + ui->cmbTestset->addItem("script", "\\textscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}"); ui->cmbTestset->addItem("tt", "\\texttt{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}"); ui->cmbTestset->addItem("subscript test", "$r_{123}\\ \\ r_{\\frac{1}{2}}$"); ui->cmbTestset->addItem("subscript0 test", "$r_{123}$"); @@ -143,10 +149,74 @@ TestForm::TestForm(QWidget *parent) : //ui->cmbTestset->addItem("", "$$"); //ui->cmbTestset->addItem("", "$$"); //ui->cmbTestset->addItem("", ""); + + JKQTMathText mt(this); + ui->cmbUnicodeSerif->setCurrentFont(QFont(mt.getFontRoman())); + ui->cmbEncodingSerif->setCurrentIndex(static_cast(mt.getFontEncodingRoman())); + ui->cmbUnicodeSans->setCurrentFont(QFont(mt.getFontSans())); + ui->cmbEncodingSans->setCurrentIndex(static_cast(mt.getFontEncodingSans())); + ui->cmbUnicodeSerifMath->setCurrentFont(QFont(mt.getFontMathRoman())); + ui->cmbEncodingSerifMath->setCurrentIndex(static_cast(mt.getFontEncodingMathRoman())); + ui->cmbUnicodeSansMath->setCurrentFont(QFont(mt.getFontMathSans())); + ui->cmbEncodingSansMath->setCurrentIndex(static_cast(mt.getFontEncodingMathSans())); + ui->cmbUnicodeFixed->setCurrentFont(QFont(mt.getFontTypewriter())); + ui->cmbEncodingTypewriter->setCurrentIndex(static_cast(mt.getFontEncodingTypewriter())); + ui->cmbCaligraphic->setCurrentFont(QFont(mt.getFontCaligraphic())); + ui->cmbEncodingCaligraphic->setCurrentIndex(static_cast(mt.getFontEncodingCaligraphic())); + ui->cmbScript->setCurrentFont(QFont(mt.getFontScript())); + ui->cmbEncodingScript->setCurrentIndex(static_cast(mt.getFontEncodingScript())); + ui->cmbUnicodeFraktur->setCurrentFont(QFont(mt.getFontFraktur())); + ui->cmbEncodingFraktur->setCurrentIndex(static_cast(mt.getFontEncodingFraktur())); + ui->cmbUnicodeBlackboard->setCurrentFont(QFont(mt.getFontBlackboard())); + ui->cmbEncodingBlackboard->setCurrentIndex(static_cast(mt.getFontEncodingBlackboard())); + ui->cmbUnicodeSymbol->setCurrentFont(QFont(mt.getSymbolfontSymbol(JKQTMathText::MTenvironmentFont::MTEroman))); + ui->cmbEncodingSymbol->setCurrentIndex(static_cast(mt.getSymbolfontEncodingSymbol(JKQTMathText::MTenvironmentFont::MTEroman))); + ui->cmbUnicodeGreek->setCurrentFont(QFont(mt.getSymbolfontGreek(JKQTMathText::MTenvironmentFont::MTEroman))); + ui->cmbEncodingGreek->setCurrentIndex(static_cast(mt.getSymbolfontEncodingGreek(JKQTMathText::MTenvironmentFont::MTEroman))); + ui->chkSimulateBlackboard->setChecked(mt.isFontBlackboardSimulated()); + + + + ui->cmbTestset->setCurrentIndex(0); ui->labMath->setMath("\\left(\\left[\\sqrt{2\\pi\\cdot\\int_{-\\infty}^\\infty f(x)\\;\\mathrm{d}x}\\right]\\right)"); ui->cmbFont->setCurrentIndex(1); + + connect(ui->chkBoxes, SIGNAL(toggled(bool)), this, SLOT(updateMath())); + connect(ui->chkAntiAlias, SIGNAL(toggled(bool)), this, SLOT(updateMath())); + connect(ui->chkAntiAliasHQ, SIGNAL(toggled(bool)), this, SLOT(updateMath())); + connect(ui->chkAntiAliasText, SIGNAL(toggled(bool)), this, SLOT(updateMath())); + connect(ui->chkSmoothTransform, SIGNAL(toggled(bool)), this, SLOT(updateMath())); + connect(ui->chkSimulateBlackboard, SIGNAL(toggled(bool)), this, SLOT(updateMath())); + connect(ui->cmbFont, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbScript, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbTestset, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbCaligraphic, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbUnicodeSans, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbUnicodeSansMath, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingSans, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingSansMath, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbUnicodeFixed, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbUnicodeGreek, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbUnicodeSerif, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbUnicodeSerifMath, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingGreek, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingSerif, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingSerifMath, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbUnicodeSymbol, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingScript, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingSymbol, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbUnicodeFraktur, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingFraktur, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbUnicodeBlackboard, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingBlackboard, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingTypewriter, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->cmbEncodingCaligraphic, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath())); + connect(ui->edtSizes, SIGNAL(textChanged(QString)), this, SLOT(updateMath())); + + + updateMath(); } TestForm::~TestForm() @@ -266,7 +336,7 @@ QTreeWidgetItem *TestForm::createTree(JKQTMathText::MTnode *node, QTreeWidgetIte ti->addChild(createTree(list[i], ti)); } } else if (symN) { - name=QString("MTsymbolNode: \'%1\' (%2)").arg(symN->getSymbolName()).arg(symN->getSymbolFontName()); + name=QString("MTsymbolNode: \'%1\' (addWhite: %2)").arg(symN->getSymbolName()).arg(symN->getAddWhitespace()); } else if (spN) { name=QString("MTwhitespaceNode :\'%1\'").arg(txtN->getText()); } else if (txtN) { @@ -335,21 +405,22 @@ void TestForm::updateMath() - mt.setFontRoman(ui->cmbUnicodeSerif->currentFont().family()); - mt.setFontSans(ui->cmbUnicodeSans->currentFont().family()); - mt.setFontTypewriter(ui->cmbUnicodeFixed->currentFont().family()); - mt.setFontSymbol(ui->cmbUnicodeSymbol->currentFont().family()); - mt.setFontCaligraphic(ui->cmbCaligraphic->currentFont().family()); + mt.setFontRoman(ui->cmbUnicodeSerif->currentFont().family(), static_cast(ui->cmbEncodingSerif->currentIndex())); + mt.setFontSans(ui->cmbUnicodeSans->currentFont().family(), static_cast(ui->cmbEncodingSans->currentIndex())); + mt.setFontMathRoman(ui->cmbUnicodeSerifMath->currentFont().family(), static_cast(ui->cmbEncodingSerifMath->currentIndex())); + mt.setFontMathSans(ui->cmbUnicodeSansMath->currentFont().family(), static_cast(ui->cmbEncodingSansMath->currentIndex())); + mt.setFontTypewriter(ui->cmbUnicodeFixed->currentFont().family(), static_cast(ui->cmbEncodingTypewriter->currentIndex())); + mt.setFontCaligraphic(ui->cmbCaligraphic->currentFont().family(), static_cast(ui->cmbEncodingCaligraphic->currentIndex())); + mt.setFontScript(ui->cmbScript->currentFont().family(), static_cast(ui->cmbEncodingScript->currentIndex())); + mt.setFontFraktur(ui->cmbUnicodeFraktur->currentFont().family(), static_cast(ui->cmbEncodingFraktur->currentIndex())); + mt.setFontBlackboard(ui->cmbUnicodeBlackboard->currentFont().family(), static_cast(ui->cmbEncodingBlackboard->currentIndex())); + mt.setSymbolfontSymbol(ui->cmbUnicodeSymbol->currentFont().family(), static_cast(ui->cmbEncodingSymbol->currentIndex())); + mt.setSymbolfontGreek(ui->cmbUnicodeGreek->currentFont().family(), static_cast(ui->cmbEncodingGreek->currentIndex())); + mt.setFontBlackboardSimulated(ui->chkSimulateBlackboard->isChecked()); - switch (ui->cmbFont->currentIndex()) { - case 1: mt.useXITS(); break; - case 2: mt.useSTIX(); break; - case 3: mt.useAnyUnicode(ui->cmbUnicodeSerif->currentFont().family(),ui->cmbUnicodeSans->currentFont().family(), false); break; - case 4: mt.useAnyUnicode(ui->cmbUnicodeSerif->currentFont().family(),ui->cmbUnicodeSans->currentFont().family(), true); break; - case 5: mt.useLatexFonts(ui->edtLatexPrefix->text(), ui->edtLatexPostfix->text()); break; - case 6: mt.useASANA(); break; - - } + if (ui->cmbFont->currentIndex()==1) qDebug()<<"useXITS: "<cmbFont->currentIndex()==2) qDebug()<<"useSTIX: "<cmbFont->currentIndex()==3) qDebug()<<"useASANA: "<tree->clear(); ht.start(); diff --git a/examples/jkqtmathtext_test/testform.ui b/examples/jkqtmathtext_test/testform.ui index cfb9894e2b..38a10f8a0e 100644 --- a/examples/jkqtmathtext_test/testform.ui +++ b/examples/jkqtmathtext_test/testform.ui @@ -6,7 +6,7 @@ 0 0 - 1518 + 1523 742 @@ -24,8 +24,8 @@ 0 0 - 745 - 616 + 748 + 538 @@ -89,37 +89,22 @@ - Symbol + Below - XITS + Below+Math: XITS - STIX + Below+Math: STIX - Unicode, limited - - - - - Unicode, full - - - - - LaTeX - - - - - ASANA + Below+Math: ASANA @@ -278,101 +263,15 @@ - - - - - latex prefix/postfix: - - - - - - - - - - + + - Symbol/Unicode fonts: rm: + Symbol/Unicode fonts: - - - - - Times New Roman - - - - - - - - sf: - - - - - - - - Arial - - - - - - - - tt: - - - - - - - - Courier New - - - - - - - - cal: - - - - - - - - Script - - - - - - - - symbol font: - - - - - - - - Symbol - - - - - + Qt::Horizontal @@ -385,6 +284,480 @@ + + + + blackboard: + + + + + + + symbol: + + + + + + + + Times New Roman + + + + + + + + + Times New Roman + + + + + + + + roman: + + + + + + + + Symbol + + + + + + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + + + + + sans: + + + + + + + 1 + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + + + + + 2 + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + + + + + 2 + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + + + + + + Symbol + + + + + + + + + Arial + + + + + + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + + + + + greek: + + + + + + + simulate blackboard + + + + + + + fraktur: + + + + + + + + Times New Roman + + + + + + + + 1 + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + + + + + caligraphic: + + + + + + + + Script + + + + + + + + 3 + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + + + + + script: + + + + + + + + Script + + + + + + + + 3 + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + + + + + typewriter: + + + + + + + + Courier New + + + + + + + + 3 + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + + + + + math- roman: + + + + + + + + Times New Roman + + + + + + + + 2 + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + + + + + math-sans: + + + + + + + + Arial + + + + + + + + 2 + + + + WinSymbol + + + + + Unicode + + + + + Unicode Limited + + + + + Standard + + + + @@ -460,230 +833,6 @@ - - cmbTestset - currentIndexChanged(int) - TestForm - updateMath() - - - 130 - 20 - - - 421 - 36 - - - - - cmbFont - currentIndexChanged(int) - TestForm - updateMath() - - - 328 - 29 - - - 423 - 89 - - - - - chkBoxes - clicked() - TestForm - updateMath() - - - 790 - 27 - - - 424 - 187 - - - - - chkAntiAlias - clicked() - TestForm - updateMath() - - - 868 - 27 - - - 422 - 220 - - - - - chkAntiAliasHQ - clicked() - TestForm - updateMath() - - - 964 - 27 - - - 423 - 259 - - - - - chkAntiAliasText - clicked() - TestForm - updateMath() - - - 1067 - 27 - - - 424 - 302 - - - - - edtSizes - textChanged(QString) - TestForm - updateMath() - - - 679 - 29 - - - 422 - 160 - - - - - edtLatexPrefix - textChanged(QString) - TestForm - updateMath() - - - 141 - 48 - - - 520 - 140 - - - - - edtLatexPostfix - textChanged(QString) - TestForm - updateMath() - - - 200 - 49 - - - 519 - 118 - - - - - cmbUnicodeSerif - currentFontChanged(QFont) - TestForm - updateMath() - - - 416 - 54 - - - 519 - 201 - - - - - cmbUnicodeSans - currentFontChanged(QFont) - TestForm - updateMath() - - - 553 - 45 - - - 518 - 175 - - - - - cmbUnicodeFixed - currentFontChanged(QFont) - TestForm - updateMath() - - - 949 - 57 - - - 518 - 236 - - - - - cmbUnicodeSymbol - currentFontChanged(QFont) - TestForm - updateMath() - - - 1221 - 57 - - - 520 - 288 - - - - - chkSmoothTransform - clicked() - TestForm - updateMath() - - - 1181 - 27 - - - 519 - 317 - - - btnRender clicked() @@ -691,8 +840,8 @@ updateMath() - 1187 - 83 + 1512 + 163 617 diff --git a/lib/jkqtcommon/jkqtpmathparser.cpp b/lib/jkqtcommon/jkqtpmathparser.cpp index 75faf90875..8ac3b93bf6 100644 --- a/lib/jkqtcommon/jkqtpmathparser.cpp +++ b/lib/jkqtcommon/jkqtpmathparser.cpp @@ -35,15 +35,11 @@ #define JKQTPPATHSEPARATOR_STRING "\\" /** \brief a separator between two directories in a path between \c ' quotes */ #define JKQTPPATHSEPARATOR_CHAR '\\' - #include - #include #else /** \brief a separator between two directories in a path between \c " quotes */ #define JKQTPPATHSEPARATOR_STRING "/" /** \brief a separator between two directories in a path between \c ' quotes */ #define JKQTPPATHSEPARATOR_CHAR '/' - #include - #include #endif @@ -1013,8 +1009,8 @@ JKQTPMathParser::jkmpEvaluateFunc JKQTPMathParser::getFunctionDef(const std::str bool JKQTPMathParser::tempvariableExists(const std::string &name){ if (tempvariables.size()<=0) return false; - for (int i=tempvariables.size()-1; i>=0; i--) { - if (tempvariables[i].name==name) return true; + for (int i=static_cast(tempvariables.size())-1; i>=0; i--) { + if (tempvariables[static_cast(i)].name==name) return true; } return false; } @@ -1807,14 +1803,20 @@ JKQTPMathParser::jkmpResult JKQTPMathParser::jkmpNodeList::evaluate(){ return res; } -int JKQTPMathParser::jkmpNodeList::getCount() {return list.size();} +int JKQTPMathParser::jkmpNodeList::getCount() { + return static_cast(list.size()); +} -JKQTPMathParser::jkmpNodeList::jkmpNodeList(JKQTPMathParser *p) { setParser(p); setParent(nullptr); } +JKQTPMathParser::jkmpNodeList::jkmpNodeList(JKQTPMathParser *p) { + setParser(p); setParent(nullptr); +} JKQTPMathParser::jkmpNodeList::~jkmpNodeList() = default; -JKQTPMathParser::jkmpVariableAssignNode::~jkmpVariableAssignNode() {delete child;} +JKQTPMathParser::jkmpVariableAssignNode::~jkmpVariableAssignNode() { + delete child; +} JKQTPMathParser::jkmpVariableAssignNode::jkmpVariableAssignNode(const std::string& var, JKQTPMathParser::jkmpNode* c, JKQTPMathParser* p, JKQTPMathParser::jkmpNode* par){ child=c; diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index e4e9d0b012..4927a6e421 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -29,21 +29,6 @@ #include #include -/** - * \brief saves the given property (for which also a default_property exists) into the given settings object - * \ingroup jkqtmathtext - * \internal - */ -#define JKQTMTPROPERTYsave(settings, group, var, varname) \ - if (var!=default_##var) settings.setValue(group+varname, var); -/** - * \brief loads the given property from the given settings object - * \ingroup jkqtmathtext - * \internal - */ -#define JKQTMTPROPERTYload(settings, group, var, varname, varconvert) \ - var=settings.value(group+varname, var).varconvert; - const double JKQTMathText::ABS_MIN_LINEWIDTH=0.02; QPainterPath makeHBracePath(double x, double ybrace, double width, double bw, double cubicshrink=0.5, double cubiccontrolfac=0.3) { @@ -140,16 +125,26 @@ JKQTMathText::MTenvironment::MTenvironment() { QFont JKQTMathText::MTenvironment::getFont(JKQTMathText* parent) const { QFont f; switch (font) { - case MTEsans: + case MTEsans: if (insideMath) { + f.setFamily(parent->getFontMathSans()); + } else { f.setFamily(parent->getFontSans()); - break; + } + break; + case MTEmathSans: f.setFamily(parent->getFontMathSans()); break; case MTEtypewriter: f.setFamily(parent->getFontTypewriter()); break; case MTEscript: f.setFamily(parent->getFontScript()); break; - case MTEroman: - f.setFamily(parent->getFontRoman()); - break; case MTEcaligraphic: f.setFamily(parent->getFontCaligraphic()); break; case MTEblackboard: f.setFamily(parent->getFontBlackboard()); break; + case MTEfraktur: f.setFamily(parent->getFontFraktur()); break; + case MTEmathRoman: f.setFamily(parent->getFontMathRoman()); break; + default: + case MTEroman: if (insideMath) { + f.setFamily(parent->getFontMathRoman()); + } else { + f.setFamily(parent->getFontRoman()); + } + break; }; f.setBold(bold); f.setItalic(italic); @@ -273,7 +268,7 @@ void JKQTMathText::MTtextNode::getSizeInternal(QPainter& painter, JKQTMathText:: text==QString(QChar(0x2329)) || text==QString(QChar(0x232A)) || text==QString(QChar(0x2308)) || text==QString(QChar(0x2309)) || text==QString(QChar(0x230A)) || text==QString(QChar(0x230B)))) { f.setItalic(false); - f.setFamily(parent->getFontBraces()); + //f.setFamily(parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Text).first); } QString txt=textTransform(text, currentEv, true); QFontMetricsF fm(f, painter.device()); @@ -325,9 +320,8 @@ double JKQTMathText::MTtextNode::draw(QPainter& painter, double x, double y, JKQ if (currentEv.insideMath && (text=="(" || text=="[" || text=="|" || text=="]" || text==")" || text=="<" || text==">" || text==QString(QChar(0x2329)) || text==QString(QChar(0x232A)) || text==QString(QChar(0x2308)) || text==QString(QChar(0x2309)) || text==QString(QChar(0x230A)) || text==QString(QChar(0x230B)))) { - f.setItalic(false); - f.setFamily(parent->getFontBraces()); - } + f.setItalic(false); + } if (onlyDigits && currentEv.insideMath) { @@ -336,6 +330,8 @@ double JKQTMathText::MTtextNode::draw(QPainter& painter, double x, double y, JKQ painter.setFont(f); + //qDebug()<<"MTtextNode: text="<getFontEncoding()==MTFEunicode) { - txt=""; - for (int i=0; ichild; +} + bool JKQTMathText::MTsubscriptNode::toHtml(QString &html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) { html=html+""; @@ -723,6 +728,14 @@ QString JKQTMathText::MTsqrtNode::getTypeName() const return "MTsqrtNode"; } +JKQTMathText::MTnode *JKQTMathText::MTsqrtNode::getChild() const { + return this->child; +} + +int JKQTMathText::MTsqrtNode::getDegree() const { + return this->degree; +} + @@ -936,6 +949,18 @@ void JKQTMathText::MTfracNode::setDrawBoxes(bool draw) } +JKQTMathText::MTnode *JKQTMathText::MTfracNode::getChild1() const { + return this->child1; +} + +JKQTMathText::MTnode *JKQTMathText::MTfracNode::getChild2() const { + return this->child2; +} + +JKQTMathText::MTfracMode JKQTMathText::MTfracNode::getMode() const { + return this->mode; +} + @@ -1077,6 +1102,18 @@ bool JKQTMathText::MTmatrixNode::toHtml(QString &/*html*/, JKQTMathText::MTenvir return false; } +QVector > JKQTMathText::MTmatrixNode::getChildren() const { + return this->children; +} + +int JKQTMathText::MTmatrixNode::getColumns() const { + return this->columns; +} + +int JKQTMathText::MTmatrixNode::getLines() const { + return this->lines; +} + void JKQTMathText::MTmatrixNode::setDrawBoxes(bool draw) { this->drawBoxes=draw; @@ -1251,6 +1288,14 @@ QString JKQTMathText::MTdecoratedNode::getTypeName() const return "MTdecoratedNode"; } +JKQTMathText::MTnode *JKQTMathText::MTdecoratedNode::getChild() const { + return this->child; +} + +JKQTMathText::MTdecoration JKQTMathText::MTdecoratedNode::getDecoration() const { + return this->decoration; +} + @@ -1307,6 +1352,10 @@ double JKQTMathText::MTsuperscriptNode::draw(QPainter& painter, double x, double return child->draw(painter, xx, y-yshift, ev);//+0.5*fm.boundingRect("A").width(); } +JKQTMathText::MTnode *JKQTMathText::MTsuperscriptNode::getChild() const { + return this->child; +} + QString JKQTMathText::MTsuperscriptNode::getTypeName() const { @@ -2000,99 +2049,167 @@ QList JKQTMathText::MTlistNode::getNodes() const { -JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& name, bool addWhitespace): - JKQTMathText::MTnode(parent) +JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& name, bool _addWhitespace): + JKQTMathText::MTnode(parent), symbolName(name), addWhitespace(_addWhitespace) { - double mathFontFactor=1.8; - symbol = ""; - symbolName=name; - fontFactor=1.0; - bold=0; - italic=-1; - yfactor=0; - QString n=name; - drawBar=false; - font=MTSFdefault; - heightIsAscent=false; - exactAscent=false; - extendWidthInMathmode=false; +} - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // statische Lookup-Tabellen vorbereiten - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - static QStringList extendWInMM; - if (extendWInMM.isEmpty()) { - extendWInMM <<"ll"<<"gg"<<"leq"<<"geq"<<"leftrightarrow"<<"leftarrow"<<"rightarrow"<<"to"<<"uparrow"<<"downarrow"<<"updownarrow"<<"Leftrightarrow" - <<"iff"<<"Leftarrow"<<"Rightarrow"<<"Uparrow"<<"Downarrow"<<"Updownarrow"<<"pm"<<"mp"<<"nexists"<<"ni"<<"notni"<<"circ"<<"sim"<<"emptyset"<<"odot"<<"ominus" - <<"subsetnot"<<"bot"<<"leftharpoonup"<<"rightharpoonup"<<"upharpoonleft"<<"downharpoonleft"<<"leftrightharpoon"<<"rightleftharpoon"<<"coprod"<<"leftharpoondown" - <<"rightharpoondown"<<"upharpoonright"<<"downharpoonright"<<"nwarrow"<<"nearrow"<<"searrow"<<"swarrow"<<"mapsto"<<"div"<<"multimap"<<"maporiginal"<<"mapimage" - <<"times"<<"propto"<<"bullet"<<"neq"<<"ne"<<"equiv"<<"approx"<<"otimes"<<"oplus"<<"oslash"<<"cap"<<"land"<<"cup"<<"lor"<<"supset"<<"supseteq"<<"supsetnot" - <<"subset"<<"subseteq"<<"in"<<"notin"<<"cdot"<<"wedge"<<"vee"<<"cong"<<"bot"<<"mid"; - } - - if (extendWInMM.contains(n)) { - extendWidthInMathmode=true; +JKQTMathText::MTsymbolNode::~MTsymbolNode() = default; + +QString JKQTMathText::MTsymbolNode::getTypeName() const +{ + return QLatin1String("MTsymbolNode(")+symbolName+QLatin1String(")"); +} + +bool JKQTMathText::MTsymbolNode::getWinSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps& props, const QString &n, const MTenvironment& currentEv, double mathFontFactor) const +{ + auto fnt=parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Text); + auto fntSym=parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Symbols); + + //qDebug()<<" +--- getWinSymbolProp("< winSymbolSymbol; + if (winSymbolSymbol.isEmpty()) { + winSymbolSymbol.insert("leftrightarrow", QChar(0xAB)); + winSymbolSymbol.insert("leftarrow", QChar(0xAC)); + winSymbolSymbol.insert("rightarrow", QChar(0xAE)); + winSymbolSymbol.insert("to", QChar(0xAE)); + winSymbolSymbol.insert("uparrow", QChar(0xAD)); + winSymbolSymbol.insert("downarrow", QChar(0xAF)); + winSymbolSymbol.insert("Leftrightarrow", QChar(0xDB)); + winSymbolSymbol.insert("iff", QChar(0xDB)); + winSymbolSymbol.insert("Leftarrow", QChar(0xDC)); + winSymbolSymbol.insert("Rightarrow", QChar(0xDE)); + winSymbolSymbol.insert("Uparrow", QChar(0xDD)); + winSymbolSymbol.insert("Downarrow", QChar(0xFF)); + winSymbolSymbol.insert("pm", QChar(0xB1)); + winSymbolSymbol.insert("leq", QChar(0xA3)); + winSymbolSymbol.insert("geq", QChar(0xB3)); + winSymbolSymbol.insert("le", QChar(0xA3)); + winSymbolSymbol.insert("ge", QChar(0xB3)); + winSymbolSymbol.insert("times", QChar(0xB4)); + winSymbolSymbol.insert("propto", QChar(0xB5)); + winSymbolSymbol.insert("partial", QChar(0xB6)); + winSymbolSymbol.insert("bullet", QChar(0xB7)); + winSymbolSymbol.insert("neq", QChar(0xB9)); + winSymbolSymbol.insert("ne", QChar(0xB9)); + winSymbolSymbol.insert("equiv", QChar(0xBA)); + winSymbolSymbol.insert("approx", QChar(0xBB)); + winSymbolSymbol.insert("ellipsis", QChar(0xBC)); + winSymbolSymbol.insert("Im", QChar(0xC1)); + winSymbolSymbol.insert("Re", QChar(0xC2)); + winSymbolSymbol.insert("otimes", QChar(0xC4)); + winSymbolSymbol.insert("oplus", QChar(0xC5)); + winSymbolSymbol.insert("oslash", QChar(0xC6)); + winSymbolSymbol.insert("cap", QChar(0xC7)); + winSymbolSymbol.insert("land", QChar(0xC7)); + winSymbolSymbol.insert("cup", QChar(0xC8)); + winSymbolSymbol.insert("lor", QChar(0xC8)); + winSymbolSymbol.insert("supset", QChar(0xC9)); + winSymbolSymbol.insert("supseteq", QChar(0xCA)); + winSymbolSymbol.insert("supsetnot", QChar(0xCB)); + winSymbolSymbol.insert("subset", QChar(0xCC)); + winSymbolSymbol.insert("subseteq", QChar(0xCD)); + winSymbolSymbol.insert("in", QChar(0xCE)); + winSymbolSymbol.insert("notin", QChar(0xCF)); + winSymbolSymbol.insert("angle", QChar(0xD0)); + winSymbolSymbol.insert("nabla", QChar(0xD1)); + winSymbolSymbol.insert("copyright", QChar(0xD3)); + winSymbolSymbol.insert("registered", QChar(0xD2)); + winSymbolSymbol.insert("circledR", QChar(0xD2)); + winSymbolSymbol.insert("trademark", QChar(0xD4)); + winSymbolSymbol.insert("textregistered", QChar(0xD4)); + winSymbolSymbol.insert("cdot", QChar(0xD7)); + winSymbolSymbol.insert("neg", QChar(0xD8)); + winSymbolSymbol.insert("wedge", QChar(0xD9)); + winSymbolSymbol.insert("vee", QChar(0xDA)); + winSymbolSymbol.insert("diamond", QChar(0xE0)); + winSymbolSymbol.insert("langle", QChar(0xE1)); + winSymbolSymbol.insert("rangle", QChar(0xF1)); + winSymbolSymbol.insert("forall", QChar(0x22)); + winSymbolSymbol.insert("exists", QChar(0x24)); + winSymbolSymbol.insert("cong", QChar(0x40)); + winSymbolSymbol.insert("bot", QChar(0x5E)); + winSymbolSymbol.insert("ll", "<<"); + winSymbolSymbol.insert("gg", ">>"); + winSymbolSymbol.insert("Alef", QChar(0xC0)); + winSymbolSymbol.insert("alef", QChar(0xC0)); + winSymbolSymbol.insert("tilde", "~"); + winSymbolSymbol.insert("emptyset", QChar(0xC6)); + winSymbolSymbol.insert("varnothing", QChar(0xC6)); + winSymbolSymbol.insert("lceil", QChar(0xE9)); + winSymbolSymbol.insert("rceil", QChar(0xF9)); + winSymbolSymbol.insert("lfloor", QChar(0xEB)); + winSymbolSymbol.insert("rfloor", QChar(0xFB)); + winSymbolSymbol.insert("subsetnot", QChar(0xCB)); + winSymbolSymbol.insert("DC", "="); + winSymbolSymbol.insert("mid", "|"); + winSymbolSymbol.insert("cdots", QString(3, QChar(0xD7))); + winSymbolSymbol.insert("dots", QChar(0xDC)); + winSymbolSymbol.insert("ldots", QChar(0xDC)); + winSymbolSymbol.insert("cent", "c"); + winSymbolSymbol.insert("sim", QChar(0x7E)); + winSymbolSymbol.insert("infty", QChar(0xA5)); } + QHash::iterator itsymbol = winSymbolSymbol.find(n); + if (itsymbol!=winSymbolSymbol.end()) { + props.symbol = itsymbol.value(); + } else if (n == "int") { props.symbol = QChar(0xF2); props.fontFactor = mathFontFactor; props.yfactor = +0.1; } + else if (n == "bbC") { props.symbol = "C"; props.bold = +1; props.italic = -1; } + else if (n == "bbH") { props.symbol = "H"; props.bold = +1; props.italic = -1; } + else if (n == "bbN") { props.symbol = "N"; props.bold = +1; props.italic = -1; } + else if (n == "bbP") { props.symbol = "P"; props.bold = +1; props.italic = -1; } + else if (n == "bbQ") { props.symbol = "Q"; props.bold = +1; props.italic = -1; } + else if (n == "bbR") { props.symbol = "R"; props.bold = +1; props.italic = -1; } + else if (n == "bbZ") { props.symbol = "Z"; props.bold = +1; props.italic = -1; } + else if (n == "iint") { props.symbol = QString(2, QChar(0xF2)); props.fontFactor = mathFontFactor; props.yfactor = +0.1; } + else if (n == "iiint") { props.symbol = QString(3, QChar(0xF2)); props.fontFactor = mathFontFactor; props.yfactor = +0.1; } + else if (n == "bigcap") { props.symbol = QChar(0xC7); props.fontFactor = 2; } + else if (n == "bigcup") { props.symbol = QChar(0xC8); props.fontFactor = 2; } + else if (n == "bigvee") { props.symbol = QChar(0xDA); props.fontFactor = 2; } + else if (n == "bighat") { props.symbol = QChar(0xD9); props.fontFactor = 2; } - static QHash simpleTranslations; - if (simpleTranslations.isEmpty()) { - simpleTranslations.insert("", " "); - simpleTranslations.insert("sin", "sin"); - simpleTranslations.insert("cos", "cos"); - simpleTranslations.insert("tan", "tan"); - simpleTranslations.insert("sinh", "sinh"); - simpleTranslations.insert("cosh", "cosh"); - simpleTranslations.insert("tanh", "tanh"); - simpleTranslations.insert("atan", "atan"); - simpleTranslations.insert("acos", "acos"); - simpleTranslations.insert("asin", "asin"); - simpleTranslations.insert("arcsin", "arcsin"); - simpleTranslations.insert("arccos", "arccos"); - simpleTranslations.insert("arctan", "arctan"); - simpleTranslations.insert("degree", QLatin1String("\xB0")); - simpleTranslations.insert("ii", "i"); - simpleTranslations.insert("dd", "d"); - simpleTranslations.insert("exp", "exp"); - simpleTranslations.insert("log", "log"); - simpleTranslations.insert("ln", "ln"); - simpleTranslations.insert("ld", "ld"); - simpleTranslations.insert("lb", "lb"); - simpleTranslations.insert("argmin", "argmin"); - simpleTranslations.insert("argmax", "argmax"); - simpleTranslations.insert("max", "max"); - simpleTranslations.insert("mod", "mod"); - simpleTranslations.insert("min", "min"); - simpleTranslations.insert("median", "median"); - simpleTranslations.insert("sign", "sign"); - simpleTranslations.insert("sgn", "sgn"); - simpleTranslations.insert("sec", "sec"); - simpleTranslations.insert("gcd", "gcd"); - simpleTranslations.insert("hom", "hom"); - simpleTranslations.insert("ker", "ker"); - simpleTranslations.insert("dim", "dim"); - simpleTranslations.insert("cot", "cot"); - simpleTranslations.insert("arg", "arg"); - simpleTranslations.insert("det", "det"); - simpleTranslations.insert("deg", "deg"); - simpleTranslations.insert("Pr", "Pr"); - simpleTranslations.insert("coth", "coth"); + else { // here are text mode symbols, i.e. bold and italic won't be touched + props.bold = -1; + props.italic = -1; + props.font = fnt.first; + if (n == "_") { props.symbol = "_"; props.bold = 0; props.italic = 0; } + else if (n == "}") { props.symbol = "}"; } + else if (n == "{") { props.symbol = "{"; } + else if (n == "hbar") { props.symbol = "h"; props.bold = 0; props.italic = 0; props.drawBar = true; } + else if (n == "euro") { props.symbol = ""; props.bold = 0; props.italic = 0; } + else if (n == "cent") { props.symbol = QChar(0xA2); props.bold = 0; props.italic = 0; } + else if (n == "pound") { props.symbol = QChar(0xA3); props.bold = 0; props.italic = 0; } + else if (n == "yen") { props.symbol = QChar(0xA5); props.bold = 0; props.italic = 0; } + else if (n == "div") { props.symbol = QChar(0xF7); props.bold = 0; props.italic = 0; } + else if (n == "backslash") { props.symbol = "\\"; props.bold = 0; props.italic = 0; } + //else if (n=="|") { symbol="||"; bold=0; italic=0; } + else if (n == "$") { props.symbol = "$"; props.bold = 0; props.italic = 0; } + else if (n == "%") { props.symbol = "%"; props.bold = 0; props.italic = 0; } + else if (n == "&") { props.symbol = "&"; props.bold = 0; props.italic = 0; } + else if (n == "#") { props.symbol = "#"; props.bold = 0; props.italic = 0; } + else if (n == "ast") { props.symbol = "*"; props.bold = 0; props.italic = 0; } + else if (n == "glq") { props.symbol = "'"; props.bold = 0; props.italic = 0; } + else if (n == "grq") { props.symbol = "'"; props.bold = 0; props.italic = 0; } + else if (n == "glqq") { props.symbol = "\""; props.bold = 0; props.italic = 0; } + else if (n == "grqq") { props.symbol = "\""; props.bold = 0; props.italic = 0; } + else if (n == "flq") { props.symbol = "<"; props.bold = 0; props.italic = 0; } + else if (n == "frq") { props.symbol = ">"; props.bold = 0; props.italic = 0; } + else if (n == "flqq") { props.symbol = ""; props.bold = 0; props.italic = 0; } + else if (n == "frqq") { props.symbol = ""; props.bold = 0; props.italic = 0; } + else { return false; } } + return true; +} - static QHash simpleTranslations_heightIsAscent; - if (simpleTranslations_heightIsAscent.isEmpty()) { - simpleTranslations_heightIsAscent.insert("erf", "erf"); - simpleTranslations_heightIsAscent.insert("median", "median"); - simpleTranslations_heightIsAscent.insert("min", "min"); - simpleTranslations_heightIsAscent.insert("max", "max"); - simpleTranslations_heightIsAscent.insert("inf", "inf"); - simpleTranslations_heightIsAscent.insert("sup", "sup"); - simpleTranslations_heightIsAscent.insert("liminf", "liminf"); - simpleTranslations_heightIsAscent.insert("limsup", "limsup"); - simpleTranslations_heightIsAscent.insert("lim", "lim"); - } +bool JKQTMathText::MTsymbolNode::getGreekSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps& props, const QString &n, const MTenvironment& currentEv, double mathFontFactor) const +{ + auto fnt=parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Text); + auto fntGreek=parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Greek); + + //qDebug()<<" +--- getGreekSymbolProp("< winSymbolGreek; if (winSymbolGreek.isEmpty()) { @@ -2137,85 +2254,6 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na winSymbolGreek.insert("Psi", "Y"); } - static QHash winSymbolSymbol; - if (winSymbolSymbol.isEmpty()) { - winSymbolSymbol.insert("leftrightarrow", QChar(0xAB)); - winSymbolSymbol.insert("leftarrow", QChar(0xAC)); - winSymbolSymbol.insert("rightarrow", QChar(0xAE)); - winSymbolSymbol.insert("to", QChar(0xAE)); - winSymbolSymbol.insert("uparrow", QChar(0xAD)); - winSymbolSymbol.insert("downarrow", QChar(0xAF)); - winSymbolSymbol.insert("Leftrightarrow", QChar(0xDB)); - winSymbolSymbol.insert("iff", QChar(0xDB)); - winSymbolSymbol.insert("Leftarrow", QChar(0xDC)); - winSymbolSymbol.insert("Rightarrow", QChar(0xDE)); - winSymbolSymbol.insert("Uparrow", QChar(0xDD)); - winSymbolSymbol.insert("Downarrow", QChar(0xFF)); - winSymbolSymbol.insert("pm", QChar(0xB1)); - winSymbolSymbol.insert("leq", QChar(0xA3)); - winSymbolSymbol.insert("geq", QChar(0xB3)); - winSymbolSymbol.insert("times", QChar(0xB4)); - winSymbolSymbol.insert("propto", QChar(0xB5)); - winSymbolSymbol.insert("partial", QChar(0xB6)); - winSymbolSymbol.insert("bullet", QChar(0xB7)); - winSymbolSymbol.insert("neq", QChar(0xB9)); - winSymbolSymbol.insert("ne", QChar(0xB9)); - winSymbolSymbol.insert("equiv", QChar(0xBA)); - winSymbolSymbol.insert("approx", QChar(0xBB)); - winSymbolSymbol.insert("ellipsis", QChar(0xBC)); - winSymbolSymbol.insert("Im", QChar(0xC1)); - winSymbolSymbol.insert("Re", QChar(0xC2)); - winSymbolSymbol.insert("otimes", QChar(0xC4)); - winSymbolSymbol.insert("oplus", QChar(0xC5)); - winSymbolSymbol.insert("oslash", QChar(0xC6)); - winSymbolSymbol.insert("cap", QChar(0xC7)); - winSymbolSymbol.insert("land", QChar(0xC7)); - winSymbolSymbol.insert("cup", QChar(0xC8)); - winSymbolSymbol.insert("lor", QChar(0xC8)); - winSymbolSymbol.insert("supset", QChar(0xC9)); - winSymbolSymbol.insert("supseteq", QChar(0xCA)); - winSymbolSymbol.insert("supsetnot", QChar(0xCB)); - winSymbolSymbol.insert("subset", QChar(0xCC)); - winSymbolSymbol.insert("subseteq", QChar(0xCD)); - winSymbolSymbol.insert("in", QChar(0xCE)); - winSymbolSymbol.insert("notin", QChar(0xCF)); - winSymbolSymbol.insert("angle", QChar(0xD0)); - winSymbolSymbol.insert("nabla", QChar(0xD1)); - winSymbolSymbol.insert("copyright", QChar(0xD3)); - winSymbolSymbol.insert("registered", QChar(0xD2)); - winSymbolSymbol.insert("trademark", QChar(0xD4)); - winSymbolSymbol.insert("cdot", QChar(0xD7)); - winSymbolSymbol.insert("neg", QChar(0xD8)); - winSymbolSymbol.insert("wedge", QChar(0xD9)); - winSymbolSymbol.insert("vee", QChar(0xDA)); - winSymbolSymbol.insert("diamond", QChar(0xE0)); - winSymbolSymbol.insert("langle", QChar(0xE1)); - winSymbolSymbol.insert("rangle", QChar(0xF1)); - winSymbolSymbol.insert("forall", QChar(0x22)); - winSymbolSymbol.insert("exists", QChar(0x24)); - winSymbolSymbol.insert("cong", QChar(0x40)); - winSymbolSymbol.insert("bot", QChar(0x5E)); - winSymbolSymbol.insert("ll", "<<"); - winSymbolSymbol.insert("gg", ">>"); - winSymbolSymbol.insert("Alef", QChar(0xC0)); - winSymbolSymbol.insert("alef", QChar(0xC0)); - winSymbolSymbol.insert("tilde", "~"); - winSymbolSymbol.insert("emptyset", QChar(0xC6)); - winSymbolSymbol.insert("varnothing", QChar(0xC6)); - winSymbolSymbol.insert("lceil", QChar(0xE9)); - winSymbolSymbol.insert("rceil", QChar(0xF9)); - winSymbolSymbol.insert("lfloor", QChar(0xEB)); - winSymbolSymbol.insert("rfloor", QChar(0xFB)); - winSymbolSymbol.insert("subsetnot", QChar(0xCB)); - winSymbolSymbol.insert("DC", "="); - winSymbolSymbol.insert("mid", "|"); - winSymbolSymbol.insert("cdots", QString(3, QChar(0xD7))); - winSymbolSymbol.insert("dots", QChar(0xDC)); - winSymbolSymbol.insert("ldots", QChar(0xDC)); - winSymbolSymbol.insert("cent", "c"); - } - - static QHash unicodeGreek; if (unicodeGreek.isEmpty()) { unicodeGreek.insert("alpha", QChar(0x3B1)); @@ -2260,6 +2298,138 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na unicodeGreek.insert("Psi", QChar(0x3A8)); } + props.italic = -1; + if(fnt.second==MTFEunicodeLimited || fnt.second==MTFEunicode) { + props.font = fnt.first; + //std::cout<<"encoding unicode\n"; + QHash::iterator itgreek = unicodeGreek.find(n); + if (itgreek!=unicodeGreek.end()) { + props.symbol = itgreek.value(); + return true; + } + } + + if(fntGreek.second==MTFEunicodeLimited || fntGreek.second==MTFEunicode) { + props.font = fntGreek.first; + //std::cout<<"encoding unicode\n"; + QHash::iterator itgreek = unicodeGreek.find(n); + if (itgreek!=unicodeGreek.end()) { + props.symbol = itgreek.value(); + return true; + } + } + + props.font = fntGreek.first; + QHash::iterator itgreek = winSymbolGreek.find(n); + if (itgreek!=winSymbolGreek.end()) { + props.symbol = itgreek.value(); + } else if (n == "sum") { props.symbol = "S"; props.fontFactor = mathFontFactor; props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "prod") { props.symbol = "P"; props.fontFactor = mathFontFactor; props.heightIsAscent = true; props.exactAscent = true; } + else { + return false; + } + + + return true; +} + + +bool JKQTMathText::MTsymbolNode::getStandardTextSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps& props, const QString &n) const +{ + props.bold = -1; + props.italic = -1; + + //qDebug()<<" +--- getStandardTextSymbolProp("< unicodeBaseSymbol; + if (unicodeBaseSymbol.isEmpty()) { + + unicodeBaseSymbol.insert("diamond", QChar(0xE0)); + unicodeBaseSymbol.insert("infty", QChar(0x221E)); + unicodeBaseSymbol.insert("partial", QChar(0x2202)); + unicodeBaseSymbol.insert("times", QChar(0x2A2F)); + unicodeBaseSymbol.insert("bullet", QChar(0x2219)); + unicodeBaseSymbol.insert("copyright", QChar(0x00A9)); + unicodeBaseSymbol.insert("registered", QChar(0x00AE)); + unicodeBaseSymbol.insert("circledR", QChar(0x00AE)); + unicodeBaseSymbol.insert("trademark", QChar(0x2122)); + unicodeBaseSymbol.insert("textregistered", QChar(0x2122)); + unicodeBaseSymbol.insert("cdot", QChar(0x00B7)); + unicodeBaseSymbol.insert("pm", QChar(0x00B1)); + unicodeBaseSymbol.insert("leq", QChar(0x2264)); + unicodeBaseSymbol.insert("geq", QChar(0x2265)); + unicodeBaseSymbol.insert("le", QChar(0x2264)); + unicodeBaseSymbol.insert("ge", QChar(0x2265)); + unicodeBaseSymbol.insert("hbar", QChar(0x210F)); + unicodeBaseSymbol.insert("EUR", QChar(0x20AC)); + unicodeBaseSymbol.insert("euro", QChar(0x20AC)); + unicodeBaseSymbol.insert("circ", QChar(0x2218)); + unicodeBaseSymbol.insert("cent", QChar(0x00A2)); + unicodeBaseSymbol.insert("pound", QChar(0x00A3)); + unicodeBaseSymbol.insert("yen", QChar(0x00A5)); + unicodeBaseSymbol.insert("dollar", QChar(0x0024)); + unicodeBaseSymbol.insert("neq", QChar(0x2260)); + unicodeBaseSymbol.insert("lnot", QChar(0x2260)); + unicodeBaseSymbol.insert("Angstrom", QChar(0x00AC)); + unicodeBaseSymbol.insert("co", QChar(0x2105)); + unicodeBaseSymbol.insert("No", QChar(0x2116)); + unicodeBaseSymbol.insert("Ohm", QChar(0x2126)); + unicodeBaseSymbol.insert("ohm", QChar(0x2126)); + unicodeBaseSymbol.insert("tcohm", QChar(0x2126)); + unicodeBaseSymbol.insert("partial", QChar(0x2202)); + unicodeBaseSymbol.insert("cdots", QString(QChar(0x00B7)) + QString(QChar(0x00B7)) + QString(QChar(0x00B7))); + unicodeBaseSymbol.insert("approx", QChar(0x2248)); + + unicodeBaseSymbol.insert("Angstroem", QChar(0x212B)); + } + + QHash::iterator itbasesymbol = unicodeBaseSymbol.find(n); + if (itbasesymbol!=unicodeBaseSymbol.end()) { + props.symbol = itbasesymbol.value(); + } else { + props.bold = -1; + props.italic = -1; + + + if (n == "glq") { props.symbol = QChar(0x2018); props.bold = 0; props.italic = 0; } + else if (n == "grq") { props.symbol = QChar(0x2019); props.bold = 0; props.italic = 0; } + else if (n == "glqq") { props.symbol = QChar(0x201C); props.bold = 0; props.italic = 0; } + else if (n == "grqq") { props.symbol = QChar(0x201D); props.bold = 0; props.italic = 0; } + else if (n == "flq") { props.symbol = QChar(0x2039); props.bold = 0; props.italic = 0; } + else if (n == "frq") { props.symbol = QChar(0x203A); props.bold = 0; props.italic = 0; } + else if (n == "flqq") { props.symbol = ""; props.bold = 0; props.italic = 0; } + else if (n == "frqq") { props.symbol = ""; props.bold = 0; props.italic = 0; } + else {return false;} + } + return true; +} + +bool JKQTMathText::MTsymbolNode::getUnicodeFullSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps& props, const QString &n, double mathFontFactor) const +{ + + //qDebug()<<" +--- getUnicodeFullSymbolProp("< unicodeSymbol; if (unicodeSymbol.isEmpty()) { unicodeSymbol.insert("leftrightarrow", QChar(0x2194)); @@ -2280,17 +2450,22 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na unicodeSymbol.insert("ll", QChar(0x226A)); unicodeSymbol.insert("gg", QChar(0x226B)); unicodeSymbol.insert("Alef", QChar(0x2135)); + unicodeSymbol.insert("Aleph", QChar(0x2135)); unicodeSymbol.insert("Bet", QChar(0x2136)); + unicodeSymbol.insert("Beth", QChar(0x2136)); unicodeSymbol.insert("Gimel", QChar(0x2137)); unicodeSymbol.insert("Dalet", QChar(0x2138)); unicodeSymbol.insert("alef", QChar(0x2135)); + unicodeSymbol.insert("aleph", QChar(0x2135)); unicodeSymbol.insert("bet", QChar(0x2136)); + unicodeSymbol.insert("beth", QChar(0x2136)); unicodeSymbol.insert("gimel", QChar(0x2137)); unicodeSymbol.insert("dalet", QChar(0x2138)); unicodeSymbol.insert("nexists", QChar(0x2204)); unicodeSymbol.insert("ni", QChar(0x220B)); unicodeSymbol.insert("notni", QChar(0x220C)); unicodeSymbol.insert("tilde", QChar(0x223C)); + unicodeSymbol.insert("sim", QChar(0x223C)); unicodeSymbol.insert("emptyset", QChar(0x2300)); unicodeSymbol.insert("varnothing", QChar(0x2300)); unicodeSymbol.insert("odot", QChar(0x2299)); @@ -2302,7 +2477,14 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na unicodeSymbol.insert("subsetnot", QChar(0x2284)); unicodeSymbol.insert("DC", QChar(0x2393)); unicodeSymbol.insert("bot", QChar(0x22A4)); - unicodeSymbol.insert("mid", QChar(0xFF5C)); + unicodeSymbol.insert("perp", QChar(0x22A5)); + unicodeSymbol.insert("sqcap", QChar(0x2293)); + unicodeSymbol.insert("sqcup", QChar(0x2294)); + unicodeSymbol.insert("triangle", QChar(0x2206)); + unicodeSymbol.insert("square", QChar(0x25A1)); + unicodeSymbol.insert("setminus", QChar(0x2216)); + unicodeSymbol.insert("mid", QChar(0x2223)); + unicodeSymbol.insert("nmid", QChar(0x2224)); unicodeSymbol.insert("vdots", QChar(0x22EE)); unicodeSymbol.insert("iddots", QChar(0x22F0)); unicodeSymbol.insert("ddots", QChar(0x22F1)); @@ -2347,8 +2529,13 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na unicodeSymbol.insert("subseteq", QChar(0x2286)); unicodeSymbol.insert("in", QChar(0x2208)); unicodeSymbol.insert("notin", QChar(0x2209)); - unicodeSymbol.insert("angle", QChar(0x2221)); + unicodeSymbol.insert("angle", QChar(0x2220)); + unicodeSymbol.insert("measuredangle", QChar(0x2221)); + unicodeSymbol.insert("sphericalangle", QChar(0x2222)); + unicodeSymbol.insert("rightangle", QChar(0x221F)); unicodeSymbol.insert("nabla", QChar(0x2207)); + unicodeSymbol.insert("parallel", QChar(0x2225)); + unicodeSymbol.insert("nparallel", QChar(0x2226)); unicodeSymbol.insert("neg", QChar(0x00AC)); unicodeSymbol.insert("wedge", QChar(0x2227)); unicodeSymbol.insert("vee", QChar(0x2228)); @@ -2356,438 +2543,278 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na unicodeSymbol.insert("rangle", QChar(0x232A)); unicodeSymbol.insert("forall", QChar(0x2200)); unicodeSymbol.insert("exists", QChar(0x2203)); - unicodeSymbol.insert("cong", QChar(0x2245)); unicodeSymbol.insert("bot", QChar(0x22A5)); + unicodeSymbol.insert("geqq", QChar(0x2267)); + unicodeSymbol.insert("leqq", QChar(0x2266)); + unicodeSymbol.insert("prec", QChar(0x227A)); + unicodeSymbol.insert("succ", QChar(0x227B)); + unicodeSymbol.insert("vartriangleleft", QChar(0x22B2)); + unicodeSymbol.insert("cong", QChar(0x2245)); + unicodeSymbol.insert("simeq", QChar(0x2243)); + unicodeSymbol.insert("therefore", QChar(0x2234)); + unicodeSymbol.insert("because", QChar(0x2235)); + unicodeSymbol.insert("lightning", QChar(0x21AF)); + unicodeSymbol.insert("blacksquare", QChar(0x220E)); + unicodeSymbol.insert("Box", QChar(0x25A1)); + unicodeSymbol.insert("celsius", QChar(0x2103)); + unicodeSymbol.insert("AC", QChar(0x223F)); + unicodeSymbol.insert("frown", QChar(0x2322)); + unicodeSymbol.insert("smile", QChar(0x2323)); + unicodeSymbol.insert("smiley", QChar(0x233A)); + unicodeSymbol.insert("blacksmiley", QChar(0x233B)); + unicodeSymbol.insert("frownie", QChar(0x2639)); + unicodeSymbol.insert("varhexagonlrbonds", QChar(0x232C)); + unicodeSymbol.insert("hexagon", QChar(0x2394)); + unicodeSymbol.insert("varcarriagereturn", QChar(0x23CE)); + unicodeSymbol.insert("benzenr", QChar(0x23E3)); + unicodeSymbol.insert("trapezium", QChar(0x23E2)); + unicodeSymbol.insert("female", QChar(0x2640)); + unicodeSymbol.insert("male", QChar(0x2642)); + unicodeSymbol.insert("accurrent", QChar(0x23E6)); } - static QHash unicodeBaseSymbol; - if (unicodeBaseSymbol.isEmpty()) { + QHash::iterator itsymbol = unicodeSymbol.find(n); - unicodeBaseSymbol.insert("diamond", QChar(0xE0)); - unicodeBaseSymbol.insert("infty", QChar(0x221E)); - unicodeBaseSymbol.insert("partial", QChar(0x2202)); - unicodeBaseSymbol.insert("times", QChar(0x2A2F)); - unicodeBaseSymbol.insert("bullet", QChar(0x2219)); - unicodeBaseSymbol.insert("copyright", QChar(0x00A9)); - unicodeBaseSymbol.insert("registered", QChar(0x00AE)); - unicodeBaseSymbol.insert("trademark", QChar(0x2122)); - unicodeBaseSymbol.insert("cdot", QChar(0x00B7)); - unicodeBaseSymbol.insert("pm", QChar(0x00B1)); - unicodeBaseSymbol.insert("leq", QChar(0x2264)); - unicodeBaseSymbol.insert("geq", QChar(0x2265)); - unicodeBaseSymbol.insert("hbar", QChar(0x210F)); - unicodeBaseSymbol.insert("euro", QChar(0x20AC)); - unicodeBaseSymbol.insert("circ", QChar(0x2218)); - unicodeBaseSymbol.insert("cent", QChar(0x00A2)); - unicodeBaseSymbol.insert("pound", QChar(0x00A3)); - unicodeBaseSymbol.insert("yen", QChar(0x00A5)); - unicodeBaseSymbol.insert("neq", QChar(0x2260)); - unicodeBaseSymbol.insert("Angstrom", QChar(0x212B)); - unicodeBaseSymbol.insert("cdots", QString(QChar(0x00B7)) + QString(QChar(0x00B7)) + QString(QChar(0x00B7))); - unicodeBaseSymbol.insert("dots", "..."); - unicodeBaseSymbol.insert("ldots", "..."); - unicodeBaseSymbol.insert("approx", QChar(0x2248)); + if (itsymbol!=unicodeSymbol.end()) { + props.symbol = itsymbol.value(); + } + else if (n == "sum") { props.symbol = QChar(0x2211); props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "prod") { props.symbol = QChar(0x220F); props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "bbC") { props.symbol = QChar(0x2102); props.italic = -1; } + else if (n == "bbH") { props.symbol = QChar(0x210D); props.italic = -1; } + else if (n == "bbN") { props.symbol = QChar(0x2115); props.italic = -1; } + else if (n == "bbP") { props.symbol = QChar(0x2119); props.italic = -1; } + else if (n == "bbQ") { props.symbol = QChar(0x211A); props.italic = -1; } + else if (n == "bbR") { props.symbol = QChar(0x211D); props.italic = -1; } + else if (n == "bbZ") { props.symbol = QChar(0x2124); props.italic = -1; } + else if (n == "iint") { props.symbol = QChar(0x222C); props.fontFactor = mathFontFactor; /*yfactor=+0.1;*/ props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "iiint") { props.symbol = QChar(0x222D); props.fontFactor = mathFontFactor; /*yfactor=+0.1;*/ props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "oint") { props.symbol = QChar(0x222E); props.fontFactor = mathFontFactor; /*yfactor=+0.1;*/ props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "oiint") { props.symbol = QChar(0x222F); props.fontFactor = mathFontFactor; /*yfactor=+0.1;*/ props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "oiiint") { props.symbol = QChar(0x2230); props.fontFactor = mathFontFactor; /*yfactor=+0.1;*/ props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "coprod") { props.symbol = QChar(0x2210); props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "bigcap") { props.symbol = QChar(0x22C2); props.heightIsAscent = true; props.exactAscent = true; props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "bigcup") { props.symbol = QChar(0x22C3); props.heightIsAscent = true; props.exactAscent = true; props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "bigvee") { props.symbol = QChar(0x22C1); props.heightIsAscent = true; props.exactAscent = true; props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "bighat") { props.symbol = QChar(0x22C0); props.heightIsAscent = true; props.exactAscent = true; props.heightIsAscent = true; props.exactAscent = true; } + else if (n == "int") { props.symbol = QChar(0x222B); props.fontFactor = mathFontFactor; /*yfactor=+0.1;*/ props.heightIsAscent = true; props.exactAscent = true; } + else {return false;} + return true; +} +bool JKQTMathText::MTsymbolNode::getSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps& props, const QString &n, const MTenvironment& currentEv, double mathFontFactor) const +{ + auto fnt=parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Text); + auto fntGreek=parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Greek); + auto fntSym=parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Symbols); + + //qDebug()<<"--- getSymbolProp("< latexSimpleSymbol; - if (latexSimpleSymbol.isEmpty()) { - latexSimpleSymbol.insert("_", "_"); - latexSimpleSymbol.insert("}", "}"); - latexSimpleSymbol.insert("{", "{"); - latexSimpleSymbol.insert("$", "$"); - latexSimpleSymbol.insert("%", "%"); - latexSimpleSymbol.insert("&", "&"); - latexSimpleSymbol.insert("#", "#"); - latexSimpleSymbol.insert("ast", "*"); - latexSimpleSymbol.insert("glq", QChar(0x27)); - latexSimpleSymbol.insert("grq", QChar(0x60)); - latexSimpleSymbol.insert("glqq", QChar(0x5C)); - latexSimpleSymbol.insert("grqq", "\""); + + return true; +} + +JKQTMathText::MTsymbolNode::SymbolProps JKQTMathText::MTsymbolNode::getSymbolProp(const QString &symName, const MTenvironment& currentEv) const +{ + + auto fnt=parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Text); + auto fntSym=parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Symbols); + auto fntGreek=parent->getFontData(currentEv.font, currentEv.insideMath, FontSubclass::Greek); + + JKQTMathText::MTsymbolNode::SymbolProps props; + double mathFontFactor=1.8; + props.symbol=""; + props.fontFactor=1.0; + props.bold=0; + props.italic=-1; + props.yfactor=0; + props.drawBar=false; + props.font=fnt.first; + props.heightIsAscent=false; + props.exactAscent=false; + props.extendWidthInMathmode=false; + + QString n=symName; + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // statische Lookup-Tabellen vorbereiten + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + static QStringList extendWInMM; + if (extendWInMM.isEmpty()) { + extendWInMM <<"ll"<<"gg"<<"leq"<<"geq"<<"leftrightarrow"<<"leftarrow"<<"rightarrow"<<"to"<<"uparrow"<<"downarrow"<<"updownarrow"<<"Leftrightarrow" + <<"iff"<<"Leftarrow"<<"Rightarrow"<<"Uparrow"<<"Downarrow"<<"Updownarrow"<<"pm"<<"mp"<<"nexists"<<"ni"<<"notni"<<"circ"<<"sim"<<"emptyset"<<"odot"<<"ominus" + <<"subsetnot"<<"bot"<<"leftharpoonup"<<"rightharpoonup"<<"upharpoonleft"<<"downharpoonleft"<<"leftrightharpoon"<<"rightleftharpoon"<<"coprod"<<"leftharpoondown" + <<"rightharpoondown"<<"upharpoonright"<<"downharpoonright"<<"nwarrow"<<"nearrow"<<"searrow"<<"swarrow"<<"mapsto"<<"div"<<"multimap"<<"maporiginal"<<"mapimage" + <<"times"<<"propto"<<"bullet"<<"neq"<<"ne"<<"equiv"<<"approx"<<"otimes"<<"oplus"<<"oslash"<<"cap"<<"land"<<"cup"<<"lor"<<"supset"<<"supseteq"<<"supsetnot" + <<"subset"<<"subseteq"<<"in"<<"notin"<<"cdot"<<"wedge"<<"vee"<<"cong"<<"bot"<<"mid"; } - static QHash latexGreek; - if (latexGreek.isEmpty()) { - latexGreek.insert("alpha", QChar(0xAE)); - latexGreek.insert("beta", QChar(0xAF)); - latexGreek.insert("gamma", QChar(0xB0)); - latexGreek.insert("delta", QChar(0xB1)); - latexGreek.insert("epsilon", QChar(0x22)); - latexGreek.insert("varepsilon", QChar(0xB2)); - latexGreek.insert("zeta", QChar(0xB3)); - latexGreek.insert("eta", QChar(0xB4)); - latexGreek.insert("theta", QChar(0xB5)); - latexGreek.insert("vartheta", QChar(0x23)); - latexGreek.insert("iota", QChar(0xB6)); - latexGreek.insert("kappa", QChar(0xB7)); - latexGreek.insert("lambda", QChar(0xB8)); - latexGreek.insert("mu", QChar(0xB9)); - latexGreek.insert("nu", QChar(0xBA)); - latexGreek.insert("xi", QChar(0xBB)); - latexGreek.insert("pi", QChar(0xBC)); - latexGreek.insert("varpi", QChar(0x24)); - latexGreek.insert("rho", QChar(0xBD)); - latexGreek.insert("varrho", QChar(0x25)); - latexGreek.insert("sigma", QChar(0xBE)); - latexGreek.insert("varsigma", QChar(0x26)); - latexGreek.insert("tau", QChar(0xBF)); - latexGreek.insert("upsilon", QChar(0xC0)); - latexGreek.insert("phi", QChar(0xC1)); - latexGreek.insert("varphi", QChar(0x27)); - latexGreek.insert("chi", QChar(0xC2)); - latexGreek.insert("psi", QChar(0xC3)); - latexGreek.insert("omega", QChar(0x21)); - latexGreek.insert("Gamma", QChar(0xA1)); - latexGreek.insert("Delta", QChar(0xA2)); - latexGreek.insert("Theta", QChar(0xA3)); - latexGreek.insert("Lambda", QChar(0xA4)); - latexGreek.insert("Xi", QChar(0xA5)); - latexGreek.insert("Pi", QChar(0xA6)); - latexGreek.insert("Sigma", QChar(0xA7)); - latexGreek.insert("Upsilon", QChar(0xA8)); - latexGreek.insert("Phi", QChar(0xA9)); - latexGreek.insert("Psi", QChar(0xAA)); - latexGreek.insert("leftharpoonup", QChar(0x28)); - latexGreek.insert("rightharpoonup", QChar(0x2A)); - latexGreek.insert("leftharpoondown", QChar(0x29)); - latexGreek.insert("rightharpoondown", QChar(0x2B)); - latexGreek.insert("neg", QChar(0xAC)); - latexGreek.insert("star", QChar(0x3F)); + if (extendWInMM.contains(n)) { + props.extendWidthInMathmode=true; } - static QHash latexSymbol; - if (latexSymbol.isEmpty()) { - latexSymbol.insert("leftrightarrow", QChar(0x24)); - latexSymbol.insert("leftarrow", QChar(0xc3)); - latexSymbol.insert("rightarrow", QChar(0x21)); - latexSymbol.insert("to", QChar(0x21)); - latexSymbol.insert("uparrow", QChar(0x22)); - latexSymbol.insert("downarrow", QChar(0x23)); - latexSymbol.insert("updownarrow", QChar(0x6c)); - latexSymbol.insert("Leftrightarrow", QChar(0x2c)); - latexSymbol.insert("iff", QChar(0x2c)); - latexSymbol.insert("Leftarrow", QChar(0x28)); - latexSymbol.insert("Rightarrow", QChar(0x29)); - latexSymbol.insert("Uparrow", QChar(0x2a)); - latexSymbol.insert("Downarrow", QChar(0x2b)); - latexSymbol.insert("Updownarrow", QChar(0x6d)); - latexSymbol.insert("pm", QChar(0xa7)); - latexSymbol.insert("mp", QChar(0xa8)); - latexSymbol.insert("leq", QChar(0xb7)); - latexSymbol.insert("geq", QChar(0xb8)); - latexSymbol.insert("ll", QChar(0xbf)); - latexSymbol.insert("gg", QChar(0xc0)); - latexSymbol.insert("Alef", QChar(0x40)); - latexSymbol.insert("alef", QChar(0x40)); - latexSymbol.insert("ni", QChar(0x33)); - latexSymbol.insert("circ", QChar(0xb1)); - latexSymbol.insert("tilde", QChar(0xbb)); - latexSymbol.insert("emptyset", QChar(0x3b)); - latexSymbol.insert("odot", QChar(0xaf)); - latexSymbol.insert("ominus", QChar(0xaa)); - latexSymbol.insert("odiv", QChar(0xae)); - latexSymbol.insert("oplus", QChar(0xa9)); - latexSymbol.insert("lceil", QChar(0x64)); - latexSymbol.insert("rceil", QChar(0x65)); - latexSymbol.insert("lfloor", QChar(0x62)); - latexSymbol.insert("rfloor", QChar(0x63)); - latexSymbol.insert("bot", QChar(0x3f)); - latexSymbol.insert("cdots", QString(3, QChar(0xA2))); - latexSymbol.insert("dots", "..."); - latexSymbol.insert("nwarrow", QChar(0x2d)); - latexSymbol.insert("nearrow", QChar(0x25)); - latexSymbol.insert("searrow", QChar(0x26)); - latexSymbol.insert("swarrow", QChar(0x2e)); - latexSymbol.insert("div", QChar(0xa5)); - latexSymbol.insert("times", QChar(0xa3)); - latexSymbol.insert("propto", QChar(0x2f)); - latexSymbol.insert("bullet", QChar(0x2b)); - latexSymbol.insert("equiv", QChar(0xb4)); - latexSymbol.insert("approx", QChar(0xbc)); - latexSymbol.insert("ellipsis", "..."); - latexSymbol.insert("Im", QChar(0x3D)); - latexSymbol.insert("Re", QChar(0x3C)); - latexSymbol.insert("oplus", QChar(0xa9)); - latexSymbol.insert("oslash", QChar(0xae)); - latexSymbol.insert("cap", QChar(0x5c)); - latexSymbol.insert("cup", QChar(0x5b)); - latexSymbol.insert("land", QChar(0x5c)); - latexSymbol.insert("lor", QChar(0x5b)); - latexSymbol.insert("supset", QChar(0xbe)); - latexSymbol.insert("supseteq", QChar(0xb6)); - latexSymbol.insert("subset", QChar(0xbd)); - latexSymbol.insert("subseteq", QChar(0xb5)); - latexSymbol.insert("in", QChar(0x32)); - latexSymbol.insert("nabla", QChar(0x35)); - latexSymbol.insert("cdot", QChar(0xa2)); - latexSymbol.insert("wedge", QChar(0x5e)); - latexSymbol.insert("vee", QChar(0x5f)); - latexSymbol.insert("diamond", QChar(0xE0)); - latexSymbol.insert("langle", QChar(0x68)); - latexSymbol.insert("rangle", QChar(0x69)); - latexSymbol.insert("infty", QChar(0x31)); - latexSymbol.insert("forall", QChar(0x38)); - latexSymbol.insert("exists", QChar(0x39)); - latexSymbol.insert("cong", QChar(0xbb)); - latexSymbol.insert("mid", "|"); + static QHash simpleTranslations; + if (simpleTranslations.isEmpty()) { + simpleTranslations.insert("", " "); + simpleTranslations.insert("sin", "sin"); + simpleTranslations.insert("cos", "cos"); + simpleTranslations.insert("tan", "tan"); + simpleTranslations.insert("sinh", "sinh"); + simpleTranslations.insert("cosh", "cosh"); + simpleTranslations.insert("tanh", "tanh"); + simpleTranslations.insert("atan", "atan"); + simpleTranslations.insert("acos", "acos"); + simpleTranslations.insert("asin", "asin"); + simpleTranslations.insert("arcsin", "arcsin"); + simpleTranslations.insert("arccos", "arccos"); + simpleTranslations.insert("arctan", "arctan"); + simpleTranslations.insert("degree", QLatin1String("\xB0")); + simpleTranslations.insert("textdegree ", QLatin1String("\xB0")); + simpleTranslations.insert("ii", "i"); + simpleTranslations.insert("dd", "d"); + simpleTranslations.insert("exp", "exp"); + simpleTranslations.insert("log", "log"); + simpleTranslations.insert("ln", "ln"); + simpleTranslations.insert("ld", "ld"); + simpleTranslations.insert("lb", "lb"); + simpleTranslations.insert("argmin", "argmin"); + simpleTranslations.insert("argmax", "argmax"); + simpleTranslations.insert("max", "max"); + simpleTranslations.insert("mod", "mod"); + simpleTranslations.insert("min", "min"); + simpleTranslations.insert("median", "median"); + simpleTranslations.insert("sign", "sign"); + simpleTranslations.insert("sgn", "sgn"); + simpleTranslations.insert("sec", "sec"); + simpleTranslations.insert("gcd", "gcd"); + simpleTranslations.insert("hom", "hom"); + simpleTranslations.insert("ker", "ker"); + simpleTranslations.insert("dim", "dim"); + simpleTranslations.insert("cot", "cot"); + simpleTranslations.insert("arg", "arg"); + simpleTranslations.insert("det", "det"); + simpleTranslations.insert("deg", "deg"); + simpleTranslations.insert("Pr", "Pr"); + simpleTranslations.insert("coth", "coth"); } + + static QHash simpleTranslations_heightIsAscent; + if (simpleTranslations_heightIsAscent.isEmpty()) { + simpleTranslations_heightIsAscent.insert("erf", "erf"); + simpleTranslations_heightIsAscent.insert("median", "median"); + simpleTranslations_heightIsAscent.insert("min", "min"); + simpleTranslations_heightIsAscent.insert("max", "max"); + simpleTranslations_heightIsAscent.insert("inf", "inf"); + simpleTranslations_heightIsAscent.insert("sup", "sup"); + simpleTranslations_heightIsAscent.insert("liminf", "liminf"); + simpleTranslations_heightIsAscent.insert("limsup", "limsup"); + simpleTranslations_heightIsAscent.insert("lim", "lim"); + } + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + props.font=fnt.first; + QString errorExplanation=""; QHash::iterator itsimple = simpleTranslations.find(n); - if (itsimple!= simpleTranslations.end()) { - symbol=itsimple.value(); + if (itsimple!= simpleTranslations.end()) { + props.symbol=itsimple.value(); } else { QHash::iterator itsimplehia = simpleTranslations_heightIsAscent.find(n); if (itsimplehia != simpleTranslations_heightIsAscent.end()) { - symbol = itsimplehia.value(); - heightIsAscent = true; - } else { - if (parent->getFontEncoding() == MTFEwinSymbol) { - // first we start with greek characters - font = MTSFgreek; - italic = -1; - QHash::iterator itgreek = winSymbolGreek.find(n); - if (itgreek!=winSymbolGreek.end()) { - symbol = itgreek.value(); - } else if (n == "sum") { symbol = "S"; fontFactor = mathFontFactor; heightIsAscent = true; exactAscent = true; } - else if (n == "prod") { symbol = "P"; fontFactor = mathFontFactor; heightIsAscent = true; exactAscent = true; } - else { - // now we set the symbols from the Symbol font - font = MTSFsymbol; - QHash::iterator itsymbol = winSymbolSymbol.find(n); - if (itsymbol!=winSymbolSymbol.end()) { - symbol = itsymbol.value(); - } else if (n == "int") { symbol = QChar(0xF2); fontFactor = mathFontFactor; yfactor = +0.1; } - else if (n == "bbC") { symbol = "C"; bold = +1; italic = -1; } - else if (n == "bbH") { symbol = "H"; bold = +1; italic = -1; } - else if (n == "bbN") { symbol = "N"; bold = +1; italic = -1; } - else if (n == "bbP") { symbol = "P"; bold = +1; italic = -1; } - else if (n == "bbQ") { symbol = "Q"; bold = +1; italic = -1; } - else if (n == "bbR") { symbol = "R"; bold = +1; italic = -1; } - else if (n == "bbZ") { symbol = "Z"; bold = +1; italic = -1; } - else if (n == "iint") { symbol = QString(2, QChar(0xF2)); fontFactor = mathFontFactor; yfactor = +0.1; } - else if (n == "iiint") { symbol = QString(3, QChar(0xF2)); fontFactor = mathFontFactor; yfactor = +0.1; } - else if (n == "bigcap") { symbol = QChar(0xC7); fontFactor = 2; } - else if (n == "bigcup") { symbol = QChar(0xC8); fontFactor = 2; } - else if (n == "bigvee") { symbol = QChar(0xDA); fontFactor = 2; } - else if (n == "bighat") { symbol = QChar(0xD9); fontFactor = 2; } - - else { // here are text mode symbols, i.e. bold and italic won't be touched - bold = -1; - italic = -1; - font = MTSFdefault; - if (n == "_") { symbol = "_"; bold = 0; italic = 0; } - else if (n == "}") { symbol = "}"; } - else if (n == "{") { symbol = "{"; } - else if (n == "hbar") { symbol = "h"; bold = 0; italic = 0; drawBar = true; } - else if (n == "euro") { symbol = ""; bold = 0; italic = 0; } - else if (n == "cent") { symbol = QChar(0xA2); bold = 0; italic = 0; } - else if (n == "pound") { symbol = QChar(0xA3); bold = 0; italic = 0; } - else if (n == "yen") { symbol = QChar(0xA5); bold = 0; italic = 0; } - else if (n == "div") { symbol = QChar(0xF7); bold = 0; italic = 0; } - else if (n == "backslash") { symbol = "\\"; bold = 0; italic = 0; } - //else if (n=="|") { symbol="||"; bold=0; italic=0; } - else if (n == "$") { symbol = "$"; bold = 0; italic = 0; } - else if (n == "%") { symbol = "%"; bold = 0; italic = 0; } - else if (n == "&") { symbol = "&"; bold = 0; italic = 0; } - else if (n == "#") { symbol = "#"; bold = 0; italic = 0; } - else if (n == "ast") { symbol = "*"; bold = 0; italic = 0; } - else if (n == "glq") { symbol = "'"; bold = 0; italic = 0; } - else if (n == "grq") { symbol = "'"; bold = 0; italic = 0; } - else if (n == "glqq") { symbol = "\""; bold = 0; italic = 0; } - else if (n == "grqq") { symbol = "\""; bold = 0; italic = 0; } - else if (n == "flq") { symbol = "<"; bold = 0; italic = 0; } - else if (n == "frq") { symbol = ">"; bold = 0; italic = 0; } - else if (n == "flqq") { symbol = ""; bold = 0; italic = 0; } - else if (n == "frqq") { symbol = ""; bold = 0; italic = 0; } + props.symbol = itsimplehia.value(); + props.heightIsAscent = true; + } else { + props.font=fnt.first; + if (!getSymbolProp(props, n, currentEv, mathFontFactor)) { + errorExplanation="didn't find symbol given font def:"+fnt.first+"["+encoding2String(fnt.second)+"] / sym:"+fntSym.first+"["+encoding2String(fntSym.second)+"] / grk:"+fntGreek.first+"["+encoding2String(fntGreek.second)+"]"; } - //else if (n=="") { symbol=QChar(); font=MTSFdefault; } - //else if (n=="") symbol=QChar(0x); - } - } else if (parent->getFontEncoding() == MTFEunicode) { // use UNICODE encoding for special characters - // first we start with greek characters - font = MTSFdefault; //MTSFgreek; - //std::cout<<"encoding unicode\n"; - QHash::iterator itgreek = unicodeGreek.find(n); - if (itgreek!=unicodeGreek.end()) { - symbol = itgreek.value(); - } else { - // now we set the symbols from the Symbol font - font = MTSFsymbol; - QHash::iterator itsymbol = unicodeSymbol.find(n); - QHash::iterator itbasesymbol = unicodeBaseSymbol.find(n); - if (itbasesymbol!=unicodeBaseSymbol.end()) { - symbol = itbasesymbol.value(); - } else if (itsymbol!=unicodeSymbol.end()) { - symbol = itsymbol.value(); - } - else if (n == "sum") { symbol = QChar(0x2211); heightIsAscent = true; exactAscent = true; } - else if (n == "prod") { symbol = QChar(0x220F); heightIsAscent = true; exactAscent = true; } - else if (n == "bbC") { symbol = QChar(0x2102); italic = -1; } - else if (n == "bbH") { symbol = QChar(0x210D); italic = -1; } - else if (n == "bbN") { symbol = QChar(0x2115); italic = -1; } - else if (n == "bbP") { symbol = QChar(0x2119); italic = -1; } - else if (n == "bbQ") { symbol = QChar(0x211A); italic = -1; } - else if (n == "bbR") { symbol = QChar(0x211D); italic = -1; } - else if (n == "bbZ") { symbol = QChar(0x2124); italic = -1; } - else if (n == "iint") { symbol = QChar(0x222C); fontFactor = mathFontFactor; /*yfactor=+0.1;*/ heightIsAscent = true; exactAscent = true; } - else if (n == "iiint") { symbol = QChar(0x222D); fontFactor = mathFontFactor; /*yfactor=+0.1;*/ heightIsAscent = true; exactAscent = true; } - else if (n == "oint") { symbol = QChar(0x222E); fontFactor = mathFontFactor; /*yfactor=+0.1;*/ heightIsAscent = true; exactAscent = true; } - else if (n == "oiint") { symbol = QChar(0x222F); fontFactor = mathFontFactor; /*yfactor=+0.1;*/ heightIsAscent = true; exactAscent = true; } - else if (n == "oiiint") { symbol = QChar(0x2230); fontFactor = mathFontFactor; /*yfactor=+0.1;*/ heightIsAscent = true; exactAscent = true; } - else if (n == "coprod") { symbol = QChar(0x2210); heightIsAscent = true; exactAscent = true; } - else if (n == "bigcap") { symbol = QChar(0x22C2); heightIsAscent = true; exactAscent = true; heightIsAscent = true; exactAscent = true; } - else if (n == "bigcup") { symbol = QChar(0x22C3); heightIsAscent = true; exactAscent = true; heightIsAscent = true; exactAscent = true; } - else if (n == "bigvee") { symbol = QChar(0x22C1); heightIsAscent = true; exactAscent = true; heightIsAscent = true; exactAscent = true; } - else if (n == "bighat") { symbol = QChar(0x22C0); heightIsAscent = true; exactAscent = true; heightIsAscent = true; exactAscent = true; } - else if (n == "int") { symbol = QChar(0x222B); fontFactor = mathFontFactor; /*yfactor=+0.1;*/ heightIsAscent = true; exactAscent = true; } - - else { // here are text mode symbols, i.e. bold and italic won't be touched - bold = -1; - italic = -1; - font = MTSFdefault; - if (n == "_") { symbol = "_"; } - else if (n == "}") { symbol = "}"; } - else if (n == "{") { symbol = "{"; } - else if (n == "backslash") { symbol = "\\"; bold = 0; italic = 0; } - //else if (n=="|") { symbol=QChar(0x2016); } - else if (n == "$") { symbol = "$"; } - else if (n == "%") { symbol = "%"; } - else if (n == "&") { symbol = "&"; } - else if (n == "#") { symbol = "#"; } - else if (n == "ast") { symbol = "*"; } - else if (n == "glq") { symbol = QChar(0x2018); bold = 0; italic = 0; } - else if (n == "grq") { symbol = QChar(0x2019); bold = 0; italic = 0; } - else if (n == "glqq") { symbol = QChar(0x201C); bold = 0; italic = 0; } - else if (n == "grqq") { symbol = QChar(0x201D); bold = 0; italic = 0; } - else if (n == "flq") { symbol = QChar(0x2039); bold = 0; italic = 0; } - else if (n == "frq") { symbol = QChar(0x203A); bold = 0; italic = 0; } - else if (n == "flqq") { symbol = ""; bold = 0; italic = 0; } - else if (n == "frqq") { symbol = ""; bold = 0; italic = 0; } - } - //else if (n=="") { symbol=QChar(); font=MTSFdefault; } - //else if (n=="") symbol=QChar(0x); - } - } else if (parent->getFontEncoding() == MTFEunicodeLimited) { // use UNICODE encoding for special characters - - // now we set the symbols from the Symbol font - font = MTSFdefault; - QHash::iterator itsymbol = unicodeBaseSymbol.find(n); - if (itsymbol!=unicodeBaseSymbol.end()) { - symbol = itsymbol.value(); - //qDebug()<<"unicodeBaseSymbol: "<::iterator itgreek = winSymbolGreek.find(n); - if (itgreek!=winSymbolGreek.end()) { - symbol = itgreek.value(); - //qDebug()<<"winSymbolGreek: "<::iterator itsymbol = winSymbolSymbol.find(n); - if (itsymbol!=winSymbolSymbol.end()) { - symbol = itsymbol.value(); - //qDebug()<<"winSymbolSymbol: "<getFontEncoding() == MTFElatex) { // use UNICODE encoding for special characters - // first we start with greek characters - font = MTSFdefault; //MTSFgreek; - //std::cout<<"encoding unicode\n"; - QHash::iterator itssymbol = latexSimpleSymbol.find(n); - if (itssymbol!=latexSimpleSymbol.end()) { - symbol = itssymbol.value(); - } else if (n == "backslash") { symbol = "\\"; bold = 0; italic = 0; } - - else { - font = MTSFgreek; - QHash::iterator itgreek = latexGreek.find(n); - if (itgreek!=latexGreek.end()) { - symbol = itgreek.value(); - } else { - // now we set the symbols from the Symbol font - font = MTSFsymbol; - QHash::iterator itsymbol = latexSymbol.find(n); - if (itsymbol!=latexSymbol.end()) { - symbol = itsymbol.value(); - } else if (n == "int") { symbol = QChar(0x73); fontFactor = mathFontFactor; yfactor = +0.1; } - - else { // here are text mode symbols, i.e. bold and italic won't be touched - font = MTSFbraces; - if (n == "bigcap") { symbol = QChar(0x5c); heightIsAscent = true; exactAscent = true; } - else if (n == "bigcup") { symbol = QChar(0x5b); heightIsAscent = true; exactAscent = true; } - else if (n == "bigvee") { symbol = QChar(0x5F); heightIsAscent = true; exactAscent = true; } - else if (n == "bighat") { symbol = QChar(0x5E); heightIsAscent = true; exactAscent = true; } - else if (n == "oint") { symbol = QChar(0x49); yfactor = +0.1; } - else if (n == "coprod") { symbol = QChar(0x61); heightIsAscent = true; exactAscent = true; } - else if (n == "iint") { symbol = QString(2, QChar(0x5A)); yfactor = +0.1; } - else if (n == "iiint") { symbol = QString(3, QChar(0x5A)); yfactor = +0.1; } - else if (n == "sum") { symbol = QChar(0x58); heightIsAscent = true; exactAscent = true; } - else if (n == "prod") { symbol = QChar(0x59); heightIsAscent = true; exactAscent = true; } - - - - } - } - } } - } } - if (addWhitespace) symbol=symbol+" "; + if (addWhitespace) props.symbol+=" "; static QSet extraSymbolName = { "infty", @@ -2797,44 +2824,26 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na "longleftrightarrow", "Longleftrightarrow" }; - if (symbol.simplified().isEmpty() && !extraSymbolName.contains(n)) { - parent->error_list.append(tr("unknown symbol '%1' found!").arg(n)); + if (props.symbol.simplified().isEmpty() && !extraSymbolName.contains(n)) { + parent->error_list.append(tr("unknown symbol '%1' found (%2)!").arg(n).arg(errorExplanation)); } - //std::cout<<"symbol node '"<getFontGreek()); break; - case MTSFsymbol: fr.setFamily(parent->getFontSymbol()); break; - case MTSFbraces: fr.setFamily(parent->getFontBraces()); break; - case MTSFintegrals: fr.setFamily(parent->getFontIntegrals()); break; - case MTSFcaligraphic: fr.setFamily(parent->getFontCaligraphic()); break; - case MTSFblackboard: fr.setFamily(parent->getFontBlackboard()); break; - default: break; - } - return fr; } void JKQTMathText::MTsymbolNode::getSizeInternal(QPainter& painter, JKQTMathText::MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const MTnodeSize* /*prevNodeSize*/) { QFont f=currentEv.getFont(parent); - f=getFontName(font, f); - f.setPointSizeF(f.pointSizeF()*fontFactor); - if (italic<0) f.setItalic(false); - if (italic>0) f.setItalic(true); - if (bold<0) f.setBold(false); - if (bold>0) f.setBold(true); + auto props=getSymbolProp(symbolName, currentEv); + f.setFamily(props.font); + f.setPointSizeF(f.pointSizeF()*props.fontFactor); + if (props.italic<0) f.setItalic(false); + if (props.italic>0) f.setItalic(true); + if (props.bold<0) f.setBold(false); + if (props.bold>0) f.setBold(true); QFontMetricsF fm(f, painter.device()); - QString symb=symbol; + QString symb=props.symbol; width=0; if (currentEv.insideMath) width=qMax(parent->getTightBoundingRect(f, symb, painter.device()).width(),parent->getTightBoundingRect(f, "i", painter.device()).width());//fm.width(symbol); else width=fm.boundingRect(symb).width();//fm.width(symbol); @@ -2860,20 +2869,20 @@ void JKQTMathText::MTsymbolNode::getSizeInternal(QPainter& painter, JKQTMathText QRectF tbr=parent->getTightBoundingRect(f, symb, painter.device()); overallHeight=tbr.height();// fm.height(); baselineHeight=tbr.height()-tbr.bottom(); - if (exactAscent) { + if (props.exactAscent) { //baselineHeight=fm.ascent()*0.8; } - if (heightIsAscent) { + if (props.heightIsAscent) { overallHeight=baselineHeight*1.1; } - if (exactAscent && heightIsAscent) { + if (props.exactAscent && props.heightIsAscent) { //qDebug()<getMathoperatorWidthFactor(); + if (props.extendWidthInMathmode && currentEv.insideMath) width=width*parent->getMathoperatorWidthFactor(); } @@ -2887,18 +2896,19 @@ double JKQTMathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J QFont fold=painter.font(); QFont f=currentEv.getFont(parent); QFont f1=f; - f=getFontName(font, f); - f.setPointSizeF(f.pointSizeF()*fontFactor); - if (italic<0) f.setItalic(false); - if (italic>0) f.setItalic(true); - if (bold<0) f.setBold(false); - if (bold>0) f.setBold(true); + auto props=getSymbolProp(symbolName, currentEv); + f.setFamily(props.font); + f.setPointSizeF(f.pointSizeF()*props.fontFactor); + if (props.italic<0) f.setItalic(false); + if (props.italic>0) f.setItalic(true); + if (props.bold<0) f.setBold(false); + if (props.bold>0) f.setBold(true); QFontMetricsF fm(f, painter.device()); QFontMetricsF fm1(f1, painter.device()); painter.setFont(f); double shift=0; - if (extendWidthInMathmode && currentEv.insideMath) { + if (props.extendWidthInMathmode && currentEv.insideMath) { double origwidth=width/parent->getMathoperatorWidthFactor(); shift=0.5*(width-origwidth); //width=width*parent->getMathoperatorWidthFactor(); @@ -2912,13 +2922,13 @@ double JKQTMathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J p.setStyle(Qt::SolidLine); painter.setPen(p); double xwi=fm.width("x"); - if (!symbol.isEmpty()) { + if (!props.symbol.isEmpty()) { // if the symbol has been recognized in the constructor: draw the symbol - painter.drawText(QPointF(x+shift, y+yfactor*overallHeight), symbol); + painter.drawText(QPointF(x+shift, y+props.yfactor*overallHeight), props.symbol); double xx=x+shift; double yy=y-fm.xHeight()-(parent->getTightBoundingRect(f, "M", painter.device()).height()-fm.xHeight())/3.0; QLineF l(xx, yy, xx+xwi/3.0+((currentEv.italic)?(xwi/3.0):0), yy); - if (drawBar&&l.length()>0) painter.drawLine(l); + if (props.drawBar&&l.length()>0) painter.drawLine(l); // try to draw some often used special symbols, by synthesizing them from // standard characters in the current drawing font @@ -3132,6 +3142,7 @@ bool JKQTMathText::MTsymbolNode::toHtml(QString &html, JKQTMathText::MTenvironme entitylut.insert("copyright", "©"); entitylut.insert("registered", "®"); entitylut.insert("trademark", "™"); + entitylut.insert("textregistered", "™"); entitylut.insert("cdot", "⋅"); entitylut.insert("neg", "¬"); entitylut.insert("wedge", "∧"); @@ -3216,19 +3227,15 @@ QString JKQTMathText::MTsymbolNode::getSymbolName() const { return this->symbolName; } -QString JKQTMathText::MTsymbolNode::getSymbolFontName() const { - QFont f; - switch(font) { - case MTSFsymbol: return "symbol["+getFontName(font, f).family()+"]"; - case MTSFgreek: return "greek["+getFontName(font, f).family()+"]"; - case MTSFbraces: return "braces["+getFontName(font, f).family()+"]"; - case MTSFintegrals: return "integrals["+getFontName(font, f).family()+"]"; - case MTSFcaligraphic: return "caligraphic["+getFontName(font, f).family()+"]"; - case MTSFblackboard: return "blackboard["+getFontName(font, f).family()+"]"; - default: - case MTSFdefault: - return "default["+getFontName(font, f).family()+"]"; - } +QString JKQTMathText::MTsymbolNode::getSymbolfontName() const { + MTenvironment currentEv; + auto props=getSymbolProp(symbolName, currentEv); + return props.font; +} + +bool JKQTMathText::MTsymbolNode::getAddWhitespace() const +{ + return addWhitespace; } @@ -3241,81 +3248,100 @@ JKQTMathText::JKQTMathText(QObject* parent): Q_INIT_RESOURCE(xits); QFontDatabase fontdb; - QString serifFont="Serif"; - QString sansFont="Sans"; - QString symbolFont="Symbol"; - QString scriptFont="Script"; + fontSize=10; + brace_factor=1.04; + subsuper_size_factor=0.7; + italic_correction_factor=0.4; + sub_shift_factor=0.4; + super_shift_factor=0.6; + brace_shrink_factor=0.6; + fontColor=QColor("black"); + + frac_factor=0.9; + frac_shift_factor=0.4; + underbrace_factor=0.75; + undersetFactor=0.7; + decoration_height_factor=0.2; + brace_y_shift_factor=0.7;//-1; + operatorsubsuper_size_factor=0.65; + mathoperator_width_factor=1.5; + + expensiveRendering=true; + blackboardSimulated=true; + + + QString serifFont="serif"; + QString sansFont="sans"; + QString symbolFont="symbol"; + QString scriptFont="script"; QString typewriterFont="typewriter"; QString decorativeFont="decorative"; + QString blackboardFont="blackboard"; + QString fracturFont="fraktur"; QStringList fonts=fontdb.families(); //qDebug()<<"fonts:\n"<0) { + break; } } + if (mathFamily.size()>0) { + break; + } + } + for (const QString& name:textNames) { + for (int i=0; i0) { + break; + } + } + if (textFamily.size()>0) { + break; + } + } + if (mathFamily.isEmpty() && !textFamily.isEmpty()) { + mathFamily=textFamily; + } else if (!mathFamily.isEmpty() && textFamily.isEmpty()) { + textFamily=mathFamily; + } + + bool res=false; + + if (!mathModeOnly && !textFamily.isEmpty()) { + setFontRoman(textFamily, MTFEunicode); + res=true; + } + if (!mathFamily.isEmpty()) { + setFontMathRoman(mathFamily, MTFEunicode); + res=true; } - fontGreek=fontname; - fontSymbol=fontname; - fontBraces=fontname; - fontIntegrals=fontname; - fontRoman=fontnametxt; - fontEncoding=MTFEunicode; brace_shrink_factor=0.6; + return res; } -void JKQTMathText::useXITS() +bool JKQTMathText::useXITS(bool mathModeOnly) { - //JKQTPAutoOutputTimer jkaaot(QString("JKQTMathText::useXITS():ALL")); QFontDatabase fdb; - //qDebug()<<"has XITS: "<0 && textFamily.size()>0) { + break; } - } else { - hasXITS=true; } - QString fam="XITS"; - if (hasXITS) fam=defaultXITSFontName; - //if (hasXITSMath) fam=defaultXITSMathFontName; - useXITSfonts=true; - fontRoman=fam; - //fontSans=fam; - //fontTypewriter=fam; - fontBlackboard=fam; - //fontCaligraphic=fam; - //fontScript=fam; - fontBraces=fam; - fontSymbol=fam; - fontGreek=fam; - fontEncoding=MTFEunicode; + if (mathFamily.isEmpty() && !textFamily.isEmpty()) { + mathFamily=textFamily; + } else if (!mathFamily.isEmpty() && textFamily.isEmpty()) { + textFamily=mathFamily; + } + + bool res=false; + + if (!mathModeOnly && !textFamily.isEmpty()) { + setFontRoman(textFamily, MTFEunicode); + res=true; + } + if (!mathFamily.isEmpty()) { + setFontMathRoman(mathFamily, MTFEunicode); + res=true; + } + brace_shrink_factor=0.6; + return res; + } -void JKQTMathText::useASANA() +bool JKQTMathText::useASANA(bool mathModeOnly) { QFontDatabase fdb; -#ifdef AUTOLOAD_XITS_FONTS - //qDebug()<<"has XITS: "<0 && textFamily.size()>0) { + break; } } - QString fam="Asana Math"; - if (hasXITS) fam=XITSfam; - useXITSfonts=true; - fontRoman=fam; - //fontSans=fam; - fontTypewriter=fam; - fontBlackboard=fam; - fontCaligraphic=fam; - fontScript=fam; - fontBraces=fam; - fontSymbol=fam; - fontGreek=fam; - fontEncoding=MTFEunicode; + if (mathFamily.isEmpty() && !textFamily.isEmpty()) { + mathFamily=textFamily; + } else if (!mathFamily.isEmpty() && textFamily.isEmpty()) { + textFamily=mathFamily; + } + + bool res=false; + + if (!mathModeOnly && !textFamily.isEmpty()) { + setFontRoman(textFamily, MTFEunicode); + res=true; + } + if (!mathFamily.isEmpty()) { + setFontMathRoman(mathFamily, MTFEunicode); + res=true; + } + + brace_shrink_factor=0.6; + return res; +} + +void JKQTMathText::useAnyUnicode(QString timesFont, const QString &sansFont, JKQTMathText::MTfontEncoding encodingTimes, JKQTMathText::MTfontEncoding encodingSans) +{ + if (!timesFont.isEmpty()) { setFontRoman(timesFont, encodingTimes); } + if (!sansFont.isEmpty()) { setFontSans(sansFont, encodingSans); } brace_shrink_factor=0.6; } -void JKQTMathText::useLatexFonts(QString prefix, const QString& postfix) { - fontLatexPostfix=postfix; - fontLatexPrefix=prefix; - fontRoman=prefix+"cmr"+postfix; - fontSans=prefix+"cmss"+postfix; - fontTypewriter=prefix+"cmtt"+postfix; - fontBlackboard=prefix+"dsrom"+postfix; - fontCaligraphic=prefix+"csmy"+postfix; - fontScript=prefix+"rsfs"+postfix; - fontBraces=prefix+"cmex"+postfix; - fontSymbol=prefix+"cmsy"+postfix; - fontGreek=prefix+"cmmi"+postfix; - fontEncoding=MTFElatex; - brace_shrink_factor=0.6; -} QString JKQTMathText::toHtml(bool *ok, double fontPointSize) { QString s; @@ -3573,10 +3574,71 @@ QString JKQTMathText::toHtml(bool *ok, double fontPointSize) { return s; } +QString JKQTMathText::encoding2String(JKQTMathText::MTfontEncoding e) +{ + switch(e) { + case MTFEunicode: return "MTFEunicode"; + case MTFEStandard: return "MTFEStandard"; + case MTFEunicodeLimited: return "MTFEunicodeLimited"; + case MTFEwinSymbol: return "MTFEwinSymbol"; + } + return "???"; +} + +void JKQTMathText::setFontColor(const QColor &__value) +{ + this->fontColor = __value; +} + +QColor JKQTMathText::getFontColor() const +{ + return this->fontColor; +} + +void JKQTMathText::setFontSize(double __value) +{ + this->fontSize = __value; +} + +double JKQTMathText::getFontSize() const +{ + return this->fontSize; +} + +void JKQTMathText::addReplacementFont(const QString &nonUseFont, const QString &useFont, MTfontEncoding useFontEncoding) { + fontReplacements.insert(nonUseFont, useFont); + fontEncodingReplacements.insert(nonUseFont, useFontEncoding); +} + void JKQTMathText::addReplacementFont(const QString &nonUseFont, const QString &useFont) { fontReplacements.insert(nonUseFont, useFont); + auto it=fontEncodingReplacements.find(nonUseFont); + if (it!=fontEncodingReplacements.end()) fontEncodingReplacements.erase(it); } +QPair JKQTMathText::getReplacementFont(const QString &nonUseFont, const QString &defaultFont, JKQTMathText::MTfontEncoding defaultFontEncoding) const { + QPair res(defaultFont, defaultFontEncoding); + bool foundFont=false; + for (auto it=fontReplacements.begin(); it!=fontReplacements.end(); ++it) { + if (it.key().toLower()==nonUseFont.toLower()) { + foundFont=true; + res.first=it.value(); + res.second=fontEncodingReplacements.value(res.first, res.second); + return res; + } + } + return res; +} + +QPair JKQTMathText::getFontData(JKQTMathText::MTenvironmentFont font, bool /*in_math_environment*/, FontSubclass subclass) const +{ + auto fd=fontDefinitions.value(font); + if (subclass==FontSubclass::Greek) return QPair(fd.symbolfontGreek, fd.symbolfontGreekEncoding); + if (subclass==FontSubclass::Symbols) return QPair(fd.symbolfontSymbol, fd.symbolfontSymbolEncoding); + else return QPair(fd.fontName, fd.fontEncoding); +} + + void JKQTMathText::setFontRomanOrSpecial(const QString &__value) { if (__value.toUpper()=="XITS") { @@ -3601,25 +3663,383 @@ void JKQTMathText::setFontRomanOrSpecial(const QString &__value) } } - -void JKQTMathText::useAnyUnicode(QString timesFont, const QString& sansFont, bool fullMathUnicodeFont) { - if (!timesFont.isEmpty()) { setFontRoman(timesFont); } - if (!sansFont.isEmpty()) { setFontSans(sansFont); } - useSTIXfonts=false; - useXITSfonts=false; - useASANAfonts=false; - if (fullMathUnicodeFont) { - fontGreek=fontRoman; - fontSymbol=fontRoman; - fontIntegrals=fontRoman; - fontEncoding=MTFEunicode; - } else { - fontEncoding=MTFEunicodeLimited; - } - fontBraces=fontRoman; - brace_shrink_factor=0.6; +void JKQTMathText::setFontRoman(const QString &__value, MTfontEncoding encoding) +{ + auto f=getReplacementFont(__value, __value, encoding); + fontDefinitions[MTEroman].fontName = f.first;; + fontDefinitions[MTEroman].fontEncoding = f.second;; } +QString JKQTMathText::getFontRoman() const +{ + return fontDefinitions[MTEroman].fontName; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getFontEncodingRoman() const +{ + return fontDefinitions[MTEroman].fontEncoding; +} + +void JKQTMathText::setFontSans(const QString &__value, MTfontEncoding encoding) +{ + auto f=getReplacementFont(__value, __value, encoding); + fontDefinitions[MTEsans].fontName = f.first;; + fontDefinitions[MTEsans].fontEncoding = f.second;; +} + +QString JKQTMathText::getFontSans() const +{ + return fontDefinitions[MTEsans].fontName; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getFontEncodingSans() const +{ + return fontDefinitions[MTEsans].fontEncoding; +} + +void JKQTMathText::setFontTypewriter(const QString &__value, MTfontEncoding encoding) +{ + auto f=getReplacementFont(__value, __value, encoding); + fontDefinitions[MTEtypewriter].fontName = f.first;; + fontDefinitions[MTEtypewriter].fontEncoding = f.second;; +} + +QString JKQTMathText::getFontTypewriter() const +{ + return fontDefinitions[MTEtypewriter].fontName; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getFontEncodingTypewriter() const +{ + return fontDefinitions[MTEtypewriter].fontEncoding; +} + +void JKQTMathText::setFontScript(const QString &__value, MTfontEncoding encoding) +{ + auto f=getReplacementFont(__value, __value, encoding); + fontDefinitions[MTEscript].fontName = f.first;; + fontDefinitions[MTEscript].fontEncoding = f.second;; +} + +QString JKQTMathText::getFontScript() const +{ + return fontDefinitions[MTEscript].fontName; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getFontEncodingScript() const +{ + return fontDefinitions[MTEscript].fontEncoding; +} + +void JKQTMathText::setFontFraktur(const QString &__value, MTfontEncoding encoding) +{ + auto f=getReplacementFont(__value, __value, encoding); + fontDefinitions[MTEfraktur].fontName = f.first;; + fontDefinitions[MTEfraktur].fontEncoding = f.second;; +} + +QString JKQTMathText::getFontFraktur() const +{ + return fontDefinitions[MTEfraktur].fontName; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getFontEncodingFraktur() const +{ + return fontDefinitions[MTEfraktur].fontEncoding; +} +void JKQTMathText::setSymbolfontGreek(MTenvironmentFont font, const QString &__value, MTfontEncoding encoding) +{ + auto f=getReplacementFont(__value, __value, encoding); + fontDefinitions[font].symbolfontGreek = f.first;; + fontDefinitions[font].symbolfontGreekEncoding = f.second;; +} + +void JKQTMathText::setSymbolfontGreek(const QString &fontName, JKQTMathText::MTfontEncoding encoding) +{ + for (int f=0; f(MTenvironmentFontCount); f++) { + setSymbolfontGreek(static_cast(f), fontName, encoding); + } +} + +QString JKQTMathText::getSymbolfontGreek(MTenvironmentFont font) const +{ + return fontDefinitions[font].symbolfontGreek; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getSymbolfontEncodingGreek(MTenvironmentFont font) const +{ + return fontDefinitions[font].symbolfontGreekEncoding; +} + +void JKQTMathText::setSymbolfontSymbol(MTenvironmentFont font, const QString &__value, MTfontEncoding encoding) +{ + auto f=getReplacementFont(__value, __value, encoding); + fontDefinitions[font].symbolfontSymbol = f.first;; + fontDefinitions[font].symbolfontSymbolEncoding = f.second;; +} + +void JKQTMathText::setSymbolfontSymbol(const QString &fontName, JKQTMathText::MTfontEncoding encoding) +{ + for (int f=0; f(MTenvironmentFontCount); f++) { + setSymbolfontSymbol(static_cast(f), fontName, encoding); + } +} + +QString JKQTMathText::getSymbolfontSymbol(MTenvironmentFont font) const +{ + return fontDefinitions[font].symbolfontSymbol; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getSymbolfontEncodingSymbol(MTenvironmentFont font) const +{ + return fontDefinitions[font].symbolfontSymbolEncoding; +} + +void JKQTMathText::setFontCaligraphic(const QString &__value, MTfontEncoding encoding) +{ + auto f=getReplacementFont(__value, __value, encoding); + fontDefinitions[MTEcaligraphic].fontName = f.first;; + fontDefinitions[MTEcaligraphic].fontEncoding = f.second;; +} + +QString JKQTMathText::getFontCaligraphic() const +{ + return fontDefinitions[MTEcaligraphic].fontName; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getFontEncodingCaligraphic() const +{ + return fontDefinitions[MTEcaligraphic].fontEncoding; +} + +void JKQTMathText::setFontMathRoman(const QString &fontName, JKQTMathText::MTfontEncoding encoding) +{ + auto f=getReplacementFont(fontName, fontName, encoding); + fontDefinitions[MTEmathRoman].fontName = f.first; + fontDefinitions[MTEmathRoman].fontEncoding = f.second; +} + +QString JKQTMathText::getFontMathRoman() const +{ + return fontDefinitions[MTEmathRoman].fontName; +} + +void JKQTMathText::setFontMathSans(const QString &fontName, JKQTMathText::MTfontEncoding encoding) +{ + auto f=getReplacementFont(fontName, fontName, encoding); + fontDefinitions[MTEmathSans].fontName = f.first; + fontDefinitions[MTEmathSans].fontEncoding = f.second; +} + +QString JKQTMathText::getFontMathSans() const +{ + return fontDefinitions[MTEmathSans].fontName; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getFontEncodingMathSans() const +{ + return fontDefinitions[MTEmathSans].fontEncoding; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getFontEncodingMathRoman() const +{ + return fontDefinitions[MTEmathRoman].fontEncoding; +} + +void JKQTMathText::setFontBlackboard(const QString &__value, MTfontEncoding encoding) +{ + blackboardSimulated=false; + auto f=getReplacementFont(__value, __value, encoding); + fontDefinitions[MTEblackboard].fontName = f.first;; + fontDefinitions[MTEblackboard].fontEncoding = f.second;; +} + +void JKQTMathText::setFontBlackboardSimulated(bool doSimulate) +{ + blackboardSimulated=doSimulate; +} + +bool JKQTMathText::isFontBlackboardSimulated() const +{ + return blackboardSimulated; +} + +QString JKQTMathText::getFontBlackboard() const +{ + return fontDefinitions[MTEblackboard].fontName; +} + +JKQTMathText::MTfontEncoding JKQTMathText::getFontEncodingBlackboard() const +{ + return fontDefinitions[MTEblackboard].fontEncoding; +} + + +void JKQTMathText::setBraceFactor(double __value) +{ + this->brace_factor = __value; +} + +double JKQTMathText::getBraceFactor() const +{ + return this->brace_factor; +} + +void JKQTMathText::setSubsuperSizeFactor(double __value) +{ + this->subsuper_size_factor = __value; +} + +double JKQTMathText::getSubsuperSizeFactor() const +{ + return this->subsuper_size_factor; +} + +void JKQTMathText::setItalicCorrectionFactor(double __value) +{ + this->italic_correction_factor = __value; +} + +double JKQTMathText::getItalicCorrectionFactor() const +{ + return this->italic_correction_factor; +} + +void JKQTMathText::setOperatorsubsuperSizeFactor(double __value) +{ + this->operatorsubsuper_size_factor = __value; +} + +double JKQTMathText::getOperatorsubsuperSizeFactor() const +{ + return this->operatorsubsuper_size_factor; +} + +void JKQTMathText::setMathoperatorWidthFactor(double __value) +{ + this->mathoperator_width_factor = __value; +} + +double JKQTMathText::getMathoperatorWidthFactor() const +{ + return this->mathoperator_width_factor; +} + +void JKQTMathText::setSuperShiftFactor(double __value) +{ + this->super_shift_factor = __value; +} + +double JKQTMathText::getSuperShiftFactor() const +{ + return this->super_shift_factor; +} + +void JKQTMathText::setSubShiftFactor(double __value) +{ + this->sub_shift_factor = __value; +} + +double JKQTMathText::getSubShiftFactor() const +{ + return this->sub_shift_factor; +} + +void JKQTMathText::setBraceShrinkFactor(double __value) +{ + this->brace_shrink_factor = __value; +} + +double JKQTMathText::getBraceShrinkFactor() const +{ + return this->brace_shrink_factor; +} + +void JKQTMathText::setUnderbraceFactor(double __value) +{ + this->underbrace_factor = __value; +} + +double JKQTMathText::getUnderbraceFactor() const +{ + return this->underbrace_factor; +} + +void JKQTMathText::setUndersetFactor(double __value) +{ + this->undersetFactor = __value; +} + +double JKQTMathText::getUndersetFactor() const +{ + return this->undersetFactor; +} + +void JKQTMathText::setFracFactor(double __value) +{ + this->frac_factor = __value; +} + +double JKQTMathText::getFracFactor() const +{ + return this->frac_factor; +} + +void JKQTMathText::setFracShiftFactor(double __value) +{ + this->frac_shift_factor = __value; +} + +double JKQTMathText::getFracShiftFactor() const +{ + return this->frac_shift_factor; +} + +void JKQTMathText::setBraceYShiftFactor(double __value) +{ + this->brace_y_shift_factor = __value; +} + +double JKQTMathText::getBraceYShiftFactor() const +{ + return this->brace_y_shift_factor; +} + +void JKQTMathText::setDecorationHeightFactor(double __value) +{ + this->decoration_height_factor = __value; +} + +double JKQTMathText::getDecorationHeightFactor() const +{ + return this->decoration_height_factor; +} + +void JKQTMathText::setExpensiveRendering(bool __value) +{ + this->expensiveRendering = __value; +} + +bool JKQTMathText::getExpensiveRendering() const +{ + return this->expensiveRendering; +} + +void JKQTMathText::setUseUnparsed(bool __value) +{ + this->useUnparsed = __value; +} + +bool JKQTMathText::isUsingUnparsed() const +{ + return this->useUnparsed; +} + +QStringList JKQTMathText::getErrorList() const { + return this->error_list; +} + + JKQTMathText::tokenType JKQTMathText::getToken() { currentTokenID++; @@ -4129,6 +4549,10 @@ JKQTMathText::MTnode* JKQTMathText::parseLatexString(bool get, const QString& qu return nl; } +JKQTMathText::MTnode *JKQTMathText::getParsedNode() const { + return this->parsedNode; +} + QList JKQTMathText::tbrs=QList(); QHash JKQTMathText::tbrh=QHash(); @@ -4357,6 +4781,11 @@ QString JKQTMathText::decorationToString(JKQTMathText::MTdecoration mode) return "unknown"; } +JKQTMathText::MTnode *JKQTMathText::getTree() const { + if (useUnparsed) return unparsedNode; + return parsedNode; +} + JKQTMathTextLabel::JKQTMathTextLabel(QWidget *parent): QLabel(parent) { @@ -4502,8 +4931,8 @@ JKQTMathText::MTplainTextNode::MTplainTextNode(JKQTMathText *parent, const QStri } QString JKQTMathText::MTplainTextNode::getTypeName() const -{return QLatin1String("MTplainTextNode(")+text+")"; - +{ + return QLatin1String("MTplainTextNode(")+text+")"; } @@ -4517,4 +4946,16 @@ void initJKQTMathTextResources() Q_INIT_RESOURCE(xits); } -JKQTMathText::MTnodeSize::MTnodeSize(): width(0), baselineHeight(0),overallHeight(0),strikeoutPos() {} +JKQTMathText::MTnodeSize::MTnodeSize(): + width(0), baselineHeight(0),overallHeight(0),strikeoutPos() +{ + +} + +JKQTMathText::FontDefinition::FontDefinition(): + fontName("Times New Roman"), fontEncoding(MTFEStandard), + symbolfontGreek("Symbol"), symbolfontGreekEncoding(MTFEwinSymbol), + symbolfontSymbol("Symbol"), symbolfontSymbolEncoding(MTFEwinSymbol) +{ + +} diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h index d6ce32a268..44d2119c40 100644 --- a/lib/jkqtmathtext/jkqtmathtext.h +++ b/lib/jkqtmathtext/jkqtmathtext.h @@ -185,10 +185,10 @@ JKQTMATHTEXT_LIB_EXPORT void initJKQTMathTextResources(); - A "sans-serif" font which may be activated with \c \\sf ... ( setFontSans() ) - A "typewriter" font which may be activated with \c \\tt ... ( setFontTypewriter() ) - A "script" font which may be activated with \c \\script ... ( setFontScript() ) - - A greek font which is used to display greek letters \c \\alpha ... ( setFontGreek() ) - - A symbol font used to display special (math) symbols. - - A "roman" font used as the standard font in math mode - - A "sans-serif" used as sans serif font in math mode + - A greek font which is used to display greek letters \c \\alpha ... ( setSymbolfontGreek() ) + - A symbol font used to display special (math) symbols. ( setSymbolfontSymbol() ) + - A "roman" font used as the standard font in math mode ( setFontMathRoman() ) + - A "sans-serif" used as sans serif font in math mode ( setFontMathSans() ) - A "blackboard" font used to display double stroked characters (setFontBlackboard() ) - A "caligraphic" font used to display caligraphic characters ( setFontCaligraphic() ) . @@ -249,13 +249,171 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ void draw(QPainter& painter, unsigned int flags, QRectF rect, bool drawBoxes=false); + + /** \brief convert LaTeX to HTML. returns \c ok=true on success and \c ok=false else. */ + QString toHtml(bool* ok=nullptr, double fontPointSize=10); + + /*! \brief used to specify the font encoding used for drawing + */ + enum MTfontEncoding { + MTFEwinSymbol, /*!< \brief This assumes that symbols shall be taken from a MS Windows style Symbol font */ + MTFEunicode, /*!< \brief This assumes that symbols shall be taken from a Unicode font (e.g. the STIX fonts from http://www.stixfonts.org/)*/ + MTFEunicodeLimited, /*!< \brief This assumes that the fonts used are Unicode, but only offer a limited set of symbols. Especially math symbols are missing from this encoding */ + MTFEStandard, /*!< \brief the encoding of a standard TTF font (i.e. we can only expect letters,number and not many special characters) */ + }; + + /** \brief convert MTfontEncoding to a string */ + static QString encoding2String(MTfontEncoding e); + + + /** \brief the available logical fonts (default is MTEroman) */ + enum MTenvironmentFont { + MTEroman, /*!< \brief roman font, e.g. \\rm{} */ + MTEsans, /*!< \brief sans-serif font, e.g. \\sf{} */ + MTEmathRoman, /*!< \brief math-mode roman font, e.g. \\mathrm{} */ + MTEmathSans, /*!< \brief math-mode sans-serif font, e.g. \\mathsf{} */ + MTEtypewriter, /*!< \brief typewriter font, e.g. \\tt{},\\mathtt{} */ + MTEscript, /*!< \brief script font, e.g. \\script{},\\mathscript{} */ + MTEblackboard, /*!< \brief blackboard font, e.g. \\mathbb{} */ + MTEcaligraphic, /*!< \brief caligraphic font, e.g. \\mathcal{} */ + MTEfraktur, /*!< \brief fraktur font, e.g. \\mathfrak{} */ + + MTenvironmentFontCount /*!< \brief internal enum value that allows to iterate over MTenvironmentFont \internal */ + }; + + + /*! \copydoc fontColor */ + void setFontColor(const QColor & __value); + /*! \copydoc fontColor */ + QColor getFontColor() const; + /*! \copydoc fontSize */ + void setFontSize(double __value); + /*! \copydoc fontSize */ + double getFontSize() const; + /** \brief add a font pair to the table with font replacements + * + * e.g. if it is known that a certain font is not good for rendering, you can add an alternative with this function. + * These are automatically applied, when setting a new font name! + * + * \param nonUseFont the font not to use + * \param useFont replacement font for nonUseFont + * + * The entry in the encodings for this font is kept empty (or even deleted), so the default encoding of the font to be replaced is used! + */ + void addReplacementFont(const QString& nonUseFont, const QString& useFont); + /** \brief add a font pair to the table with font replacements + * + * e.g. if it is known that a certain font is not good for rendering, you can add an alternative with this function. + * These are automatically applied, when setting a new font name! + * + * \param nonUseFont the font not to use + * \param useFont replacement font for nonUseFont + * \param useFontEncoding encoding of the replacement font + */ + void addReplacementFont(const QString& nonUseFont, const QString& useFont, MTfontEncoding useFontEncoding); + /** \brief retrieves a replacement for the given font name \a nonUseFont, including its encoding. Returns the given default values \a defaultFont and/or \a defaultFontEncoding if one of the two is not found */ + QPair getReplacementFont(const QString &nonUseFont, const QString &defaultFont, MTfontEncoding defaultFontEncoding) const; + + enum class FontSubclass { + Text, + Default=Text, + Symbols, + Greek, + }; + + /** \brief retrieve the font and encoding to be used for \a font, which might optionally be typeset inside a math environment, specified by in_math_environment, possibly for the given font subclass \a subclass */ + QPair getFontData(MTenvironmentFont font, bool in_math_environment=false, FontSubclass subclass=FontSubclass::Default) const; + + /*! \brief calls setFontRoman(), or calls useXITS() if \a __value \c =="XITS". calls useSTIX() if \a __value \c =="STIX", ... + + \see setFontRoman(), useXITS(), useSTIX() for more information */ + void setFontRomanOrSpecial(const QString & fontName); + + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEroman */ + void setFontRoman(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief retrieves the font to be used for text in the logical font MTEroman */ + QString getFontRoman() const; + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEsans */ + void setFontSans(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief retrieves the font to be used for text in the logical font MTEsans */ + QString getFontSans() const; + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEtypewriter */ + void setFontTypewriter(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief retrieves the font to be used for text in the logical font MTEtypewriter */ + QString getFontTypewriter() const; + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEscript */ + void setFontScript(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief retrieves the font to be used for text in the logical font MTEscript */ + QString getFontScript() const; + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEfraktur */ + void setFontFraktur(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief retrieves the font to be used for text in the logical font MTEfraktur */ + QString getFontFraktur() const; + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEcaligraphic */ + void setFontCaligraphic(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief retrieves the font to be used for text in the logical font MTEcaligraphic */ + QString getFontCaligraphic() const; + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEblackboard */ + void setFontBlackboard(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief blackboard font is simulated by using roman with outlines only */ + void setFontBlackboardSimulated(bool doSimulate); + /*! \brief is blackboard font simulated by using roman with outlines only */ + bool isFontBlackboardSimulated() const; + /*! \brief retrieves the font to be used for text in the logical font MTEblackboard */ + QString getFontBlackboard() const; + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for greek letters in the logical font \a font */ + void setSymbolfontGreek(MTenvironmentFont font, const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for integrals in all logical fonts */ + void setSymbolfontGreek(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief retrieves the font to be used for greek letters in the logical font \a font */ + QString getSymbolfontGreek(MTenvironmentFont font) const; + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for symbols in the logical font \a font */ + void setSymbolfontSymbol(MTenvironmentFont font, const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for integrals in all logical fonts */ + void setSymbolfontSymbol(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief retrieves the font to be used for symbols in the logical font \a font */ + QString getSymbolfontSymbol(MTenvironmentFont font) const; + + /*! \brief retrieves the encoding used for the symbol font to be used for symbols in the logical font \a font */ + MTfontEncoding getSymbolfontEncodingSymbol(MTenvironmentFont font) const; + /*! \brief retrieves the encoding used for the greek letter font to be used for symbols in the logical font \a font */ + MTfontEncoding getSymbolfontEncodingGreek(MTenvironmentFont font) const; + /*! \brief retrieves the encoding used for the script font */ + MTfontEncoding getFontEncodingScript() const; + /*! \brief retrieves the encoding used for the Fraktur font */ + MTfontEncoding getFontEncodingFraktur() const; + /*! \brief retrieves the encoding used for the typewriter font */ + MTfontEncoding getFontEncodingTypewriter() const; + /*! \brief retrieves the encoding used for the sans-serif font */ + MTfontEncoding getFontEncodingSans() const; + /*! \brief retrieves the encoding used for the roman font */ + MTfontEncoding getFontEncodingRoman() const; + /*! \brief retrieves the encoding used for the blackboard font */ + MTfontEncoding getFontEncodingBlackboard() const; + /*! \brief retrieves the encoding used for the caligraphic font */ + JKQTMathText::MTfontEncoding getFontEncodingCaligraphic() const; + + + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEmathRoman */ + void setFontMathRoman(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief retrieves the font to be used for text in the logical font MTEroman */ + QString getFontMathRoman() const; + /*! \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEmathSans */ + void setFontMathSans(const QString & fontName, MTfontEncoding encoding=MTfontEncoding::MTFEStandard); + /*! \brief retrieves the font to be used for text in the logical font MTEsans */ + QString getFontMathSans() const; + /*! \brief retrieves the encoding used for the math-mode sans-serif font */ + MTfontEncoding getFontEncodingMathSans() const; + /*! \brief retrieves the encoding used for the math-mode roman font */ + MTfontEncoding getFontEncodingMathRoman() const; + /** \brief configures the class to use the STIX fonts in mathmode * * use STIX (1.x/2.x) fonts from https://www.stixfonts.org/ in math-mode * * \image html jkqtmathparser_stix.png */ - void useSTIX(); + bool useSTIX(bool mathModeOnly=true); /** \brief configures the class to use the XITS fonts in mathmode * @@ -264,7 +422,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { * * \image html jkqtmathparser_xits.png */ - void useXITS(); + bool useXITS(bool mathModeOnly=true); /** \brief configures the class to use the ASANA fonts in mathmode * @@ -272,395 +430,92 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { * * \image html jkqtmathparser_asana.png */ - void useASANA(); + bool useASANA(bool mathModeOnly=true); - /** \brief configures the class to use a unicode font for symbols in mathmode + /** \brief sets \a timesFont (with its encoding \a encodingTimes ) for serif-text and \a sansFont (with its encoding \a encodingSans ) for both mathmode and textmode fonts * * use generic Unicode fonts, e.g. "Arial" and "Times New Roman" in math-mode. * You should use fonts that contain as many of the mathematical symbols as possible to ensure good rendering results. * - * setAnyUnicode("Times New Roman", "Times New Roman"):
\image html jkqtmathparser_timesnewroman.png - * setAnyUnicode("Arial", "Arial"):
\image html jkqtmathparser_arial.png - * setAnyUnicode("Courier New", "Courier New"):
\image html jkqtmathparser_couriernew.png - * setAnyUnicode("Comic Sans MS", "Comic Sans MS"):
\image html jkqtmathparser_comicsans.png + * setAnyUnicode("Times New Roman", "Times New Roman"):
\image html jkqtmathparser_timesnewroman.png

+ * setAnyUnicode("Arial", "Arial"):
\image html jkqtmathparser_arial.png

+ * setAnyUnicode("Courier New", "Courier New"):
\image html jkqtmathparser_couriernew.png

+ * setAnyUnicode("Comic Sans MS", "Comic Sans MS"):
\image html jkqtmathparser_comicsans.png

* - * The parameter \a fullMathUnicodeFont specifies, whether the unicode fonts encode also math symbols, or are - * limited to latin+greek+basic symbols. */ - void useAnyUnicode(QString timesFont=QString(""), const QString& sansFont=QString(""), bool fullMathUnicodeFont=false); - - void useLatexFonts(QString prefix=QString(""), const QString& postfix=QString("")); - - /** \brief convert LaTeX to HTML. returns \c ok=true on success and \c ok=false else. */ - QString toHtml(bool* ok=nullptr, double fontPointSize=10); - - /*! \brief used to specify the font encoding used for drawing - - - \c MTFEwinSymbol: This assumes that symbols shal be taken from a MS Windows style Symbol font - - \c MTFElatex: This assumes that symbols shal be taken from the CM (computer modern) fonts, used by LaTeX - - \c MTFEunicode: This assumes that symbols shall be taken from a Unicode font - (e.g. the STIX fonts from http://www.stixfonts.org/) - - \c MTFEunicodeLimited: This assumes that the fonts used are Unicode, but only offer a limited set of symbols. - Especially math symbols are missing from this encoding - . - */ - enum MTfontEncoding { - MTFEwinSymbol, - MTFEunicode, - MTFEunicodeLimited, - MTFElatex - }; - - /*! \copydoc fontColor */ - inline void setFontColor(const QColor & __value) - { - this->fontColor = __value; - } - /*! \copydoc fontColor */ - inline QColor getFontColor() const - { - return this->fontColor; - } - /*! \copydoc fontSize */ - inline void setFontSize(double __value) - { - this->fontSize = __value; - } - /*! \copydoc fontSize */ - inline double getFontSize() const - { - return this->fontSize; - } - /** \brief add a font pair to the table with font replacements - * - * e.g. if it is known that a certain font is not good for rendering, you can add an alternative with this function. - * These are automatically applied, when setting a new font name! - * - * \param nonUseFont the font not to use - * \param useFont replacement font for nonUseFont - */ - void addReplacementFont(const QString& nonUseFont, const QString& useFont); + void useAnyUnicode(QString timesFont=QString(""), const QString& sansFont=QString(""), MTfontEncoding encodingTimes=MTfontEncoding::MTFEunicode, MTfontEncoding encodingSans=MTfontEncoding::MTFEunicode); - /*! \copydoc fontRoman */ - inline void setFontRoman(const QString & __value) - { - this->fontRoman = fontReplacements.value(__value, __value); - } - /*! \brief sets the property fontRoman ( \copybrief fontRoman ) to \a __value, or calls useXITS() if \a __value \c =="XITS". calls useSTIX() if \a __value \c =="STIX", ... - \see fontRoman for more information */ - void setFontRomanOrSpecial(const QString & __value); - /*! \copydoc fontRoman */ - inline QString getFontRoman() const - { - return this->fontRoman; - } - /*! \copydoc fontSans */ - inline void setFontSans(const QString & __value) - { - this->fontSans = fontReplacements.value(__value, __value); - } - /*! \copydoc fontSans */ - inline QString getFontSans() const - { - return this->fontSans; - } - /*! \copydoc fontTypewriter */ - inline void setFontTypewriter(const QString & __value) - { - this->fontTypewriter = __value; - } - /*! \copydoc fontTypewriter */ - inline QString getFontTypewriter() const - { - return this->fontTypewriter; - } - /*! \copydoc fontScript */ - inline void setFontScript(const QString & __value) - { - this->fontScript = __value; - } - /*! \copydoc fontScript */ - inline QString getFontScript() const - { - return this->fontScript; - } - /*! \copydoc fontGreek */ - inline void setFontGreek(const QString & __value) - { - this->fontGreek = __value; - } - /*! \copydoc fontGreek */ - inline QString getFontGreek() const - { - return this->fontGreek; - } - /*! \copydoc fontSymbol */ - inline void setFontSymbol(const QString & __value) - { - this->fontSymbol = __value; - } - /*! \copydoc fontSymbol */ - inline QString getFontSymbol() const - { - return this->fontSymbol; - } - /*! \copydoc fontBraces */ - inline void setFontBraces(const QString & __value) - { - this->fontBraces = __value; - } - /*! \copydoc fontBraces */ - inline QString getFontBraces() const - { - return this->fontBraces; - } - /*! \copydoc fontIntegrals */ - inline void setFontIntegrals(const QString & __value) - { - this->fontIntegrals = __value; - } - /*! \copydoc fontIntegrals */ - inline QString getFontIntegrals() const - { - return this->fontIntegrals; - } - /*! \copydoc fontCaligraphic */ - inline void setFontCaligraphic(const QString & __value) - { - this->fontCaligraphic = __value; - } - /*! \copydoc fontCaligraphic */ - inline QString getFontCaligraphic() const - { - return this->fontCaligraphic; - } - /*! \copydoc fontBlackboard */ - inline void setFontBlackboard(const QString & __value) - { - this->fontBlackboard = __value; - } - /*! \copydoc fontBlackboard */ - inline QString getFontBlackboard() const - { - return this->fontBlackboard; - } - /*! \copydoc fontLatexPrefix */ - inline void setFontLatexPrefix(const QString & __value) - { - this->fontLatexPrefix = __value; - } - /*! \copydoc fontLatexPrefix */ - inline QString getFontLatexPrefix() const - { - return this->fontLatexPrefix; - } - /*! \copydoc fontLatexPostfix */ - inline void setFontLatexPostfix(const QString & __value) - { - this->fontLatexPostfix = __value; - } - /*! \copydoc fontLatexPostfix */ - inline QString getFontLatexPostfix() const - { - return this->fontLatexPostfix; - } - /*! \copydoc fontEncoding */ - inline void setFontEncoding(const MTfontEncoding & __value) - { - this->fontEncoding = __value; - } - /*! \copydoc fontEncoding */ - inline MTfontEncoding getFontEncoding() const - { - return this->fontEncoding; - } - /*! \copydoc useSTIXfonts */ - inline bool isUsingSTIXfonts() const { - return this->useSTIXfonts; - } - /*! \copydoc useXITSfonts */ - inline bool isUsingXITSfonts() const { - return this->useXITSfonts; - } /*! \copydoc brace_factor */ - inline void setBraceFactor(double __value) - { - this->brace_factor = __value; - } + void setBraceFactor(double __value); /*! \copydoc brace_factor */ - inline double getBraceFactor() const - { - return this->brace_factor; - } + double getBraceFactor() const; /*! \copydoc subsuper_size_factor */ - inline void setSubsuperSizeFactor(double __value) - { - this->subsuper_size_factor = __value; - } + void setSubsuperSizeFactor(double __value); /*! \copydoc subsuper_size_factor */ - inline double getSubsuperSizeFactor() const - { - return this->subsuper_size_factor; - } + double getSubsuperSizeFactor() const; /*! \copydoc italic_correction_factor */ - inline void setItalicCorrectionFactor(double __value) - { - this->italic_correction_factor = __value; - } + void setItalicCorrectionFactor(double __value); /*! \copydoc italic_correction_factor */ - inline double getItalicCorrectionFactor() const - { - return this->italic_correction_factor; - } + double getItalicCorrectionFactor() const; /*! \copydoc operatorsubsuper_size_factor */ - inline void setOperatorsubsuperSizeFactor(double __value) - { - this->operatorsubsuper_size_factor = __value; - } + void setOperatorsubsuperSizeFactor(double __value); /*! \copydoc operatorsubsuper_size_factor */ - inline double getOperatorsubsuperSizeFactor() const - { - return this->operatorsubsuper_size_factor; - } + double getOperatorsubsuperSizeFactor() const; /*! \copydoc mathoperator_width_factor */ - inline void setMathoperatorWidthFactor(double __value) - { - this->mathoperator_width_factor = __value; - } + void setMathoperatorWidthFactor(double __value); /*! \copydoc mathoperator_width_factor */ - inline double getMathoperatorWidthFactor() const - { - return this->mathoperator_width_factor; - } + double getMathoperatorWidthFactor() const; /*! \copydoc super_shift_factor */ - inline void setSuperShiftFactor(double __value) - { - this->super_shift_factor = __value; - } + void setSuperShiftFactor(double __value); /*! \copydoc super_shift_factor */ - inline double getSuperShiftFactor() const - { - return this->super_shift_factor; - } + double getSuperShiftFactor() const; /*! \copydoc sub_shift_factor */ - inline void setSubShiftFactor(double __value) - { - this->sub_shift_factor = __value; - } + void setSubShiftFactor(double __value); /*! \copydoc sub_shift_factor */ - inline double getSubShiftFactor() const - { - return this->sub_shift_factor; - } + double getSubShiftFactor() const; /*! \copydoc brace_shrink_factor */ - inline void setBraceShrinkFactor(double __value) - { - this->brace_shrink_factor = __value; - } + void setBraceShrinkFactor(double __value); /*! \copydoc brace_shrink_factor */ - inline double getBraceShrinkFactor() const - { - return this->brace_shrink_factor; - } + double getBraceShrinkFactor() const; /*! \copydoc underbrace_factor */ - inline void setUnderbraceFactor(double __value) - { - this->underbrace_factor = __value; - } + void setUnderbraceFactor(double __value); /*! \copydoc underbrace_factor */ - inline double getUnderbraceFactor() const - { - return this->underbrace_factor; - } + double getUnderbraceFactor() const; /*! \copydoc undersetFactor */ - inline void setUndersetFactor(double __value) - { - this->undersetFactor = __value; - } + void setUndersetFactor(double __value); /*! \copydoc undersetFactor */ - inline double getUndersetFactor() const - { - return this->undersetFactor; - } + double getUndersetFactor() const; /*! \copydoc frac_factor */ - inline void setFracFactor(double __value) - { - this->frac_factor = __value; - } + void setFracFactor(double __value); /*! \copydoc frac_factor */ - inline double getFracFactor() const - { - return this->frac_factor; - } + double getFracFactor() const; /*! \copydoc frac_shift_factor */ - inline void setFracShiftFactor(double __value) - { - this->frac_shift_factor = __value; - } + void setFracShiftFactor(double __value); /*! \copydoc frac_shift_factor */ - inline double getFracShiftFactor() const - { - return this->frac_shift_factor; - } + double getFracShiftFactor() const; /*! \copydoc brace_y_shift_factor */ - inline void setBraceYShiftFactor(double __value) - { - this->brace_y_shift_factor = __value; - } + void setBraceYShiftFactor(double __value); /*! \copydoc brace_y_shift_factor */ - inline double getBraceYShiftFactor() const - { - return this->brace_y_shift_factor; - } + double getBraceYShiftFactor() const; /*! \copydoc decoration_height_factor */ - inline void setDecorationHeightFactor(double __value) - { - this->decoration_height_factor = __value; - } + void setDecorationHeightFactor(double __value); /*! \copydoc decoration_height_factor */ - inline double getDecorationHeightFactor() const - { - return this->decoration_height_factor; - } + double getDecorationHeightFactor() const; /*! \copydoc expensiveRendering */ - inline void setExpensiveRendering(bool __value) - { - this->expensiveRendering = __value; - } + void setExpensiveRendering(bool __value); /*! \copydoc expensiveRendering */ - inline bool getExpensiveRendering() const - { - return this->expensiveRendering; - } + bool getExpensiveRendering() const; /*! \copydoc useUnparsed */ - inline void setUseUnparsed(bool __value) - { - this->useUnparsed = __value; - } + void setUseUnparsed(bool __value); /*! \copydoc useUnparsed */ - inline bool isUsingUnparsed() const - { - return this->useUnparsed; - } + bool isUsingUnparsed() const; /*! \copydoc error_list */ - inline QStringList getErrorList() const { - return this->error_list; - } + QStringList getErrorList() const; protected: - /** \brief the available fonts */ - enum MTenvironmentFont { - MTEroman, - MTEsans, - MTEtypewriter, - MTEscript, - MTEblackboard, - MTEcaligraphic - }; - /** \brief describes the current drawing environment (base fontname ...) */ struct MTenvironment { MTenvironment(); @@ -720,7 +575,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ class JKQTMATHTEXT_LIB_EXPORT MTnode { public: - MTnode(JKQTMathText* parent); + explicit MTnode(JKQTMathText* parent); + MTnode(const MTnode&)=delete; + MTnode& operator=(const MTnode&)=delete; virtual ~MTnode(); /** \brief determine the size of the node, calls getSizeInternal() implementation of the actual type \see getSizeInternal() * @@ -791,7 +648,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ class JKQTMATHTEXT_LIB_EXPORT MTtextNode: public MTnode { public: - MTtextNode(JKQTMathText* parent, const QString& text, bool addWhitespace, bool stripInnerWhitepace=false); + explicit MTtextNode(JKQTMathText* parent, const QString& text, bool addWhitespace, bool stripInnerWhitepace=false); virtual ~MTtextNode() override; /** \copydoc MTnode::draw() */ virtual double draw(QPainter& painter, double x, double y, MTenvironment currentEv, const MTnodeSize* prevNodeSize=nullptr) override; @@ -813,7 +670,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ class JKQTMATHTEXT_LIB_EXPORT MTplainTextNode: public MTtextNode { public: - MTplainTextNode(JKQTMathText* parent, const QString& text, bool addWhitespace, bool stripInnerWhitepace=false); + explicit MTplainTextNode(JKQTMathText* parent, const QString& text, bool addWhitespace, bool stripInnerWhitepace=false); /** \copydoc MTnode::getTypeName() */ virtual QString getTypeName() const override; protected: @@ -825,7 +682,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ class JKQTMATHTEXT_LIB_EXPORT MTwhitespaceNode: public MTtextNode { public: - MTwhitespaceNode(JKQTMathText* parent); + explicit MTwhitespaceNode(JKQTMathText* parent); virtual ~MTwhitespaceNode() override; /** \copydoc MTnode::getTypeName() */ virtual QString getTypeName() const override; @@ -839,7 +696,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ class JKQTMATHTEXT_LIB_EXPORT MTsymbolNode: public MTnode { public: - MTsymbolNode(JKQTMathText* parent, const QString& name, bool addWhitespace); + explicit MTsymbolNode(JKQTMathText* parent, const QString& name, bool addWhitespace); virtual ~MTsymbolNode() override; /** \copydoc MTnode::getTypeName() */ virtual QString getTypeName() const override; @@ -849,33 +706,49 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { virtual bool toHtml(QString& html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) override; /*! \copydoc symbolName */ QString getSymbolName() const; - QString getSymbolFontName() const; + QString getSymbolfontName() const; + bool getAddWhitespace() const; protected: /** \copydoc MTnode::getSizeInternal() */ virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const MTnodeSize* prevNodeSize=nullptr) override; + /** \brief this string will be sent to the drawText method with properly set fonts */ - QString symbol; - /** \brief the symbol name supplied to the constructor */ QString symbolName; - /** \brief these fonts may be used for symbols */ - enum symbolFont { MTSFdefault, MTSFsymbol, MTSFgreek, MTSFbraces, MTSFintegrals, MTSFcaligraphic, MTSFblackboard }; - /** \brief changes the font name according to a given symbolFont value */ - QFont getFontName(symbolFont f, QFont& fi) const; - /** \brief magnification factor for the font size */ - symbolFont font; - /** \brief magnification factor for the font size */ - double fontFactor; - /** \brief 0: leave italic setting as is, >0: set italic, <0 set italic to false */ - char italic; - /** \brief 0: leave bold setting as is, >0: set bold, <0 set bold to false */ - char bold; - /** \brief this corrects the y position of a symbol: draws at y <- y+ height*yfactor) */ - double yfactor; - /** \brief indicates whether to draw a bar (like for \c \\hbar ) */ - bool drawBar; - bool heightIsAscent; - bool exactAscent; - bool extendWidthInMathmode; + /** \brief add a whitespace to the symbol? */ + bool addWhitespace; + struct SymbolProps { + /** \brief the symbol name supplied to the constructor */ + QString symbol; + /** \brief font to use for output */ + QString font; + /** \brief magnification factor for the font size */ + double fontFactor; + /** \brief 0: leave italic setting as is, >0: set italic, <0 set italic to false */ + char italic; + /** \brief 0: leave bold setting as is, >0: set bold, <0 set bold to false */ + char bold; + /** \brief this corrects the y position of a symbol: draws at y <- y+ height*yfactor) */ + double yfactor; + /** \brief indicates whether to draw a bar (like for \c \\hbar ) */ + bool drawBar; + bool heightIsAscent; + bool exactAscent; + bool extendWidthInMathmode; + }; + /** \brief retrieve the properties to render the given symbol \a symName in the current environment \a currentEv */ + SymbolProps getSymbolProp(const QString& symName, const MTenvironment& currentEv) const; + /** \brief fill \a props for the symbol named \a n in the given environment \a currentEv and with the given \a mathFontFactor , returns \c true if the symbol can be drawn using Unicode font (or WinSymbol as Fallback)*/ + bool getSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps &props, const QString &n, const MTenvironment ¤tEv, double mathFontFactor) const; + /** \brief fill \a props for the greek letter symbol named \a n in the given environment \a currentEv and with the given \a mathFontFactor , returns \c true if the symbol can be drawn using Unicode font (or WinSymbol as Fallback) */ + bool getGreekSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps &props, const QString &n, const MTenvironment ¤tEv, double mathFontFactor) const; + /** \brief fill \a props for the symbol named \a n in the given environment \a currentEv and with the given \a mathFontFactor , returns \c true if the symbol can be drawn using WinSymbol font */ + bool getWinSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps &props, const QString &n, const MTenvironment ¤tEv, double mathFontFactor) const; + /** \brief fill \a props for the symbol named \a n , returns \c true if the symbol can be drawn using any font, does not alter the font name!!! */ + bool getStandardTextSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps &props, const QString &n) const; + /** \brief fill \a props for the symbol named \a n , returns \c true if the symbol can be drawn using any unicode font, does not alter the font name!!! */ + bool getUnicodeBaseSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps &props, const QString &n) const; + /** \brief fill \a props for the symbol named \a n , returns \c true if the symbol can be drawn using a full unicode font, does not alter the font name!!! */ + bool getUnicodeFullSymbolProp(JKQTMathText::MTsymbolNode::SymbolProps &props, const QString &n, double mathFontFactor) const; }; /** \brief subclass representing a list of nodes in the syntax tree @@ -883,7 +756,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ class JKQTMATHTEXT_LIB_EXPORT MTlistNode: public MTnode { public: - MTlistNode(JKQTMathText* parent); + explicit MTlistNode(JKQTMathText* parent); virtual ~MTlistNode() override; /** \copydoc MTnode::getTypeName() */ virtual QString getTypeName() const override; @@ -908,7 +781,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ class JKQTMATHTEXT_LIB_EXPORT MTinstruction1Node: public MTnode { public: - MTinstruction1Node(JKQTMathText* parent, const QString& name, MTnode* child, const QStringList& parameters=QStringList()); + explicit MTinstruction1Node(JKQTMathText* parent, const QString& name, MTnode* child, const QStringList& parameters=QStringList()); virtual ~MTinstruction1Node() override; /** \copydoc MTnode::getTypeName() */ virtual QString getTypeName() const override; @@ -944,15 +817,13 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ class JKQTMATHTEXT_LIB_EXPORT MTsubscriptNode: public MTnode { public: - MTsubscriptNode(JKQTMathText* parent, MTnode* child); + explicit MTsubscriptNode(JKQTMathText* parent, MTnode* child); virtual ~MTsubscriptNode() override; /** \copydoc MTnode::draw() */ virtual double draw(QPainter& painter, double x, double y, MTenvironment currentEv, const MTnodeSize* prevNodeSize=nullptr) override; /** \copydoc MTnode::getTypeName() */ virtual QString getTypeName() const override; /*! \brief returns the child node */ - inline MTnode* getChild() const { - return this->child; - } + MTnode *getChild() const; /** \copydoc MTnode::toHtml() */ virtual bool toHtml(QString& html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) override; /** \copydoc MTnode::setDrawBoxes() */ @@ -972,14 +843,12 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { */ class JKQTMATHTEXT_LIB_EXPORT MTsuperscriptNode: public MTnode { public: - MTsuperscriptNode(JKQTMathText* parent, MTnode* child); + explicit MTsuperscriptNode(JKQTMathText* parent, MTnode* child); virtual ~MTsuperscriptNode() override; /** \copydoc MTnode::draw() */ virtual double draw(QPainter& painter, double x, double y, MTenvironment currentEv, const MTnodeSize* prevNodeSize=nullptr) override; /*! \brief returns the child node */ - inline MTnode* getChild() const { - return this->child; - } + MTnode* getChild() const; /** \copydoc MTnode::getTypeName() */ virtual QString getTypeName() const override; /** \copydoc MTnode::toHtml() */ @@ -1050,13 +919,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { virtual void setDrawBoxes(bool draw) override; virtual QString getTypeName() const override ; /*! \brief returns the child node */ - inline MTnode* getChild() const { - return this->child; - } + MTnode *getChild() const; /*! \copydoc degree */ - inline int getDegree() const { - return this->degree; - } + int getDegree() const; protected: /** \copydoc MTnode::getSizeInternal() */ virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const MTnodeSize* prevNodeSize=nullptr) override; @@ -1094,17 +959,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { /** \copydoc MTnode::setDrawBoxes() */ virtual void setDrawBoxes(bool draw) override; /*! \brief returns the 1st child node */ - inline MTnode* getChild1() const { - return this->child1; - } + MTnode* getChild1() const; /*! \brief returns the 2nd child node */ - inline MTnode* getChild2() const { - return this->child2; - } + MTnode* getChild2() const; /*! \copydoc mode */ - inline MTfracMode getMode() const { - return this->mode; - } + MTfracMode getMode() const; protected: /** \copydoc MTnode::getSizeInternal() */ virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const MTnodeSize* prevNodeSize=nullptr) override; @@ -1125,17 +984,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { virtual double draw(QPainter& painter, double x, double y, MTenvironment currentEv, const MTnodeSize* prevNodeSize=nullptr) override; virtual bool toHtml(QString& html, JKQTMathText::MTenvironment currentEv, JKQTMathText::MTenvironment defaultEv) override; /*! \brief returns the child nodes */ - inline QVector > getChildren() const { - return this->children; - } + QVector > getChildren() const; /*! \copydoc columns */ - inline int getColumns() const { - return this->columns; - } + int getColumns() const; /*! \copydoc lines */ - inline int getLines() const { - return this->lines; - } + int getLines() const; protected: /** \copydoc MTnode::getSizeInternal() */ virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const MTnodeSize* prevNodeSize=nullptr) override; @@ -1177,13 +1030,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { virtual void setDrawBoxes(bool draw) override; virtual QString getTypeName() const override ; /*! \brief returns the child node */ - inline MTnode* getChild() const { - return this->child; - } + MTnode* getChild() const; /*! \copydoc decoration */ - inline MTdecoration getDecoration() const { - return this->decoration; - } + MTdecoration getDecoration() const; protected: /** \copydoc MTnode::getSizeInternal() */ virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const MTnodeSize* prevNodeSize=nullptr) override; @@ -1195,178 +1044,74 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { /** \brief table with font replacements to use (e.g. if it is known that a certain font is not good for rendering, you can add * an alternative using addReplacementFont(). These are automatically applied, when setting a new font name! */ QMap fontReplacements; + /** \brief acompanies fontReplacements and collects the encodings of the replacement fonts, if no entry is present, the default encoding is used, as given to the setter! */ + QMap fontEncodingReplacements; /** \brief font color */ QColor fontColor; - /*! \brief default value for property fontColor. - \see fontColor for more information */ - QColor default_fontColor; /** \brief base font size in points */ double fontSize; - /*! \brief default value for property fontSize. - \see fontSize for more information */ - double default_fontSize; - /** \brief roman font */ - QString fontRoman; - /*! \brief default value for property fontRoman. - \see fontRoman for more information */ - QString default_fontRoman; - /** \brief sans-serif font */ - QString fontSans; - /*! \brief default value for property fontSans. - \see fontSans for more information */ - QString default_fontSans; - /** \brief typewriter font */ - QString fontTypewriter; - /*! \brief default value for property fontTypewriter. - \see fontTypewriter for more information */ - QString default_fontTypewriter; - /** \brief script font */ - QString fontScript; - /*! \brief default value for property fontScript. - \see fontScript for more information */ - QString default_fontScript; - /** \brief greek font */ - QString fontGreek; - /*! \brief default value for property fontGreek. - \see fontGreek for more information */ - QString default_fontGreek; - /** \brief symbol font, used for math symbols. */ - QString fontSymbol; - /*! \brief default value for property fontSymbol. - \see fontSymbol for more information */ - QString default_fontSymbol; - /** \brief symbol font, used for braces in math mode. */ - QString fontBraces; - /*! \brief default value for property fontBraces. - \see fontBraces for more information */ - QString default_fontBraces; - /** \brief symbol font, used for integrals in math mode. */ - QString fontIntegrals; - /*! \brief default value for property fontIntegrals. - \see fontIntegrals for more information */ - QString default_fontIntegrals; - /** \brief font used for caligraphic symbols (escepcially in math environments) */ - QString fontCaligraphic; - /*! \brief default value for property fontCaligraphic. - \see fontCaligraphic for more information */ - QString default_fontCaligraphic; - /** \brief font used for blackboard (double-stroke) symbols (escepcially in math environments) */ - QString fontBlackboard; - /*! \brief default value for property fontBlackboard. - \see fontBlackboard for more information */ - QString default_fontBlackboard; - /** \brief prefix for LaTeX fonts */ - QString fontLatexPrefix; - /*! \brief default value for property fontLatexPrefix. - \see fontLatexPrefix for more information */ - QString default_fontLatexPrefix; - /** \brief postfix for LaTeX fonts */ - QString fontLatexPostfix; - /*! \brief default value for property fontLatexPostfix. - \see fontLatexPostfix for more information */ - QString default_fontLatexPostfix; - /** \brief specifies the encoding of special character fonts (default is \c MTFEwinSymbol ) */ - MTfontEncoding fontEncoding; - /*! \brief default value for property fontEncoding. - \see fontEncoding for more information */ - MTfontEncoding default_fontEncoding; + + + /*! \brief summarizes all information available on a font for a specific MTenvironmentFont + \see fontDefinitions */ + struct FontDefinition { + FontDefinition(); + /** \brief name of the font */ + QString fontName; + /** \brief specifies the encoding of the font (default is \c MTFEwinSymbol ) */ + MTfontEncoding fontEncoding; + + /** \brief symbol font used for greek symbols, or empty when \a fontName shall be used */ + QString symbolfontGreek; + /** \brief specifies the encoding of symbolfontGreek */ + MTfontEncoding symbolfontGreekEncoding; + /** \brief symbol font, used for math symbols, or empty when \a fontName shall be used */ + QString symbolfontSymbol; + /** \brief specifies the encoding of symbolfontSymbol */ + MTfontEncoding symbolfontSymbolEncoding; + }; + + /** \brief stores information about the different fonts used by LaTeX markup */ + QHash fontDefinitions; + /** \brief if enabled, the blackboard-characters are simulated by using font outlines only */ + bool blackboardSimulated; + + /** \brief resizing factor for braces in math mode */ double brace_factor; - /*! \brief default value for property brace_factor. - \see brace_factor for more information */ - double default_brace_factor; /** \brief shrinking the width of braces in math mode 0: reduce to 0 pixel width, 1: leave unchanged*/ double brace_shrink_factor; - /*! \brief default value for property brace_shrink_factor. - \see brace_shrink_factor for more information */ - double default_brace_shrink_factor; /** \brief resizing factor for font size in sub-/superscript */ double subsuper_size_factor; - /*! \brief default value for property subsuper_size_factor. - \see subsuper_size_factor for more information */ - double default_subsuper_size_factor; /** \brief fraction of a whitespace by which to shift a sub-/superscript left/right when the previous text is italic */ double italic_correction_factor; - /*! \brief default value for property italic_correction_factor. - \see italic_correction_factor for more information */ - double default_italic_correction_factor; /** \brief like subsuper_size_factor, but for operators (\\sum, \\int) where the text is placed above/below the symbol */ double operatorsubsuper_size_factor; - /*! \brief default value for property operatorsubsuper_size_factor. - \see operatorsubsuper_size_factor for more information */ - double default_operatorsubsuper_size_factor; /** \brief factor, used to extend the size of an operator in math mode */ double mathoperator_width_factor; - /*! \brief default value for property mathoperator_width_factor. - \see mathoperator_width_factor for more information */ - double default_mathoperator_width_factor; /** \brief relative shift of text in superscript to normal text: * 0= baseline kept, 1: baseline shifted to top of normal text */ double super_shift_factor; - /*! \brief default value for property super_shift_factor. - \see super_shift_factor for more information */ - double default_super_shift_factor; /** \brief relative shift of text in subscript to normal text: * 0= baseline kept, 1: baseline shifted to bottom of normal text */ double sub_shift_factor; - /*! \brief default value for property sub_shift_factor. - \see sub_shift_factor for more information */ - double default_sub_shift_factor; - /** \brief indicates whether to use STIX fonts or not */ - bool useSTIXfonts; - /*! \brief default value for property useSTIXfonts. - \see useSTIXfonts for more information */ - bool default_useSTIXfonts; - /** \brief indicates whether to use XITS fonts or not */ - bool useXITSfonts; - /** \brief the first call to useXITS() determines this name for the default XITS fonts */ - QString defaultXITSFontName; - /** \brief the call to useXITS() determines this name for the default XITS Math fonts */ - QString defaultXITSMathFontName; - /*! \brief default value for property useXITSfonts. - \see useXITSfonts for more information */ - bool default_useXITSfonts; - /** \brief indicates whether to use XITS fonts or not */ - bool useASANAfonts; - /*! \brief default value for property useASANAfonts. - \see useASANAfonts for more information */ - bool default_useASANAfonts; + + /** \brief scaling factor for font of nominator and denominator of a fraction */ double frac_factor; - /*! \brief default value for property frac_factor. - \see frac_factor for more information */ - double default_frac_factor; /** \brief shift of denominator/nummerator away from central line of a frac */ double frac_shift_factor; - /*! \brief default value for property frac_shift_factor. - \see frac_shift_factor for more information */ - double default_frac_shift_factor; /** \brief scaling factor for font of underbrace/overbrace text */ double underbrace_factor; - /*! \brief default value for property underbrace_factor. - \see underbrace_factor for more information */ - double default_underbrace_factor; /** \brief scaling factor for font of underset/overset text */ double undersetFactor; - /*! \brief default value for property undersetFactor. - \see undersetFactor for more information */ - double default_undersetFactor; /** \brief fraction of the brace ascent that the brace is shifted downwards, when scaled */ double brace_y_shift_factor; - /*! \brief default value for property brace_y_shift_factor. - \see brace_y_shift_factor for more information */ - double default_brace_y_shift_factor; /** \brief size of the decorations (dot, tilde, ...), as fractio of the baselineheight */ double decoration_height_factor; - /*! \brief default value for property decoration_height_factor. - \see decoration_height_factor for more information */ - double default_decoration_height_factor; /** \brief switches on some options that will grant better rendering at the expense of higher time consumption */ bool expensiveRendering; - /*! \brief default value for property expensiveRendering. - \see expensiveRendering for more information */ - bool default_expensiveRendering; /** \brief a list that will be filled with error messages while parsing, if any error occur */ QStringList error_list; /** \brief used by the parser. This is used to implement brace pairs with \\right. */ @@ -1379,10 +1124,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { /** \brief if true, the unparsedNode is drawn */ bool useUnparsed; - inline MTnode* getTree() const { - if (useUnparsed) return unparsedNode; - return parsedNode; - } + MTnode* getTree() const; /** \brief the token types that may arrise in the string */ enum tokenType { @@ -1419,9 +1161,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { public: /*! \copydoc parsedNode */ - inline MTnode* getParsedNode() const { - return this->parsedNode; - } + MTnode *getParsedNode() const; struct JKQTMATHTEXT_LIB_EXPORT tbrData { explicit tbrData(const QFont& f, const QString& text, QPaintDevice *pd); @@ -1445,6 +1185,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { static QList tbrs; static QHash tbrh; static QRectF getTightBoundingRect(const QFont &fm, const QString& text, QPaintDevice *pd); + };