refactored symbol node, should also fix issue #78

This commit is contained in:
jkriege2 2022-07-05 22:03:08 +02:00
parent 341e1ac2ef
commit 0ab3626f4d
17 changed files with 376 additions and 265 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -1,6 +1,7 @@
#include "testform.h"
#include "ui_testform.h"
#include <QDebug>
#include <sstream>
#include "jkqtmathtext/nodes/jkqtmathtexttextnode.h"
#include "jkqtmathtext/nodes/jkqtmathtextbracenode.h"
#include "jkqtmathtext/nodes/jkqtmathtextdecoratednode.h"
@ -44,6 +45,7 @@ TestForm::TestForm(QWidget *parent) :
ui->cmbTestset->addItem("math: named symbols 6", "times: $\\times$\\ ast: $\\ast$\\ star: $\\star$\\ propto: $\\propto$\\ bullet: $\\bullet$\\ neq: $\\neq$\\ ne: $\\ne$\\ equiv: $\\equiv$\\ approx: $\\approx$\\ otimes: $\\otimes$\\ oplus: $\\oplus$");
ui->cmbTestset->addItem("math: named symbols 7", "oslash: $\\oslash$\\ cap: $\\cap$\\ land: $\\land$\\ cup: $\\cup$\\ lor: $\\lor$\\ supset: $\\supset$\\ supseteq: $\\supseteq$\\ supsetnot: $\\supsetnot$\\ subset: $\\subset$");
ui->cmbTestset->addItem("math: named symbols 8", "subseteq: $\\subseteq$\\ in: $\\in$\\ notin: $\\notin$\\ cdot: $\\cdot$\\ wedge: $\\wedge$\\ vee: $\\vee$\\ cong: $\\cong$\\ bot: $\\bot$");
ui->cmbTestset->addItem("math: named symbols with special fallback-drawing", "\\infty\\ \\prod\\ \\coprod\\ \\nexists\\ \\sum\\ \\varnothing\\ \\exists\\ \\forall\\ \\neq\\ \\ni\\ \\alpha\\beta\\Omega");
ui->cmbTestset->addItem("math: symbols", "$\\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$");
ui->cmbTestset->addItem("math: std dev", "$\\sigma_x=\\sqrt{\\langle (x-\\langle x\\rangle)^2\\rangle}=\\sqrt{\\frac{1}{N-1}\\cdot\\left( \\sum_{i=1}^N{x_i}^2-\\frac{1}{N}\\cdot\\left(\\sum_{i=1}^Nx_i\\right)^2\\right)}$");
ui->cmbTestset->addItem("math: std dev 2", "$\\sigma_x=\\sqrt{\\langle (x-\\langle x\\rangle)^2\\rangle}=\\sqrt{\\frac{1}{N-1}\\cdot\\left( \\sum_{i=1}^Nx_i^2-\\frac{1}{N}\\cdot\\left(\\sum_{i=1}^Nx_i\\right)^2\\right)}$");
@ -204,7 +206,7 @@ TestForm::TestForm(QWidget *parent) :
ui->cmbTestset->addItem("math: lim, sum ...", "$\\lim_{x\\to\\infty} f(x) = \\binom{k}{r} + \\frac{a}{b} \\sum_{n=1}^\\infty a_n + \\displaystyle{ \\left\\{ \\frac{1}{13} \\sum_{n=1}^\\infty b_n \\right\\} }.$");
ui->cmbTestset->addItem("math: array test", "$f(x) := \\left\\{\\begin{array} x^2 \\sin \\frac{1}{x} & \\textrm{if } x \\ne 0, \\\\ 0 & \\textrm{if } x = 0 . \\end{array}\\right.$");
ui->cmbTestset->addItem("math: Schwinger-Dyson", "$\\left\\langle\\psi\\left|\\mathcal{T}\\{F \\phi^j\\}\\right|\\psi\\right\\rangle=\\left\\langle\\psi\\left|\\mathcal{T}\\{iF_{,i}D^{ij}-FS_{int,i}D^{ij}\\}\\right|\\psi\\right\\rangle.$");
ui->cmbTestset->addItem(QLatin1String("math: Schrödinger's equation"), "$\\left[-\\frac{\\hbar^2}{2m}\\frac{\\partial^2}{\\partial x^2}+V\\right]\\Psi(x)=\\mathrm{i}\\hbar\\frac{\\partial}{\\partial t}\\Psi(x)$");
ui->cmbTestset->addItem(QString(QString("math: Schr")+QChar(0xF6)+"dinger's equation"), QString("Schr")+QChar(0xF6)+"dinger's equation: $\\left[-\\frac{\\hbar^2}{2m}\\frac{\\partial^2}{\\partial x^2}+V\\right]\\Psi(x)=\\mathrm{i}\\hbar\\frac{\\partial}{\\partial t}\\Psi(x)$");
ui->cmbTestset->addItem("math: Cauchy-Schwarz inequality", "$\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq \\left( \\sum_{k=1}^n a_k^2 \\right) \\left( \\sum_{k=1}^n b_k^2 \\right)$");
ui->cmbTestset->addItem("math: Maxwell's equations", "$\\begin{aligned}\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac{1}{c}\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac{1}{c}\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \\end{aligned}$");
ui->cmbTestset->addItem("math: Langevin Equation", "$m \\dot{v}(t) = -\\gamma v(t) + F(x,t)+ f(t)$");
@ -238,8 +240,6 @@ TestForm::TestForm(QWidget *parent) :
ui->cmbEncodingBlackboard->setCurrentIndex(static_cast<int>(mt.getFontEncodingBlackboard()));
ui->cmbUnicodeSymbol->setCurrentFont(QFont(mt.getFallbackFontSymbols()));
ui->cmbEncodingSymbol->setCurrentIndex(static_cast<int>(mt.getFontEncodingFallbackFontSymbols()));
ui->cmbUnicodeGreek->setCurrentFont(QFont(mt.getFallbackFontGreek()));
ui->cmbEncodingGreek->setCurrentIndex(static_cast<int>(mt.getFontEncodingFallbackFontGreek()));
ui->chkSimulateBlackboard->setChecked(mt.isFontBlackboardSimulated());
@ -266,10 +266,8 @@ TestForm::TestForm(QWidget *parent) :
connect(ui->cmbEncodingSans, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath()));
connect(ui->cmbEncodingSansMath, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMath()));
connect(ui->cmbUnicodeTypewriter, 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()));
@ -321,6 +319,7 @@ double TestForm::draw(QPainter& painter, double X, double YY, JKQTMathText& mt,
painter.setPen(p);
painter.drawLine(X, Y, X+s.width(), Y);
}
qDebug()<<getFonts(mt);
ht.start();
p.setStyle(Qt::SolidLine);
p.setWidth(1);
@ -365,6 +364,7 @@ double TestForm::drawAligned(QPainter& painter, double X, double YY, JKQTMathTex
case 8: flags=Qt::AlignRight|Qt::AlignBottom; break;
}
qDebug()<<getFonts(mt);
QPen p=painter.pen();
p.setColor("darkred");
p.setStyle(Qt::SolidLine);
@ -387,9 +387,26 @@ double TestForm::drawAligned(QPainter& painter, double X, double YY, JKQTMathTex
painter.drawText(X, Y-6, name+":");
painter.restore();
qDebug()<<name<<": width="<<s.width()<<" height="<<s.height()<<" ascent="<<mt.getAscent(painter)<<" descent="<<mt.getDescent(painter);
qDebug()<<getFonts(mt);
return rect.bottom()+40;
}
QString TestForm::getFonts(const JKQTMathText& mt) const
{
std::ostringstream str;
str<<"Roman: "<<mt.getFontRoman().toStdString()<<", "<<JKQTMathTextFontEncoding2String(mt.getFontEncodingRoman()).toStdString()<<"\n";
str<<"Math-Roman: "<<mt.getFontMathRoman().toStdString()<<", "<<JKQTMathTextFontEncoding2String(mt.getFontEncodingMathRoman()).toStdString()<<"\n";
str<<"Sans: "<<mt.getFontSans().toStdString()<<", "<<JKQTMathTextFontEncoding2String(mt.getFontEncodingSans()).toStdString()<<"\n";
str<<"Math-Sans: "<<mt.getFontMathSans().toStdString()<<", "<<JKQTMathTextFontEncoding2String(mt.getFontEncodingMathSans()).toStdString()<<"\n";
str<<"FallbackSymbols: "<<mt.getFallbackFontSymbols().toStdString()<<", "<<JKQTMathTextFontEncoding2String(mt.getFontEncodingFallbackFontSymbols()).toStdString()<<"\n";
str<<"Fraktur: "<<mt.getFontFraktur().toStdString()<<", "<<JKQTMathTextFontEncoding2String(mt.getFontEncodingFraktur()).toStdString()<<"\n";
str<<"Script: "<<mt.getFontScript().toStdString()<<", "<<JKQTMathTextFontEncoding2String(mt.getFontEncodingScript()).toStdString()<<"\n";
str<<"Typewriter: "<<mt.getFontTypewriter().toStdString()<<", "<<JKQTMathTextFontEncoding2String(mt.getFontEncodingTypewriter()).toStdString()<<"\n";
str<<"Caligraphic: "<<mt.getFontCaligraphic().toStdString()<<", "<<JKQTMathTextFontEncoding2String(mt.getFontEncodingCaligraphic()).toStdString()<<"\n";
str<<"Blackboard: "<<mt.getFontBlackboard().toStdString()<<", "<<JKQTMathTextFontEncoding2String(mt.getFontEncodingBlackboard()).toStdString()<<", isSimulated="<<mt.isFontBlackboardSimulated();
return str.str().c_str();
}
QTreeWidgetItem *TestForm::createTree(JKQTMathTextNode *node, QTreeWidgetItem* parent)
{
QString name;
@ -454,12 +471,11 @@ QTreeWidgetItem *TestForm::createTree(JKQTMathTextNode *node, QTreeWidgetItem* p
ti->addChild(createTree(list[i], ti));
}
} else if (symN) {
name=QString("MTSymbolNode: \'%1\' (addWhite: %2, subsuper=%3)").arg(symN->getSymbolName()).arg(symN->getAddWhitespace()).arg(symN->isSubSuperscriptAboveBelowNode());
name=QString("MTSymbolNode: \'%1\' (subsuper=%3)").arg(symN->getSymbolName()).arg(symN->isSubSuperscriptAboveBelowNode());
} else if (spN) {
name=QString("MTWhitespaceNode :type=%1, count=%2").arg(spN->Type2String(spN->getWhitespaceType())).arg(spN->getWhitespaceCount());
} else if (txtN) {
name=QString("MTTextNode: \'%1\'").arg(txtN->getText());
} else {
name=QString("unknown");
}
@ -522,6 +538,7 @@ void TestForm::updateMath()
ht.start();
mt.setFallbackFontSymbols(ui->cmbUnicodeSymbol->currentFont().family(), static_cast<JKQTMathTextFontEncoding>(ui->cmbEncodingSymbol->currentIndex()));
if (ui->cmbFont->currentIndex()<=3) {
mt.setFontRoman(ui->cmbUnicodeSerif->currentFont().family(), static_cast<JKQTMathTextFontEncoding>(ui->cmbEncodingSerif->currentIndex()));
mt.setFontSans(ui->cmbUnicodeSans->currentFont().family(), static_cast<JKQTMathTextFontEncoding>(ui->cmbEncodingSans->currentIndex()));
@ -533,17 +550,35 @@ void TestForm::updateMath()
mt.setFontFraktur(ui->cmbUnicodeFraktur->currentFont().family(), static_cast<JKQTMathTextFontEncoding>(ui->cmbEncodingFraktur->currentIndex()));
mt.setFontBlackboard(ui->cmbUnicodeBlackboard->currentFont().family(), static_cast<JKQTMathTextFontEncoding>(ui->cmbEncodingBlackboard->currentIndex()));
mt.setFallbackFontSymbols(ui->cmbUnicodeSymbol->currentFont().family(), static_cast<JKQTMathTextFontEncoding>(ui->cmbEncodingSymbol->currentIndex()));
mt.setFallbackFontGreek(ui->cmbUnicodeGreek->currentFont().family(), static_cast<JKQTMathTextFontEncoding>(ui->cmbEncodingGreek->currentIndex()));
} else if (ui->cmbFont->currentIndex()==5 || ui->cmbFont->currentIndex()==6) {
mt.setFontRoman(QGuiApplication::font().family());
mt.setFontMathRoman(QGuiApplication::font().family());
} else if (ui->cmbFont->currentIndex()==7) {
mt.useXITS();
mt.useAnyUnicode("Times New Roman", "Times New Roman");
} else if (ui->cmbFont->currentIndex()==8) {
mt.useXITS();
mt.useAnyUnicode("Arial", "Arial");
} else if (ui->cmbFont->currentIndex()==9) {
mt.useXITS();
mt.useAnyUnicode("Courier New", "Courier New");
} else if (ui->cmbFont->currentIndex()==10) {
mt.useXITS();
mt.useAnyUnicode("Comic Sans MS", "Comic Sans MS");
} else if (ui->cmbFont->currentIndex()==11) {
mt.useAnyUnicodeForTextOnly("Times New Roman", "Times New Roman");
mt.useXITS();
} else if (ui->cmbFont->currentIndex()==12) {
mt.useAnyUnicodeForTextOnly("Arial", "Arial");
mt.useXITS();
} else if (ui->cmbFont->currentIndex()==13) {
mt.useAnyUnicodeForTextOnly("Courier New", "Courier New");
mt.useXITS();
} else if (ui->cmbFont->currentIndex()==14) {
mt.useAnyUnicodeForTextOnly("Comic Sans MS", "Comic Sans MS");
mt.useXITS();
} else if (ui->cmbFont->currentIndex()==15) {
mt.useXITS(false);
}
mt.setFontBlackboardSimulated(ui->chkSimulateBlackboard->isChecked());
@ -583,9 +618,9 @@ void TestForm::updateMath()
if (i==0) {
ui->labError->clear();
if (mt.getErrorList().size()>0) {
ui->labError->setHtml("<span color=\"red\">"+mt.getErrorList().join("<br>")+"</span>");
ui->labError->setHtml(QString("<span color=\"red\">"+mt.getErrorList().join("<br>")+"</span><br><br><b>Fonts:</b><br><i>%1</i>").arg(getFonts(mt).replace("\n", "<br>")));
} else {
ui->labError->setHtml("<span color=\"green\">OK</span>");
ui->labError->setHtml(QString("<span color=\"green\">OK</span><br><br><b>Fonts:</b><br><i>%1</i>").arg(getFonts(mt).replace("\n", "<br>")));
}
}

View File

@ -29,7 +29,7 @@ class TestForm : public QWidget
JKQTPHighResTimer ht;
double draw(QPainter& painter, double X, double YY, JKQTMathText& mt, QString name, double &durationSizingMS, double &durationTimingMS, QStringList *lstErrors=nullptr);
double drawAligned(QPainter& painter, double X, double YY, JKQTMathText& mt, QString name);
QString getFonts(const JKQTMathText& mt) const;
QTreeWidgetItem* createTree(JKQTMathTextNode* node, QTreeWidgetItem *parent=NULL);
};

View File

@ -144,13 +144,6 @@
</item>
<item row="1" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="7">
<widget class="QLabel" name="label_7">
<property name="text">
<string>fallback-greek:</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_14">
<property name="text">
@ -194,25 +187,6 @@
</property>
</widget>
</item>
<item row="2" column="9">
<widget class="QComboBox" name="cmbEncodingGreek">
<item>
<property name="text">
<string>WinSymbol</string>
</property>
</item>
<item>
<property name="text">
<string>Unicode</string>
</property>
</item>
<item>
<property name="text">
<string>Latin1</string>
</property>
</item>
</widget>
</item>
<item row="0" column="9">
<widget class="QComboBox" name="cmbEncodingTypewriter">
<item>
@ -519,13 +493,6 @@
</property>
</widget>
</item>
<item row="2" column="8">
<widget class="QFontComboBox" name="cmbUnicodeGreek">
<property name="currentFont">
<font/>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QFontComboBox" name="cmbCaligraphic">
<property name="currentFont">
@ -645,32 +612,57 @@
</item>
<item>
<property name="text">
<string>Default-Constructed+SetAppFont</string>
<string>Default-Constructed+SetAppFontRoman+SetAppFontMath</string>
</property>
</item>
<item>
<property name="text">
<string>Default-Constructed+SetAppFont+XITS</string>
<string>Default-Constructed+SetAppFontRoman+SetAppFontMath+XITS</string>
</property>
</item>
<item>
<property name="text">
<string>useAnyUnicode(&quot;Times New Roman&quot;, &quot;Times New Roman&quot;)</string>
<string>useXITS(true)+useAnyUnicode(&quot;Times New Roman&quot;, &quot;Times New Roman&quot;)</string>
</property>
</item>
<item>
<property name="text">
<string>useAnyUnicode(&quot;Arial&quot;, &quot;Arial&quot;)</string>
<string>useXITS(true)+useAnyUnicode(&quot;Arial&quot;, &quot;Arial&quot;)</string>
</property>
</item>
<item>
<property name="text">
<string>useAnyUnicode(&quot;Courier New&quot;, &quot;Courier New&quot;)</string>
<string>useXITS(true)+useAnyUnicode(&quot;Courier New&quot;, &quot;Courier New&quot;)</string>
</property>
</item>
<item>
<property name="text">
<string>useAnyUnicode(&quot;Comic Sans MS&quot;, &quot;Comic Sans MS&quot;)</string>
<string>useXITS(true)+useAnyUnicode(&quot;Comic Sans MS&quot;, &quot;Comic Sans MS&quot;)</string>
</property>
</item>
<item>
<property name="text">
<string>useAnyUnicodeForTextOnly(&quot;Times New Roman&quot;, &quot;Times New Roman&quot;)+useXITS(true)</string>
</property>
</item>
<item>
<property name="text">
<string>useAnyUnicodeForTextOnly(&quot;Arial&quot;, &quot;Arial&quot;)+useXITS(true)</string>
</property>
</item>
<item>
<property name="text">
<string>useAnyUnicodeForTextOnly(&quot;Courier New&quot;, &quot;Courier New&quot;)+useXITS(true)</string>
</property>
</item>
<item>
<property name="text">
<string>useAnyUnicodeForTextOnly(&quot;Comic Sans MS&quot;, &quot;Comic Sans MS&quot;)+useXITS(true)</string>
</property>
</item>
<item>
<property name="text">
<string>useXITS(false)</string>
</property>
</item>
</widget>

View File

@ -171,7 +171,6 @@ JKQTMathText::JKQTMathText(QObject* parent):
}
setFontScript(scriptFont, estimateJKQTMathTextFontEncoding(scriptFont));
setFontFraktur(fracturFont, estimateJKQTMathTextFontEncoding(fracturFont));
setFallbackFontGreek(symbolFont, estimateJKQTMathTextFontEncoding(symbolFont));
setFallbackFontSymbols(symbolFont, estimateJKQTMathTextFontEncoding(symbolFont));
//qDebug()<<"set fonts: "<<std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now()-t0).count()/1000.0<<"ms"; t0=std::chrono::high_resolution_clock::now();
useXITS();
@ -284,12 +283,10 @@ bool JKQTMathText::useSTIX(bool mathModeOnly) {
}
if (!stixs.mathFontName().isEmpty()) {
setFontMathRoman(stixs.mathFontName(), MTFEUnicode);
setFallbackFontGreek(stixs.mathFontName(), MTFEUnicode);
setFallbackFontSymbols(stixs.mathFontName(), MTFEUnicode);
res=true;
} else if (!stixs.fontName().isEmpty()) {
setFontMathRoman(stixs.fontName(), MTFEUnicode);
setFallbackFontGreek(stixs.fontName(), MTFEUnicode);
setFallbackFontSymbols(stixs.fontName(), MTFEUnicode);
res=true;
}
@ -305,13 +302,11 @@ bool JKQTMathText::useXITS(bool mathModeOnly)
if (!mathModeOnly && !xits.fontName().isEmpty()) {
setFontRoman(xits.fontName(), MTFEUnicode);
setFallbackFontGreek(xits.fontName(), MTFEUnicode);
setFallbackFontSymbols(xits.fontName(), MTFEUnicode);
res=true;
}
if (!xits.mathFontName().isEmpty()) {
setFontMathRoman(xits.mathFontName(), MTFEUnicode);
setFallbackFontGreek(xits.mathFontName(), MTFEUnicode);
setFallbackFontSymbols(xits.mathFontName(), MTFEUnicode);
res=true;
}
@ -327,13 +322,11 @@ bool JKQTMathText::useASANA(bool mathModeOnly)
if (!mathModeOnly && !asana.fontName().isEmpty()) {
setFontRoman(asana.fontName(), MTFEUnicode);
setFallbackFontGreek(asana.fontName(), MTFEUnicode);
setFallbackFontSymbols(asana.fontName(), MTFEUnicode);
res=true;
}
if (!asana.mathFontName().isEmpty()) {
setFontMathRoman(asana.mathFontName(), MTFEUnicode);
setFallbackFontGreek(asana.mathFontName(), MTFEUnicode);
setFallbackFontSymbols(asana.mathFontName(), MTFEUnicode);
res=true;
}
@ -573,13 +566,6 @@ JKQTMathTextFontEncoding JKQTMathText::getFontEncodingFraktur() const
return fontDefinitions[MTEfraktur].fontEncoding;
}
void JKQTMathText::setFallbackFontGreek(const QString &fontName, JKQTMathTextFontEncoding encoding)
{
auto f=getReplacementFont(fontName, fontName, encoding);
fontDefinitions[MTEFallbackGreek].fontName = f.first;
fontDefinitions[MTEFallbackGreek].fontEncoding = f.second;
}
void JKQTMathText::setFallbackFontSymbols(const QString &fontName, JKQTMathTextFontEncoding encoding)
{
auto f=getReplacementFont(fontName, fontName, encoding);
@ -588,20 +574,11 @@ void JKQTMathText::setFallbackFontSymbols(const QString &fontName, JKQTMathTextF
}
QString JKQTMathText::getFallbackFontGreek() const
{
return fontDefinitions[MTEFallbackGreek].fontName;
}
QString JKQTMathText::getFallbackFontSymbols() const
{
return fontDefinitions[MTEFallbackSymbols].fontName;
}
JKQTMathTextFontEncoding JKQTMathText::getFontEncodingFallbackFontGreek() const
{
return fontDefinitions[MTEFallbackGreek].fontEncoding;
}
JKQTMathTextFontEncoding JKQTMathText::getFontEncodingFallbackFontSymbols() const
{
@ -1170,7 +1147,7 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, JKQTMathTextBraceType
getNew=addWhite;
if (parsingMathEnvironment) {
if (mathEnvironmentSpecialText.contains(text.trimmed()) && JKQTMathTextSymbolNode::hasSymbol(text.trimmed())) {
nl->addChild(new JKQTMathTextSymbolNode(this, text.trimmed(), addWhite));
nl->addChild(new JKQTMathTextSymbolNode(this, text.trimmed()));
} else {
nl->addChild(new JKQTMathTextTextNode(this, text, addWhite, parsingMathEnvironment));
}
@ -1183,7 +1160,7 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, JKQTMathTextBraceType
if (JKQTMathTextWhitespaceNode::supportsInstructionName(currentInstructionName)) {
nl->addChild(new JKQTMathTextWhitespaceNode(currentInstructionName, this));
} else if (JKQTMathTextSymbolNode::hasSymbol(currentInstructionName)) {
nl->addChild(new JKQTMathTextSymbolNode(this, currentInstructionName, false));
nl->addChild(new JKQTMathTextSymbolNode(this, currentInstructionName));
} else {
getToken(); // look at next token
if (currentToken==MTTopenbrace) {
@ -1484,7 +1461,7 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, JKQTMathTextBraceType
} else if (JKQTMathTextWhitespaceNode::supportsInstructionName(currentInstructionName)) {
nl->addChild(new JKQTMathTextWhitespaceNode(currentInstructionName, this));
} else if (JKQTMathTextSymbolNode::hasSymbol(currentInstructionName)) {
nl->addChild(new JKQTMathTextSymbolNode(this, currentInstructionName, false));
nl->addChild(new JKQTMathTextSymbolNode(this, currentInstructionName));
static QSet<QString> subsupOperations= (QSet<QString>()<<"sum"<<"prod"<<"coprod"
<<"bigcap"<<"bigcup"<<"bigvee"<<"bighat"
<<"int"<<"iint"<<"iiint"<<"oint"<<"oiint"<<"oiiint"
@ -1522,7 +1499,7 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, JKQTMathTextBraceType
child=new JKQTMathTextWhitespaceNode(name, this);
} else if (JKQTMathTextSymbolNode::hasSymbol(name)) {
getNew=false;
child=new JKQTMathTextSymbolNode(this, name, false);
child=new JKQTMathTextSymbolNode(this, name);
} else {
error_list.append(tr("error @ ch. %1: unknown instruction \\%2").arg(currentTokenID).arg(name));
}
@ -1551,7 +1528,7 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, JKQTMathTextBraceType
nl->addChild(new JKQTMathTextWhitespaceNode(currentInstructionName, this));
} else if (JKQTMathTextSymbolNode::hasSymbol(currentInstructionName)){
getNew=true;
child=new JKQTMathTextSymbolNode(this, currentInstructionName, false);
child=new JKQTMathTextSymbolNode(this, currentInstructionName);
} else {
getToken(); // look at next token
if (currentToken==MTTopenbrace) {

View File

@ -195,8 +195,7 @@ class JKQTMathTextNode; // forward
- A "blackboard" (MTEblackboard) font used to display double stroked characters ( setFontBlackboard() )
- A "caligraphic" (MTEcaligraphic) font used to display caligraphic characters ( setFontCaligraphic() )
- A "fraktur" (MTEfraktur) font used to display fraktur characters ( setFontFraktur() )
- A fallback font MTEFallbackGreek for greek letter (if the letters are not present in the currently used font) \c \\alpha ... ( setFallbackFontGreek() )
- A fallback font MTEFallbackSymbols for (math) symbols (if the symbols are not present in the currently used font). ( setFallbackFontSymbols() )
- A fallback font MTEFallbackSymbols for (math) symbols, greek letters ... (if the symbols are not present in the currently used font). ( setFallbackFontSymbols() )
.
These fonts are generic font classes, which font is actually used can be configured in JKQTMathText class with the \c set...() functions mentioned above. You can also use these functions to set the fonts used for math rendering in math-mode:
@ -207,6 +206,7 @@ class JKQTMathTextNode; // forward
<br>using "Arial": \image html jkqtmathtext/jkqtmathparser_arial.png
<br>using "Courier New": \image html jkqtmathtext/jkqtmathparser_couriernew.png
<br>using "Comic Sans MS": \image html jkqtmathtext/jkqtmathparser_comicsans.png
<br>using "Old English Text": \image html jkqtmathtext/jkqtmathparser_OldEnglish.png
.
Math-mode is activated by enclosing your equation in \c $...$ or \c \\[...\\] . This mode is optimized for mathematical equations. Here is an example of the difference:
@ -216,7 +216,7 @@ class JKQTMathTextNode; // forward
Font Lookup for symbols works as follows in JKQTMathTextSymbolNode:
- if a character is found in the current (or to be used) font, it is taken from there
- if the character is not found, it is looked for in the fallback fonts MTEFallbackGreek and MTEFallbackSymbols
- if the character is not found, it is looked for in the fallback fonts MTEFallbackSymbols
- as a last resort, some symbols can be created otherwise, so if neither of the two options above
contain the required symbol, the symbol might be synthesized otherwise, or a rectangle with the size of "X" is drawn instead
@ -378,10 +378,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
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 setFallbackFontGreek(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard);
/** \brief retrieves the font to be used for greek letters in the logical font \a font */
QString getFallbackFontGreek() 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 setFallbackFontSymbols(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard);
/** \brief retrieves the font to be used for symbols in the logical font \a font */
@ -389,8 +385,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
/** \brief retrieves the encoding used for the symbol font to be used for symbols */
JKQTMathTextFontEncoding getFontEncodingFallbackFontSymbols() const;
/** \brief retrieves the encoding used for the greek letter font to be used for greek letters */
JKQTMathTextFontEncoding getFontEncodingFallbackFontGreek() const;
/** \brief retrieves the encoding used for the script font */
JKQTMathTextFontEncoding getFontEncodingScript() const;
/** \brief retrieves the encoding used for the Fraktur font */
@ -460,7 +454,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
* <code>useAnyUnicode("Arial", "Arial")</code>:<br>\image html jkqtmathtext/jkqtmathparser_arial.png <br><br>
* <code>useAnyUnicode("Courier New", "Courier New")</code>:<br>\image html jkqtmathtext/jkqtmathparser_couriernew.png <br><br>
* <code>useAnyUnicode("Comic Sans MS", "Comic Sans MS")</code>:<br>\image html jkqtmathtext/jkqtmathparser_comicsans.png <br><br>
*
* <code>useAnyUnicodeForTextOnly("Comic Sans MS", "Comic Sans MS");</code>:<br/>\image html jkqtmathparser_comicsans_textonly.png
*/
void useAnyUnicode(QString timesFont, const QString& sansFont, JKQTMathTextFontEncoding encodingTimes=JKQTMathTextFontEncoding::MTFEUnicode, JKQTMathTextFontEncoding encodingSans=JKQTMathTextFontEncoding::MTFEUnicode);
/** \brief sets \a timesFont (with its encoding \a encodingTimes ) for serif-text and \a sansFont (with its encoding \a encodingSans ) for mathmode fonts only
@ -474,6 +468,9 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
/** \brief sets \a timesFont (with its encoding \a encodingTimes ) for serif-text and \a sansFont (with its encoding \a encodingSans ) for both mathmode fonts only
*
* \see useAnyUnicodeForMathOnly(), useAnyUnicode()
*
* <code>useAnyUnicode("Comic Sans MS", "Comic Sans MS")</code>:<br>\image html jkqtmathtext/jkqtmathparser_comicsans.png <br><br>
* <code>useAnyUnicodeForTextOnly("Comic Sans MS", "Comic Sans MS");</code>:<br/>\image html jkqtmathparser_comicsans_textonly.png
*/
void useAnyUnicodeForTextOnly(QString timesFont, const QString& sansFont, JKQTMathTextFontEncoding encodingTimes=JKQTMathTextFontEncoding::MTFEUnicode, JKQTMathTextFontEncoding encodingSans=JKQTMathTextFontEncoding::MTFEUnicode);

View File

@ -490,7 +490,6 @@ QFont JKQTMathTextEnvironment::getFont(JKQTMathText* parent) const {
case MTEfraktur: f.setFamily(parent->getFontFraktur()); break;
case MTEmathRoman: f.setFamily(parent->getFontMathRoman()); break;
case MTEFallbackSymbols: f.setFamily(parent->getFallbackFontSymbols()); break;
case MTEFallbackGreek: f.setFamily(parent->getFallbackFontGreek()); break;
case MTECustomFont: f.setFamily(customFontName); break;
default:
case MTEroman: if (insideMath) {

View File

@ -219,12 +219,10 @@ enum JKQTMathTextEnvironmentFont {
MTEblackboard, /*!< \brief blackboard font, e.g. <code>\\mathbb{}</code> */
MTEcaligraphic, /*!< \brief caligraphic font, e.g. <code>\\mathcal{}</code> */
MTEfraktur, /*!< \brief fraktur font, e.g. <code>\\mathfrak{}</code> */
MTEFallbackSymbols, /*!< \brief symbol font */
MTEEnvironmentFontCount, /*!< \brief internal enum value that allows to iterate over MTenvironmentFont \internal */
MTECurrentFont, /*!< \brief internal enum value that specifies that the currently set font shall be used \internal */
MTECustomFont, /*!< \brief internal enum value that specifies that a custom font specified elsewhere shall be used \internal */
MTEFallbackSymbols, /*!< \brief symbol font */
MTEFallbackGreek, /*!< \brief greek letters font */
};

View File

@ -194,7 +194,7 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
const double xheight=fm.xHeight();
const double xwidth=JKQTMathTextGetTightBoundingRect(f, "x", painter.device()).width();
const double linewideth=qMax(0.0,ceil(currentEv.fontSize/16.0));//fm.lineWidth();
const double linewideth=fm.lineWidth();
const double Mheight=JKQTMathTextGetTightBoundingRect(f, "M", painter.device()).height();//fm.ascent();
const double qheight=JKQTMathTextGetTightBoundingRect(f, "q", painter.device()).height();//fm.ascent();
const double braceheight=fm.xHeight()*parentMathText->getUnderbraceBraceSizeXFactor();
@ -238,7 +238,7 @@ double JKQTMathTextFracNode::draw(QPainter& painter, double x, double y, JKQTMat
painter.setPen(p);
if (mode==JKQTMathTextFracNode::MTFMfrac || mode==JKQTMathTextFracNode::MTFMdfrac || mode==JKQTMathTextFracNode::MTFMtfrac) {
deltaWidth=xwidth/2.0;
const QLineF l(x+p.widthF(), yline, x+maxWidth+deltaWidth-p.widthF(), yline);
const QLineF l(x+p.widthF()*2.0, yline, x+maxWidth+deltaWidth-p.widthF()*2.0, yline);
if (l.length()>0) painter.drawLine(l);
child1->draw(painter, x+deltaWidth/2.0+(maxWidth-width1)/2.0, yline-xheight*(parentMathText->getFracShiftFactor())-descent1, ev1);
child2->draw(painter, x+deltaWidth/2.0+(maxWidth-width2)/2.0, yline+xheight*(parentMathText->getFracShiftFactor())+ascent2, ev2);

View File

@ -35,8 +35,8 @@
JKQTMathTextSymbolNode::JKQTMathTextSymbolNode(JKQTMathText* _parent, const QString& name, bool _addWhitespace):
JKQTMathTextNode(_parent), symbolName(name), addWhitespace(_addWhitespace)
JKQTMathTextSymbolNode::JKQTMathTextSymbolNode(JKQTMathText* _parent, const QString& name):
JKQTMathTextNode(_parent), symbolName(name)
{
fillSymbolTables();
}
@ -88,6 +88,7 @@ void JKQTMathTextSymbolNode::getSymbolSizeInternal(QPainter &painter, JKQTMathTe
} else {
overallHeight=tbrNoSymbol.height();
baselineHeight=tbrNoSymbol.height()-tbrNoSymbol.bottom();
width=tbrNoSymbol.width();
}
const double oldDescent=overallHeight-baselineHeight;
@ -95,6 +96,9 @@ void JKQTMathTextSymbolNode::getSymbolSizeInternal(QPainter &painter, JKQTMathTe
baselineHeight=fm.ascent();
overallHeight=baselineHeight+oldDescent;
}
if (has(symflags, RotateSymbol90)) {
width=qMax(overallHeight, width);
}
strikeoutPos=fm.strikeOutPos();
if (has(globalFlags, IntLikeSymbolCorrection)) {
@ -153,11 +157,11 @@ QRectF JKQTMathTextSymbolNode::getTightBoundingRect(const QFontMetricsF &fm, con
}
}
void JKQTMathTextSymbolNode::drawText(QPainter &p, const QString &text, GlobalSymbolFlags globalFlags)
void JKQTMathTextSymbolNode::drawText(QPainter &p, const QString &text, GlobalSymbolFlags globalFlags, SymbolFlags symflags)
{
const QFontMetricsF fm(p.font());
if (has(globalFlags, MakeWhitespaceHalf) && text.contains(' ')) {
const QStringList str=text.simplified().trimmed().split(' ');
const QFontMetricsF fm(p.font());
const QRectF brSp=fm.boundingRect("i");
double x=0;
for (int i=0; i<str.size(); i++) {
@ -165,6 +169,22 @@ void JKQTMathTextSymbolNode::drawText(QPainter &p, const QString &text, GlobalSy
x=x+fm.boundingRect(str[i]).width()+brSp.width()/2.0;
}
} else {
const QRectF tbr=fm.tightBoundingRect(text);
p.save(); auto __finalpaint=JKQTPFinally([&p]() {p.restore();});
p.translate(tbr.center());
if (has(symflags, RotateSymbol90)) {
//qDebug()<<" --> RotateSymbol90";
p.rotate(90);
}
if (has(symflags, FlipSymbolUpDown)) {
//qDebug()<<" --> FlipSymbolUpDown";
p.scale(1,-1);
}
if (has(symflags, FlipSymbolLeftRight)) {
//qDebug()<<" --> FlipSymbolLeftRight";
p.scale(-1,1);
}
p.translate(-tbr.center());
p.drawText(QPointF(0,0), text);
}
}
@ -181,16 +201,20 @@ double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTM
const GlobalSymbolFlags globalFlags=fullProps.globalFlags;
const auto drawProps=fullProps.getDrawingData(currentEv, parentMathText);
const QFont f=drawProps.first;
const QFont fnonItalic=JKQTMathTextGetNonItalic(drawProps.first);
const QFontMetricsF fm(f);
const QFontMetricsF fmNonItalic(fnonItalic);
const JKQTMathTextSymbolNode::SymbolProps symprops=drawProps.second;
const SymbolFlags symflags=symprops.flags;
const QString sym=symprops.symbol;
const QRectF tbr=getTightBoundingRect(fm, sym, globalFlags);
const QRectF tbrNonItalic=getTightBoundingRect(fmNonItalic, sym, globalFlags);
const QRectF br=getBoundingRect(fm, sym, globalFlags);
const QRectF tbrNoSymbol=JKQTMathTextGetTightBoundingRect(f, "X", painter.device());
const double yShift=symprops.yShiftFactor*tbr.height();
const double xShift=(width-tbr.width())/2.0;
const QPointF x0(x+xShift-tbr.x(), y+yShift);
const double italic_xcorrection=tbr.width()-tbrNonItalic.width();
//qDebug()<<"SYMB::draw(): symbolName="<<symbolName<<" font="<<f<<" sym="<<sym<<" yShiftFactor="<<symprops.yShiftFactor;
@ -200,15 +224,33 @@ double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTM
painter.setFont(f);
painter.setPen(currentEv.color);
painter.translate(x0);
drawText(painter, sym, globalFlags);
if (has(symflags, DrawBar)) {
drawText(painter, sym, globalFlags, symflags);
if (has(symflags, DrawLeftHBar) || has (symflags, DrawRightHBar)) {
//qDebug()<<" -> DrawLeftHBar or DrawRightHBar";
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
painter.setPen(QPen(currentEv.color, fm.lineWidth()));
const double ybar=0.66*tbr.top();
painter.drawLine(br.width()-tbrNoSymbol.width()/2.0, ybar, br.width(), ybar);
const double ybar=-(fm.xHeight()+fm.ascent())/2.0;
const double deltaybar=(fm.ascent()-fm.xHeight())*0.25;
const double barwidth=tbrNonItalic.width()/2.0;
const double xbarstart=(has(symflags, DrawLeftHBar))?italic_xcorrection:(tbr.width()-barwidth);
painter.drawLine(xbarstart, ybar, xbarstart+barwidth, ybar-deltaybar);
}
if (has(symflags, DrawVertLine)) {
//qDebug()<<" -> DrawVertLine";
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
painter.setPen(QPen(currentEv.color, fm.lineWidth()));
const double ybar=tbr.top();
const double xbarstart=italic_xcorrection+tbrNonItalic.width()/2.0;
const double xbarend=tbrNonItalic.width()/2.0;
painter.drawLine(xbarstart, ybar, xbarend, ybar+tbr.height());
}
if (has(symflags, DrawSlash)) {
painter.drawText(QPointF(0,0),"/");
//qDebug()<<" -> DrawSlash";
painter.drawText(QPointF((width-fm.boundingRect('/').width())/2.0,0),"/");
}
if (has(symflags, DrawBackSlash)) {
//qDebug()<<" -> DrawBackSlash";
painter.drawText(QPointF((width-fm.boundingRect('\\').width())/2.0,0),"\\");
}
/*painter.save();
painter.setPen(QPen(QColor("red"), 0.5, Qt::DotLine));
@ -242,11 +284,6 @@ QString JKQTMathTextSymbolNode::getSymbolName() const {
return this->symbolName;
}
bool JKQTMathTextSymbolNode::getAddWhitespace() const
{
return addWhitespace;
}
void JKQTMathTextSymbolNode::getSymbolSize(QPainter &painter, JKQTMathTextEnvironment currentEv, double &width, double &baselineHeight, double &overallHeight, double &strikeoutPos, double &subSuperXCorrection, double &subBesidesXCorrection, const JKQTMathTextNodeSize *prevNodeSize)
{
double w=width, b=baselineHeight, o=overallHeight, s=strikeoutPos;
@ -309,7 +346,19 @@ JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::MathOperatorSymb
JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::GreekLetter_WinSymbol_Unicode_Html(const QString &letterWinSymbol, const QString &letterUnicode, const QString &html)
{
return SymbolFullProps(MTEFallbackGreek, MTFEUnicode, SymbolProps(letterUnicode), MTFEWinSymbol, SymbolProps(letterWinSymbol), html);
return SymbolFullProps(MTFEUnicode, SymbolProps(letterUnicode), MTFEWinSymbol, SymbolProps(letterWinSymbol), html);
}
JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::UprightGreekLetter_WinSymbol_Unicode_Html(const QString &letterWinSymbol, const QString &letterUnicode, const QString &html)
{
return SymbolFullProps(MTFEUnicode, SymbolProps(letterUnicode, ItalicOff), MTFEWinSymbol, SymbolProps(letterWinSymbol, ItalicOff), html, ItalicOff);
}
void JKQTMathTextSymbolNode::addGreekLetterVariants_WinSymbol_Unicode_Html(const QString &baseInstructionName, const QString &letterWinSymbol, const QString &letterUnicode, const QString &html)
{
symbols[baseInstructionName]=GreekLetter_WinSymbol_Unicode_Html(letterWinSymbol, letterUnicode, html);
symbols["text"+baseInstructionName]=GreekLetter_WinSymbol_Unicode_Html(letterWinSymbol, letterUnicode, html);
symbols["up"+baseInstructionName]=UprightGreekLetter_WinSymbol_Unicode_Html(letterWinSymbol, letterUnicode, html);
}
JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SymbolStd(const QString &symbol, const QString &html)
@ -317,11 +366,21 @@ JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SymbolStd(const
return SymbolFullProps(MTFEStandard, SymbolProps(symbol), html);
}
JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SymbolUnicode(const QString &symbol, SymbolFlags _flags, double _fontScalingFactor, double _yShiftFactor)
{
return SymbolFullProps(MTFEUnicode, SymbolProps(symbol, _flags, _fontScalingFactor, _yShiftFactor));
}
JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SymbolUnicode(const QString &symbol, const QString &html)
{
return SymbolFullProps(MTFEUnicode, SymbolProps(symbol), html);
}
JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SymbolStd(const QString &symbol, SymbolFlags _flags, double _fontScalingFactor, double _yShiftFactor)
{
return SymbolFullProps(MTFEStandard, SymbolProps(symbol, _flags, _fontScalingFactor, _yShiftFactor), symbol);
}
JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::UprightSymbolStd(const QString &symbol, const QString &html)
{
return SymbolFullProps(MTFEStandard, SymbolProps(symbol, ItalicOff), html, ItalicOff);
@ -337,9 +396,9 @@ JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SimpleTextSymbol
return SymbolFullProps(MTFEStandard, SymbolProps(symbol), html);
}
JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SimpleTextSymbol(const QString &symbol)
JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SimpleTextSymbol(const QString &symbol, SymbolFlags _flags, double _fontScalingFactor, double _yShiftFactor)
{
return SymbolFullProps(MTFEStandard, SymbolProps(symbol), symbol);
return SymbolFullProps(MTFEStandard, SymbolProps(symbol, _flags, _fontScalingFactor, _yShiftFactor), symbol);
}
JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SimpleUprightTextSymbol(const QString &symbol, const QString &html)
@ -377,74 +436,95 @@ void JKQTMathTextSymbolNode::fillSymbolTables()
symbols["|"]=SimpleUprightTextSymbol("||", "&Vert;").addUprightUnicode(QChar(0x2016));
symbols["}"]=SimpleUprightTextSymbol("}");
symbols["AC"]=UprightSymbolUnicode(QChar(0x223F)).addUprightHtml("&acd;").addUprightStd("~");
symbols["Angstrom"]= symbols["Angstroem"]=UprightSymbolUnicode(QChar(0x212B)).addUprightStd(QChar(0xC5));
symbols["Beth"]=symbols["Bet"]=symbols["beth"]=symbols["bet"]=SymbolUnicode(QChar(0x2136)).addHtml("&beth;");
{ auto s=UprightSymbolUnicode(QChar(0x212B)).addUprightStd(QChar(0xC5));
symbols["Angstrom"]=s; symbols["Angstroem"]=s; }
{ auto s=SymbolUnicode(QChar(0x2136)).addHtml("&beth;");
symbols["Beth"]=s; symbols["Bet"]=s; symbols["beth"]=s; symbols["bet"]=s; }
symbols["Box"]=UprightSymbolUnicode(QChar(0x25A1));
symbols["DC"]=SymbolUnicode(QChar(0x2393)).addWinSymbol(QChar(0xBB)).addStd("=");
symbols["EUR"]=SymbolUnicode(QChar(0x20AC));
symbols["Im"]=UprightSymbolUnicode(QChar(0x2111)).addHtml("&image;").addWinSymbol(QChar(0xC1));
symbols["No"]=SymbolUnicode(QChar(0x2116));
symbols["Ohm"]=symbols["ohm"]=UprightSymbolUnicode(QChar(0x2126)).addUprightWinSymbol("W").addUprightHtml("&Omega;");
{ auto s=UprightSymbolUnicode(QChar(0x2126)).addUprightWinSymbol("W").addUprightHtml("&Omega;");
symbols["Ohm"]=s; symbols["ohm"]=s; }
symbols["P"]=SimpleTextSymbol(QChar(0xB6)).addHtml("&para;");
symbols["Re"]=SymbolUnicode(QChar(0x211C)).addHtml("&Rfr;").addWinSymbol(QChar(0xC2));
symbols["S"]=symbols["§"]=SimpleTextSymbol(QChar(0xA7)).addHtml("&sect;");
{ auto s=SimpleTextSymbol(QChar(0xA7)).addHtml("&sect;");
symbols["S"]=s; symbols["§"]=s;}
symbols["accurrent"]=SymbolUnicode(QChar(0x23E6));
symbols["alef"]=symbols["aleph"]=symbols["Aleph"]=symbols["Alef"]=SymbolUnicode(QChar(0x2135)).addHtml("&aleph;").addWinSymbol(QChar(0xC0));
{ auto s=SymbolUnicode(QChar(0x2135)).addHtml("&aleph;").addWinSymbol(QChar(0xC0));
symbols["alef"]=s; symbols["aleph"]=s; symbols["Aleph"]=s; symbols["Alef"]=s; }
symbols["angle"]=UprightSymbolUnicode(QChar(0x2220)).addHtml("&angle;").addWinSymbol(QChar(0xD0));
symbols["backslash"]=SimpleTextSymbol("\\");
symbols["benzene"]=UprightSymbolUnicode(QChar(0x232C));
symbols["benzenr"]=UprightSymbolUnicode(QChar(0x23E3));
symbols["blacksquare"]=UprightSymbolUnicode(QChar(0x220E)).addHtml("&squ;");
symbols["blcorner"]=symbols["llcorner"]=UprightSymbolUnicode(QChar(0x231E));
symbols["brcorner"]=symbols["lrcorner"]=UprightSymbolUnicode(QChar(0x231F));
{ auto s=UprightSymbolUnicode(QChar(0x231E));
symbols["blcorner"]=s; symbols["llcorner"]=s; }
{ auto s=UprightSymbolUnicode(QChar(0x231F));
symbols["brcorner"]=s; symbols["lrcorner"]=s; }
symbols["bullet"]=UprightSymbolUnicode(QChar(0x2022)).addUprightHtml("&bull;").addUprightWinSymbol(QChar(0xB7));
symbols["cdots"]=SymbolUnicode(QChar(0x22EF)).addHtml("&middot;&middot;&middot;").addStd(QString(3, QChar(0xB7)));
symbols["celsius"]=symbols["degC"]=SymbolUnicode(QChar(0x2103)).addUprightStd("°C").addUprightHtml("&deg;C");
{ auto s=SymbolUnicode(QChar(0x2103)).addUprightStd("°C").addUprightHtml("&deg;C");
symbols["celsius"]=s; symbols["degC"]=s; }
symbols["cent"]=SimpleTextSymbol(QChar(0xA2), "&cent;");
symbols["circ"]=UprightSymbolStd(QChar(0x2218));
symbols["circ"]=UprightSymbolStd(QChar(0x2218)).addUprightHtml("&SmallCircle;").addStd("o", ItalicOff,0.7, -0.25);
symbols["co"]=UprightSymbolUnicode(QChar(0x2105));
symbols["copyright"]=symbols["textcopyright"]=SimpleTextSymbol(QChar(0xA5), "&copy;");
symbols["dalet"]=symbols["Dalet"]=symbols["daleth"]=symbols["Daleth"]=SymbolUnicode(QChar(0x2138)).addHtml("&daleth;");
{ auto s=SimpleTextSymbol(QChar(0xA5), "&copy;");
symbols["copyright"]=s; symbols["textcopyright"]=s; }
symbols["dagger"]=UprightSymbolUnicode(QChar(0x2020)).addUprightHtml("&dagger;");
symbols["ddagger"]=UprightSymbolUnicode(QChar(0x2021)).addUprightHtml("&ddagger;");
{ auto s=SymbolUnicode(QChar(0x2138)).addHtml("&daleth;");
symbols["dalet"]=s; symbols["Dalet"]=s; symbols["daleth"]=s; symbols["Daleth"]=s; }
symbols["dd"] = SymbolFullProps(SymbolProps("d", Upright|BoldOff), "d", Upright|BoldOff);
symbols["diamond"]=UprightSymbolUnicode(QChar(0x22C4)).addHtml("&diam;").addWinSymbol(QChar(0xE0));
symbols["dollar"]=SymbolUnicode(QChar(0x0024));
symbols["dollar"]=symbols["$"]=SimpleTextSymbol(QChar(0x24), "&dollar;");
{ auto s=SimpleTextSymbol(QChar(0x24), "&dollar;");
symbols["dollar"]=s; symbols["$"]=s; }
symbols["dprime"]=SymbolUnicode(QChar(0x2033)).addHtml("&Prime;").addStd("''");
symbols["ellipsis"]=symbols["dots"]=symbols["ldots"]=SymbolUnicode(QChar(0x2026)).addHtml("&mldr;").addWinSymbol(QChar(0xBC)).addStd("...");
symbols["euro"]=symbols["EUR"]=SimpleTextSymbol(QChar(0x20AC), "&euro;");
symbols["fahrenheit"]=symbols["degF"]=SymbolUnicode(QChar(0x2109));
symbols["ee"] = SymbolFullProps(SymbolProps("e", Upright|BoldOff), "e", Upright|BoldOff);
{ auto s=SymbolUnicode(QChar(0x2026)).addHtml("&mldr;").addWinSymbol(QChar(0xBC)).addStd("...");
symbols["ellipsis"]=s; symbols["dots"]=s; symbols["ldots"]=s; }
{ auto s=SimpleTextSymbol(QChar(0x20AC), "&euro;");
symbols["euro"]=s; symbols["EUR"]=s; }
{ auto s=SymbolUnicode(QChar(0x2109));
symbols["fahrenheit"]=s; symbols["degF"]=s; }
symbols["female"]=SymbolUnicode(QChar(0x2640)).addHtml("&female;");
symbols["flq"]=SymbolUnicode(QChar(0x2039)).addHtml("&lsaquo;").addStd("<");
symbols["flqq"]=SymbolUnicode(QChar(0x00AB)).addHtml("&laquo;").addStd(QChar(0xAB));
symbols["frown"]=SymbolUnicode(QChar(0x2322)).addHtml("&frown;");
symbols["frq"]=SymbolUnicode(QChar(0x203A)).addHtml("&rsaquo;").addStd(">");
symbols["frqq"]=SymbolUnicode(QChar(0x00BB)).addHtml("&raquo;").addStd(QChar(0xBB));
symbols["gimel"]=symbols["Gimel"]=SymbolUnicode(QChar(0x2137)).addHtml("&gimel;");
{ auto s=SymbolUnicode(QChar(0x2137)).addHtml("&gimel;");
symbols["gimel"]=s; symbols["Gimel"]=s; }
symbols["glq"]=SymbolUnicode(QChar(0x2018)).addHtml("&OpenCurlyQuote;").addStd("'");
symbols["glqq"]=SymbolUnicode(QChar(0x201C)).addHtml("&OpenCurlyDoubleQuote;").addStd("\"");
symbols["grq"]=SymbolUnicode(QChar(0x2019)).addHtml("&CloseCurlyQuote;").addStd("'");
symbols["grqq"]=SymbolUnicode(QChar(0x201D)).addHtml("&CloseCurlyDoubleQuote;").addStd("\"");
symbols["hbar"]=SymbolUnicode(QChar(0x210F)).addHtml("&hbar;").addStd("h", DrawBar);
symbols["hbar"]=UprightSymbolUnicode(QChar(0x210F)).addUprightHtml("&hbar;").addStd("h", ItalicOn|DrawLeftHBar);
symbols["hexagon"]=UprightSymbolUnicode(QChar(0x2394));
symbols["ii"] = SymbolFullProps(SymbolProps("i", Upright|BoldOff), "i", Upright|BoldOff);
symbols["infty"]=SymbolUnicode(QChar(0x221E)).addHtml("&infin;").addWinSymbol(QChar(0xA5)).addStd("8", Rotate90);
symbols["infty"]=SymbolUnicode(QChar(0x221E)).addHtml("&infin;").addWinSymbol(QChar(0xA5)).addStd("8", RotateSymbol90);
symbols["langle"]=UprightSymbolUnicode(QChar(0x2329)).addWinSymbol(QChar(0xE1));
symbols["lceil"]=UprightSymbolUnicode(QChar(0x2308)).addHtml("&LeftCeiling;").addWinSymbol(QChar(0xE9));
symbols["ldots"]=symbols["dots"]=SimpleTextSymbol("...");
{ auto s=SimpleTextSymbol("...").addUnicode(QChar(0x2026)).addWinSymbol(QChar(0xB6));
symbols["ldots"]=s; symbols["dots"]=s; }
symbols["lfloor"]=UprightSymbolUnicode(QChar(0x230A)).addHtml("&LeftFloor;").addWinSymbol(QChar(0xEB));
symbols["lightning"]=SymbolUnicode(QChar(0x21AF));
symbols["male"]=SymbolUnicode(QChar(0x2642)).addHtml("&male;");
symbols["measuredangle"]=UprightSymbolUnicode(QChar(0x2221)).addHtml("&measuredangle;");
symbols["micro"] = SimpleTextSymbol(QChar(0xB5), "&micro;");
symbols["ohm"]=SymbolUnicode(QChar(0x2126));
symbols["partial"]=UprightSymbolUnicode(QChar(0x2202)).addHtml("&part;").addWinSymbol(QChar(0xB6));
symbols["perthousand"]=symbols["permil"]=SymbolUnicode(QChar(0x2030)).addHtml("&permil;");
symbols["ohm"]=UprightSymbolUnicode(QChar(0x2126)).addUprightHtml("&Omega;").addUprightWinSymbol(QChar(0x57));
symbols["partial"]=UprightSymbolUnicode(QChar(0x2202)).addUprightHtml("&part;").addUprightWinSymbol(QChar(0xB6));
{ auto s=SymbolUnicode(QChar(0x2030)).addHtml("&permil;");
symbols["perthousand"]=s; symbols["permil"]=s; }
symbols["pound"]=SimpleTextSymbol(QChar(0xA3), "&pound;");
symbols["pound"]=SymbolUnicode(QChar(0x00A3));
symbols["prime"]=SymbolUnicode(QChar(0x2032)).addHtml("&prime;").addStd("'");
symbols["rangle"]=UprightSymbolUnicode(QChar(0x232A)).addWinSymbol(QChar(0xF1));
symbols["rceil"]=UprightSymbolUnicode(QChar(0x2309)).addHtml("&RightCeiling;").addWinSymbol(QChar(0xF9));
symbols["registered"]=symbols["textregistered"]=symbols["circledR"]=SimpleTextSymbol(QChar(0xAA), "&reg;");
{ auto s=SimpleTextSymbol(QChar(0xAA), "&reg;");
symbols["registered"]=s; symbols["textregistered"]=s; symbols["circledR"]=s; }
symbols["rfloor"]=UprightSymbolUnicode(QChar(0x230B)).addHtml("&RightFloor;").addWinSymbol(QChar(0xFB));
symbols["rightangle"]=UprightSymbolUnicode(QChar(0x221F)).addHtml("&angrt;");
symbols["smile"]=UprightSymbolUnicode(QChar(0x2323)).addHtml("&smile;");
@ -452,18 +532,20 @@ void JKQTMathTextSymbolNode::fillSymbolTables()
symbols["star"]=UprightSymbolUnicode(QChar(0x22C6));
symbols["tcohm"]=SymbolUnicode(QChar(0x2126));
symbols["textbar"]=SimpleTextSymbol("|", "&VerticalLine;");
symbols["textdegree"]=symbols["degree"] = SimpleTextSymbol(QChar(0xB0), "&deg;");
{ auto s=SimpleTextSymbol(QChar(0xB0), "&deg;");
symbols["textdegree"]=s; symbols["degree"] = s; }
symbols["textgreater"]=SimpleTextSymbol(">", "&gt;");
symbols["textless"]=SimpleTextSymbol("<", "&lt;");
symbols["tlcorner"]=symbols["ulcorner"]=SymbolUnicode(QChar(0x231C));
{ auto s=SymbolUnicode(QChar(0x231C));
symbols["tlcorner"]=s; symbols["ulcorner"]=s; }
symbols["trademark"]=SymbolUnicode(QChar(0x2122)).addHtml("&trade;").addWinSymbol(QChar(0xD4)).addStd("(TM)");
symbols["trapezium"]=SymbolUnicode(QChar(0x23E2)).addHtml("&trpezium;");
symbols["trcorner"]=symbols["urcorner"]=UprightSymbolUnicode(QChar(0x231D));
{ auto s=UprightSymbolUnicode(QChar(0x231D));
symbols["trcorner"]=s; symbols["urcorner"]=s; }
symbols["trprime"]=SymbolUnicode(QChar(0x2034)).addHtml("&tprime;").addStd("'''");
symbols["varcarriagereturn"]=SymbolUnicode(QChar(0x23CE)).addWinSymbol(QChar(0xBF));
symbols["varhexagonlrbonds"]=SymbolUnicode(QChar(0x232C));
symbols["yen"]=SimpleTextSymbol(QChar(0xA5), "&yen;");
symbols["yen"]=SymbolUnicode(QChar(0x00A5));
@ -516,11 +598,12 @@ void JKQTMathTextSymbolNode::fillSymbolTables()
/**************************************************************************************
* STANDARD MathOperator Symbols
**************************************************************************************/
symbols["*"]=symbols["ast"]=symbols["asterisk"]=MathOperatorSymbolUnicode(QChar(0x2217)).addMathOperatorStd("*").addMathOperatorHtml("*");
{ auto s=MathOperatorSymbolUnicode(QChar(0x2217)).addMathOperatorStd("*").addMathOperatorHtml("*");
symbols["*"]=s; symbols["ast"]=s; symbols["asterisk"]=s; }
symbols["+"]=MathOperatorSymbolUnicode(QChar(0x2B)).addMathOperatorHtml("+").addMathOperatorStd("+");
symbols["-"]=MathOperatorSymbolUnicode(QChar(0x2212)).addMathOperatorHtml("-").addMathOperatorStd("-");
symbols["<"]=MathOperatorSymbol("<", "&lt;");
symbols["="] = MathOperatorSymbol("=");
symbols["="]=MathOperatorSymbol("=");
symbols[">"]=MathOperatorSymbol(">", "&gt;");
symbols["Downarrow"]=UprightSymbolUnicode(QChar(0x21D3)).addUprightHtml("&DoubleDownArrow;").addUprightWinSymbol(QChar(0xDF));
symbols["Leftarrow"]=UprightSymbolUnicode(QChar(0x21D0)).addUprightHtml("&DoubleLeftArrow;").addUprightWinSymbol(QChar(0xDC));
@ -540,26 +623,32 @@ void JKQTMathTextSymbolNode::fillSymbolTables()
symbols["bigcup"]=MathOperatorSymbolUnicode(QChar(0x22C3)).addMathOperatorHtml("&int;").addMathOperatorWinSymbol(QChar(0xC8), 1.8);
symbols["bighat"]=MathOperatorSymbolUnicode(QChar(0x22C0)).addMathOperatorHtml("&int;").addMathOperatorWinSymbol(QChar(0xD9), 1.8);
symbols["bigvee"]=MathOperatorSymbolUnicode(QChar(0x22C1)).addMathOperatorHtml("&int;").addMathOperatorWinSymbol(QChar(0xDA), 1.8);
symbols["bot"]=symbols["perp"]=MathOperatorSymbolUnicode(QChar(0x22A5)).addMathOperatorHtml("&UpTee;");
symbols["cap"]=symbols["land"]=MathOperatorSymbolUnicode(QChar(0x2229)).addMathOperatorHtml("&cap;").addMathOperatorWinSymbol(QChar(0xC7));
{ auto s=MathOperatorSymbolUnicode(QChar(0x22A5)).addMathOperatorHtml("&UpTee;");
symbols["bot"]=s; symbols["perp"]=s; }
{ auto s=MathOperatorSymbolUnicode(QChar(0x2229)).addMathOperatorHtml("&cap;").addMathOperatorWinSymbol(QChar(0xC7));
symbols["cap"]=s; symbols["land"]=s; }
symbols["cdot"]=MathOperatorSymbol(QChar(0xB7)).addMathOperatorHtml("&middot;").addMathOperatorWinSymbol(QChar(0xD7));
symbols["cong"]=MathOperatorSymbolUnicode(QChar(0x2245)).addMathOperatorHtml("&TildeFullEqual;");
symbols["coprod"]=MathOperatorSymbolUnicode(QChar(0x2210)).addMathOperatorHtml("&Coproduct;").addWinSymbol(QChar(0xD5), ItalicOff|BoldOff|FlipUpDown, 1.8, 0.1);
symbols["cup"]=symbols["lor"]=MathOperatorSymbolUnicode(QChar(0x222A)).addMathOperatorHtml("&cup;").addMathOperatorWinSymbol(QChar(0xC8));
symbols["coprod"]=MathOperatorSymbolUnicode(QChar(0x2210)).addMathOperatorHtml("&Coproduct;").addWinSymbol(QChar(0xD5), ItalicOff|BoldOff|FlipSymbolUpDown, 1.8, 0.1);
{ auto s=MathOperatorSymbolUnicode(QChar(0x222A)).addMathOperatorHtml("&cup;").addMathOperatorWinSymbol(QChar(0xC8));
symbols["cup"]=s; symbols["lor"]=s; }
symbols["ddots"]=MathOperatorSymbolUnicode(QChar(0x22F1)).addMathOperatorHtml("&dtdot;");
symbols["div"]=MathOperatorSymbolUnicode(QChar(0x00F7)).addMathOperatorHtml("&div;").addMathOperatorWinSymbol(QChar(0xB8));
symbols["downarrow"]=UprightSymbolUnicode(QChar(0x2193)).addUprightHtml("&ShortDownArrow;").addUprightWinSymbol(QChar(0xAF));
symbols["downharpoonleft"]=UprightSymbolUnicode(QChar(0x21C3)).addUprightHtml("&LeftDownVector;");
symbols["downharpoonright"]=UprightSymbolUnicode(QChar(0x21C2)).addUprightHtml("&RightDownVector;");
symbols["emptyset"]=symbols["varnothing"]=MathOperatorSymbolUnicode(QChar(0x2205)).addMathOperatorHtml("&varnothing;").addMathOperatorWinSymbol(QChar(0xC6)).addStd("0", BoldOff|ItalicOff|DrawSlash);
{ auto s=MathOperatorSymbolUnicode(QChar(0x2205)).addMathOperatorHtml("&varnothing;").addMathOperatorWinSymbol(QChar(0xC6)).addStd("0", BoldOff|ItalicOff|DrawSlash);
symbols["emptyset"]=s; symbols["varnothing"]=s; }
symbols["equiv"]=MathOperatorSymbolUnicode(QChar(0x2261)).addMathOperatorHtml("&equiv;").addMathOperatorWinSymbol(QChar(0xBA));
symbols["exists"]=MathOperatorSymbolUnicode(QChar(0x2203)).addMathOperatorHtml("&exist;").addMathOperatorWinSymbol(QChar(0x24)).addStd("E", ItalicOff|BoldOff|FlipLeftRight);
symbols["forall"]=MathOperatorSymbolUnicode(QChar(0x2200)).addMathOperatorHtml("&forall;").addMathOperatorWinSymbol(QChar(0x22)).addStd("A", ItalicOff|BoldOff|FlipUpDown);
symbols["geq"]=symbols["ge"]=MathOperatorSymbolUnicode(QChar(0x2265)).addMathOperatorHtml("&GreaterEqual;").addMathOperatorWinSymbol(QChar(0xB3));
symbols["exists"]=MathOperatorSymbolUnicode(QChar(0x2203)).addMathOperatorHtml("&exist;").addMathOperatorWinSymbol(QChar(0x24)).addStd("E", ItalicOff|BoldOff|FlipSymbolLeftRight);
symbols["forall"]=MathOperatorSymbolUnicode(QChar(0x2200)).addMathOperatorHtml("&forall;").addMathOperatorWinSymbol(QChar(0x22)).addStd("A", ItalicOff|BoldOff|FlipSymbolUpDown);
{ auto s=MathOperatorSymbolUnicode(QChar(0x2265)).addMathOperatorHtml("&GreaterEqual;").addMathOperatorWinSymbol(QChar(0xB3));
symbols["geq"]=s; symbols["ge"]=s; }
symbols["geqq"]=MathOperatorSymbolUnicode(QChar(0x2267)).addMathOperatorHtml("&GreaterFullEqual;");
symbols["gg"]=MathOperatorSymbolUnicode(QChar(0x226B)).addMathOperatorHtml("&NestedGreaterGreater;").addMathOperatorStd(">>");
symbols["iddots"]=MathOperatorSymbolUnicode(QChar(0x22F0)).addMathOperatorHtml("&utdot;");
symbols["iff"]=symbols["Leftrightarrow"]=UprightSymbolUnicode(QChar(0x21D4)).addUprightHtml("&DoubleLeftRightArrow;").addUprightWinSymbol(QChar(0xDB));
{ auto s=UprightSymbolUnicode(QChar(0x21D4)).addUprightHtml("&DoubleLeftRightArrow;").addUprightWinSymbol(QChar(0xDB));
symbols["iff"]=s; symbols["Leftrightarrow"]=s; }
symbols["iiint"]=MathOperatorSymbolUnicode(QChar(0x222D)).setGlobalFlags(IntLikeSymbolCorrection).addMathOperatorHtml("&tint;").addMathOperatorWinSymbol(QString(3, QChar(0xF2)), 1.8, 0.1);
symbols["iint"]=MathOperatorSymbolUnicode(QChar(0x222C)).setGlobalFlags(IntLikeSymbolCorrection).addMathOperatorHtml("&Int;").addMathOperatorWinSymbol(QString(2, QChar(0xF2)), 1.8, 0.1);
symbols["in"]=MathOperatorSymbolUnicode(QChar(0x2208)).addMathOperatorHtml("&isin;").addMathOperatorWinSymbol(QChar(0xCE));
@ -569,7 +658,8 @@ void JKQTMathTextSymbolNode::fillSymbolTables()
symbols["leftharpoonup"]=UprightSymbolUnicode(QChar(0x21BC)).addUprightHtml("&LeftVector;");
symbols["leftrightarrow"]=UprightSymbolUnicode(QChar(0x2194)).addUprightHtml("&harr;").addUprightWinSymbol(QChar(0xAB));
symbols["leftrightharpoon"]=UprightSymbolUnicode(QChar(0x21CB)).addUprightHtml("&ReverseEquilibrium;");
symbols["leq"]=symbols["le"]=MathOperatorSymbolUnicode(QChar(0x2264)).addMathOperatorHtml("&leq;").addMathOperatorWinSymbol(QChar(0xA3));
{ auto s=MathOperatorSymbolUnicode(QChar(0x2264)).addMathOperatorHtml("&leq;").addMathOperatorWinSymbol(QChar(0xA3));
symbols["leq"]=s; symbols["le"]=s; }
symbols["leqq"]=MathOperatorSymbolUnicode(QChar(0x2266)).addMathOperatorHtml("&LessFullEqual;");
symbols["ll"]=MathOperatorSymbolUnicode(QChar(0x226A)).addMathOperatorHtml("&NestedLessLess;").addMathOperatorStd("<<");
symbols["lnot"]=MathOperatorSymbolUnicode(QChar(0xAC)).addMathOperatorWinSymbol(QChar(0xD8)).addMathOperatorHtml("&not;");
@ -577,15 +667,16 @@ void JKQTMathTextSymbolNode::fillSymbolTables()
symbols["maporiginal"]=MathOperatorSymbolUnicode(QChar(0x22B6)).addMathOperatorHtml("&origof;");
symbols["mapsto"]=MathOperatorSymbolUnicode(QChar(0x21A6)).addMathOperatorHtml("&RightTeeArrow;");
symbols["mid"]=MathOperatorSymbolUnicode(QChar(0x2223)).addMathOperatorHtml("&VerticalBar;").addMathOperatorWinSymbol(QChar(0xBD)).addMathOperatorStd("|");
symbols["mp"]=MathOperatorSymbolUnicode(QChar(0x2213)).addMathOperatorHtml("&mp;");
symbols["mp"]=MathOperatorSymbolUnicode(QChar(0x2213)).addMathOperatorHtml("&mp;").addWinSymbol(QChar(0xB1),ItalicOff|BoldOff|FlipSymbolUpDown).addStd(QChar(0xB1),ItalicOff|BoldOff|FlipSymbolUpDown);
symbols["multimap"]=MathOperatorSymbolUnicode(QChar(0x22B8)).addMathOperatorHtml("&mumap;");
symbols["nabla"]=MathOperatorSymbolUnicode(QChar(0x2207)).addMathOperatorHtml("&nabla;").addMathOperatorWinSymbol(QChar(0xD1));
symbols["ne"]=MathOperatorSymbolUnicode(QChar(0x2260)).addMathOperatorHtml("&ne;").addMathOperatorWinSymbol(QChar(0xB9));
symbols["nearrow"]=UprightSymbolUnicode(QChar(0x2197)).addUprightHtml("&UpperRightArrow;");
symbols["neg"]=symbols["lnot"]=MathOperatorSymbolUnicode(QChar(0x00AC)).addMathOperatorHtml("&not;").addMathOperatorWinSymbol(QChar(0xD8));
{ auto s=MathOperatorSymbolUnicode(QChar(0x00AC)).addMathOperatorHtml("&not;").addMathOperatorWinSymbol(QChar(0xD8));
symbols["neg"]=s; symbols["lnot"]=s; }
symbols["neq"]=MathOperatorSymbolUnicode(QChar(0x2260)).addMathOperatorHtml("&ne;").addMathOperatorWinSymbol(QChar(0xB9)).addStd("=", ItalicOff|BoldOff|DrawSlash);
symbols["nexists"]=MathOperatorSymbolUnicode(QChar(0x2204)).addMathOperatorHtml("&NotExists;").addStd("E", ItalicOff|BoldOff|FlipLeftRight|DrawSlash).addMathOperatorWinSymbol(QChar(0x24), ItalicOff|BoldOff|DrawSlash);
symbols["ni"]=MathOperatorSymbolUnicode(QChar(0x220B)).addMathOperatorHtml("&ReverseElement;").addMathOperatorWinSymbol(QChar(0xCE), ItalicOff|BoldOff|FlipLeftRight);
symbols["nexists"]=MathOperatorSymbolUnicode(QChar(0x2204)).addMathOperatorHtml("&NotExists;").addStd("E", ItalicOff|BoldOff|FlipSymbolLeftRight|DrawSlash).addMathOperatorWinSymbol(QChar(0x24), ItalicOff|BoldOff|DrawSlash);
symbols["ni"]=MathOperatorSymbolUnicode(QChar(0x220B)).addMathOperatorHtml("&ReverseElement;").addMathOperatorWinSymbol(QChar(0xCE), ItalicOff|BoldOff|FlipSymbolLeftRight);
symbols["nmid"]=MathOperatorSymbolUnicode(QChar(0x2224)).addMathOperatorHtml("&NotVerticalBar;");
symbols["notin"]=MathOperatorSymbolUnicode(QChar(0x2209)).addMathOperatorHtml("&notin;").addMathOperatorWinSymbol(QChar(0xCF));
symbols["notni"]=MathOperatorSymbolUnicode(QChar(0x220C)).addMathOperatorHtml("&NotReverseElement;");
@ -609,7 +700,8 @@ void JKQTMathTextSymbolNode::fillSymbolTables()
symbols["rightleftharpoon"]=UprightSymbolUnicode(QChar(0x21CC)).addUprightHtml("&Equilibrium;");
symbols["searrow"]=UprightSymbolUnicode(QChar(0x2198)).addUprightHtml("&LowerRightArrow;");
symbols["setminus"]=MathOperatorSymbolUnicode(QChar(0x2216)).addMathOperatorHtml("&smallsetminus;");
symbols["~"]=symbols["sim"]=symbols["tilde"]=MathOperatorSymbolUnicode(QChar(0x223C)).addMathOperatorHtml("&tilde;").addMathOperatorStd("~");
{ auto s=MathOperatorSymbolUnicode(QChar(0x223C)).addMathOperatorHtml("&tilde;").addMathOperatorStd("~");
symbols["~"]=s; symbols["sim"]=s; symbols["tilde"]=s; }
symbols["simeq"]=MathOperatorSymbolUnicode(QChar(0x2243)).addMathOperatorHtml("&TildeEqual;");
symbols["sqcap"]=MathOperatorSymbolUnicode(QChar(0x2293)).addMathOperatorHtml("&SquareIntersection;");
symbols["sqcup"]=MathOperatorSymbolUnicode(QChar(0x2294)).addMathOperatorHtml("&SquareUnion;");
@ -625,7 +717,8 @@ void JKQTMathTextSymbolNode::fillSymbolTables()
symbols["swarrow"]=UprightSymbolUnicode(QChar(0x2199)).addUprightHtml("&LowerLeftArrow;");
symbols["therefore"]=MathOperatorSymbolUnicode(QChar(0x2234)).addMathOperatorHtml("&therefore;").addMathOperatorWinSymbol(QChar(0x5C));
symbols["times"] = MathOperatorSymbol(QChar(0xD7), "&times;").addMathOperatorWinSymbol(QChar(0xB4));
symbols["to"]=symbols["rightarrow"]=UprightSymbolUnicode(QChar(0x2192)).addUprightHtml("&rarr;").addUprightWinSymbol(QChar(0xAE));
{ auto s=UprightSymbolUnicode(QChar(0x2192)).addUprightHtml("&rarr;").addUprightWinSymbol(QChar(0xAE));
symbols["to"]=s; symbols["rightarrow"]=s; }
symbols["top"]=MathOperatorSymbolUnicode(QChar(0x22A4)).addMathOperatorHtml("&top;").addMathOperatorWinSymbol(QChar(0x5E));
symbols["triangle"]=MathOperatorSymbolUnicode(QChar(0x2206));
symbols["uparrow"]=UprightSymbolUnicode(QChar(0x2191)).addUprightHtml("&ShortUpArrow;").addUprightWinSymbol(QChar(0xAD));
@ -642,46 +735,46 @@ void JKQTMathTextSymbolNode::fillSymbolTables()
/**************************************************************************************
* GREEK letters
**************************************************************************************/
symbols["alpha"]=GreekLetter_WinSymbol_Unicode_Html( "a", QChar(0x3B1), "&alpha;");
symbols["beta"]=GreekLetter_WinSymbol_Unicode_Html("b", QChar(0x3B2), "&beta;");
symbols["gamma"]=GreekLetter_WinSymbol_Unicode_Html("g", QChar(0x3B3), "&gamma;");
symbols["delta"]=GreekLetter_WinSymbol_Unicode_Html("d", QChar(0x3B4), "&delta;");
symbols["epsilon"]=GreekLetter_WinSymbol_Unicode_Html("e", QChar(0x3F5), "&varepsilon;");
symbols["varepsilon"]=GreekLetter_WinSymbol_Unicode_Html("e", QChar(0x3B5), "&epsi;");
symbols["zeta"]=GreekLetter_WinSymbol_Unicode_Html("z", QChar(0x3B6),"&zeta;");
symbols["eta"]=GreekLetter_WinSymbol_Unicode_Html("h", QChar(0x3B7),"&eta;");
symbols["theta"]=GreekLetter_WinSymbol_Unicode_Html("q", QChar(0x3B8),"&theta;");
symbols["vartheta"]=GreekLetter_WinSymbol_Unicode_Html("J", QChar(0x3D1),"&thetasym;");
symbols["iota"]=GreekLetter_WinSymbol_Unicode_Html("i", QChar(0x3B9),"&iota;");
symbols["kappa"]=GreekLetter_WinSymbol_Unicode_Html("k", QChar(0x3BA),"&kappa;");
symbols["lambda"]=GreekLetter_WinSymbol_Unicode_Html("l", QChar(0x3BB),"&lambda;");
symbols["mu"]=GreekLetter_WinSymbol_Unicode_Html("m", QChar(0x3BC),"&mu;");
symbols["nu"]=GreekLetter_WinSymbol_Unicode_Html("n", QChar(0x3BD),"&nu;");
symbols["xi"]=GreekLetter_WinSymbol_Unicode_Html("x", QChar(0x3BE),"&xi;");
symbols["pi"]=GreekLetter_WinSymbol_Unicode_Html("p", QChar(0x3C0),"&pi;");
symbols["varpi"]=GreekLetter_WinSymbol_Unicode_Html("v", QChar(0x3D6),"&piv;");
symbols["rho"]=GreekLetter_WinSymbol_Unicode_Html("r", QChar(0x3C1),"&rho;");
symbols["varrho"]=GreekLetter_WinSymbol_Unicode_Html("r", QChar(0x3F1),"&varrho;");
symbols["sigma"]=GreekLetter_WinSymbol_Unicode_Html("s", QChar(0x3C3),"&sigma;");
symbols["varsigma"]=GreekLetter_WinSymbol_Unicode_Html("V", QChar(0x3C2),"&varsigma;");
symbols["tau"]=GreekLetter_WinSymbol_Unicode_Html("t", QChar(0x3C4),"&tau;");
symbols["upsilon"]=GreekLetter_WinSymbol_Unicode_Html("u", QChar(0x3C5),"&upsilon;");
symbols["phi"]=GreekLetter_WinSymbol_Unicode_Html("f", QChar(0x3D5),"&straightphi;");
symbols["varphi"]=GreekLetter_WinSymbol_Unicode_Html("j", QChar(0x3C6),"&phi;");
symbols["chi"]=GreekLetter_WinSymbol_Unicode_Html("c", QChar(0x3C7),"&chi;");
symbols["psi"]=GreekLetter_WinSymbol_Unicode_Html("y", QChar(0x3C8),"&psi;");
symbols["omega"]=GreekLetter_WinSymbol_Unicode_Html("w", QChar(0x3C9),"&omega;");
symbols["Gamma"]=GreekLetter_WinSymbol_Unicode_Html("G", QChar(0x3A9),"&Gamma;");
symbols["Delta"]=GreekLetter_WinSymbol_Unicode_Html("D", QChar(0x394),"&Delta;");
symbols["Theta"]=GreekLetter_WinSymbol_Unicode_Html("Q", QChar(0x398),"&Theta;");
symbols["Lambda"]=GreekLetter_WinSymbol_Unicode_Html("L", QChar(0x39B),"&Lambda;");
symbols["Omega"]=GreekLetter_WinSymbol_Unicode_Html("W", QChar(0x3A9),"&Omega;");
symbols["Xi"]=GreekLetter_WinSymbol_Unicode_Html("X", QChar(0x39E),"&Xi;");
symbols["Pi"]=GreekLetter_WinSymbol_Unicode_Html("P", QChar(0x3A0),"&Pi;");
symbols["Sigma"]=GreekLetter_WinSymbol_Unicode_Html("S", QChar(0x3A3),"&Sigma;");
symbols["Upsilon"]=GreekLetter_WinSymbol_Unicode_Html("U", QChar(0x3C6),"&Upsilon;");
symbols["Phi"]=GreekLetter_WinSymbol_Unicode_Html("F", QChar(0x3A6),"&Phi;");
symbols["Psi"]=GreekLetter_WinSymbol_Unicode_Html("Y", QChar(0x3A8),"&Psi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("alpha", "a", QChar(0x3B1), "&alpha;");
addGreekLetterVariants_WinSymbol_Unicode_Html("beta", "b", QChar(0x3B2), "&beta;");
addGreekLetterVariants_WinSymbol_Unicode_Html("gamma", "g", QChar(0x3B3), "&gamma;");
addGreekLetterVariants_WinSymbol_Unicode_Html("delta", "d", QChar(0x3B4), "&delta;");
addGreekLetterVariants_WinSymbol_Unicode_Html("epsilon", "e", QChar(0x3F5), "&varepsilon;");
addGreekLetterVariants_WinSymbol_Unicode_Html("varepsilon", "e", QChar(0x3B5), "&epsi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("zeta", "z", QChar(0x3B6),"&zeta;");
addGreekLetterVariants_WinSymbol_Unicode_Html("eta", "h", QChar(0x3B7),"&eta;");
addGreekLetterVariants_WinSymbol_Unicode_Html("theta", "q", QChar(0x3B8),"&theta;");
addGreekLetterVariants_WinSymbol_Unicode_Html("vartheta", "J", QChar(0x3D1),"&thetasym;");
addGreekLetterVariants_WinSymbol_Unicode_Html("iota", "i", QChar(0x3B9),"&iota;");
addGreekLetterVariants_WinSymbol_Unicode_Html("kappa", "k", QChar(0x3BA),"&kappa;");
addGreekLetterVariants_WinSymbol_Unicode_Html("lambda", "l", QChar(0x3BB),"&lambda;");
addGreekLetterVariants_WinSymbol_Unicode_Html("mu", "m", QChar(0x3BC),"&mu;");
addGreekLetterVariants_WinSymbol_Unicode_Html("nu", "n", QChar(0x3BD),"&nu;");
addGreekLetterVariants_WinSymbol_Unicode_Html("xi", "x", QChar(0x3BE),"&xi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("pi", "p", QChar(0x3C0),"&pi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("varpi", "v", QChar(0x3D6),"&piv;");
addGreekLetterVariants_WinSymbol_Unicode_Html("rho", "r", QChar(0x3C1),"&rho;");
addGreekLetterVariants_WinSymbol_Unicode_Html("varrho", "r", QChar(0x3F1),"&varrho;");
addGreekLetterVariants_WinSymbol_Unicode_Html("sigma", "s", QChar(0x3C3),"&sigma;");
addGreekLetterVariants_WinSymbol_Unicode_Html("varsigma", "V", QChar(0x3C2),"&varsigma;");
addGreekLetterVariants_WinSymbol_Unicode_Html("tau", "t", QChar(0x3C4),"&tau;");
addGreekLetterVariants_WinSymbol_Unicode_Html("upsilon", "u", QChar(0x3C5),"&upsilon;");
addGreekLetterVariants_WinSymbol_Unicode_Html("phi", "f", QChar(0x3D5),"&straightphi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("varphi", "j", QChar(0x3C6),"&phi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("chi", "c", QChar(0x3C7),"&chi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("psi", "y", QChar(0x3C8),"&psi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("omega", "w", QChar(0x3C9),"&omega;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Gamma", "G", QChar(0x3A9),"&Gamma;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Delta", "D", QChar(0x394),"&Delta;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Theta", "Q", QChar(0x398),"&Theta;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Lambda", "L", QChar(0x39B),"&Lambda;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Omega", "W", QChar(0x3A9),"&Omega;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Xi", "X", QChar(0x39E),"&Xi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Pi", "P", QChar(0x3A0),"&Pi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Sigma", "S", QChar(0x3A3),"&Sigma;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Upsilon", "U", QChar(0x3C6),"&Upsilon;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Phi", "F", QChar(0x3A6),"&Phi;");
addGreekLetterVariants_WinSymbol_Unicode_Html("Psi", "Y", QChar(0x3A8),"&Psi;");
@ -802,6 +895,20 @@ JKQTMathTextSymbolNode::SymbolFullProps::SymbolFullProps(JKQTMathTextEnvironment
this->props[enc2]=props2;
}
JKQTMathTextSymbolNode::SymbolProps JKQTMathTextSymbolNode::SymbolFullProps::getProps(JKQTMathTextFontEncoding key, const SymbolProps &defaultValue, JKQTMathTextFontEncoding *foundEncodingOut) const
{
if (props.contains(key)) {
if (foundEncodingOut) *foundEncodingOut=key;
return props[key];
}
if (key==MTFEUnicode && props.contains(MTFEStandard)) {
if (foundEncodingOut) *foundEncodingOut=MTFEStandard;
return props[MTFEStandard];
}
if (foundEncodingOut) *foundEncodingOut=key;
return defaultValue;
}
JKQTMathTextSymbolNode::SymbolFullProps &JKQTMathTextSymbolNode::SymbolFullProps::add(JKQTMathTextFontEncoding enc, const SymbolProps &_props)
{
props[enc]=_props;
@ -895,76 +1002,64 @@ JKQTMathTextSymbolNode::SymbolFullProps &JKQTMathTextSymbolNode::SymbolFullProps
QPair<QFont, JKQTMathTextSymbolNode::SymbolProps> JKQTMathTextSymbolNode::SymbolFullProps::getDrawingData(JKQTMathTextEnvironment currentEv, JKQTMathText* parent) const
{
//qDebug()<<" ---------------------";
SymbolProps outProps;
QFont outFont;
const JKQTMathTextFontEncoding currentEnc=currentEv.getFontEncoding(parent);
QFont currentFont=currentEv.getFont(parent);
currentFont.setStyleStrategy(QFont::NoFontMerging);
const QFontMetricsF currentFM(currentFont);
QFont fallbackGreekFont=parent->getFallbackFontGreek();
fallbackGreekFont.setStyleStrategy(QFont::NoFontMerging);
const QFontMetricsF fallbackGreekFM(fallbackGreekFont);
QFont fallbackSymbolsFont=parent->getFallbackFontSymbols();
const JKQTMathTextFontEncoding fallbackSymbolsFontEnc=parent->getFontEncodingFallbackFontSymbols();
fallbackSymbolsFont.setStyleStrategy(QFont::NoFontMerging);
const QFontMetricsF fallbackSymbolsFM(fallbackSymbolsFont);
const QChar chFallbackSym=props.value(fallbackSymbolsFontEnc, SymbolProps()).getSymbolSingleChar();
if (fontType==MTEFallbackGreek) {
if (currentEnc!=MTFEStandard && props.contains(currentEnc)) {
outProps=props[currentEnc];
const QChar ch=props[currentEnc].getSymbolSingleChar();
if (!ch.isNull() && !currentFM.inFont(ch)) {
currentEv.font=MTEFallbackGreek;
outProps=props.value(currentEv.getFontEncoding(parent), outProps);
}
} else if (currentEnc==MTFEStandard && props.contains(currentEnc)){
outProps=props[currentEnc];
const QChar ch=props[currentEnc].getSymbolSingleChar();
if (!ch.isNull() && fallbackGreekFM.inFont(ch)) {
currentEv.font=MTEFallbackGreek;
outProps=props.value(currentEv.getFontEncoding(parent), outProps);
}
} else {
currentEv.font=MTEFallbackGreek;
}
if (fontType==MTECustomFont) {
//qDebug()<<" ==>1 fontType==MTECustomFont";
currentEv.customFontName=customFontFamily;
currentEv.font=MTECustomFont;
outProps=getProps(MTFEUnicode, outProps);
} else if (fontType==MTEFallbackSymbols) {
if (currentEnc!=MTFEStandard && props.contains(currentEnc)) {
outProps=props[currentEnc];
const QChar ch=props[currentEnc].getSymbolSingleChar();
if (!ch.isNull() && !currentFM.inFont(ch)) {
currentEv.font=MTEFallbackGreek;
outProps=props.value(currentEv.getFontEncoding(parent), outProps);
}
} else if (currentEnc==MTFEStandard && props.contains(currentEnc)){
outProps=props[currentEnc];
const QChar ch=props[currentEnc].getSymbolSingleChar();
if (!ch.isNull() && fallbackSymbolsFM.inFont(ch)) {
currentEv.font=MTEFallbackSymbols;
outProps=props.value(currentEv.getFontEncoding(parent), outProps);
}
//qDebug()<<" ==>2 fontType==MTEFallbackSymbols";
if (!chFallbackSym.isNull() && fallbackSymbolsFM.inFont(chFallbackSym)) {
//qDebug()<<" ==>2.1 !chFallbackSym.isNull() && fallbackSymbolsFM.inFont(chFallbackSym)";
currentEv.font=MTEFallbackSymbols;
outProps=getProps(fallbackSymbolsFontEnc, outProps);
} else {
currentEv.font=MTEFallbackGreek;
//qDebug()<<" ==>2.2 else";
outProps=getProps(currentEnc, outProps);
}
} else if (fontType!=MTEEnvironmentFontCount) {
if (fontType!=MTECurrentFont) {
currentEv.font=fontType;
}
if (fontType==MTECustomFont) {
currentEv.customFontName=customFontFamily;
outProps=props.value(MTFEStandard, outProps);
} else {
QFont lcurrentFont=currentEv.getFont(parent);
lcurrentFont.setStyleStrategy(QFont::NoFontMerging);
const QFontMetricsF lcurrentFM(lcurrentFont);
auto lcurrentEnc=currentEv.getFontEncoding(parent);
outProps=props.value(lcurrentEnc, props.value(MTFEStandard, outProps));
const QChar ch=outProps.getSymbolSingleChar();
if (!ch.isNull() && !lcurrentFM.inFont(ch) && fallbackSymbolsFM.inFont(ch)) {
} else if (fontType==MTECurrentFont) {
//qDebug()<<" ==>2 fontType==MTECurrentFont";
JKQTMathTextFontEncoding localEnc=currentEnc;
outProps=getProps(currentEnc, outProps, &localEnc);
const QChar ch=outProps.getSymbolSingleChar();
if (!ch.isNull() && !currentFM.inFont(ch)) {
//qDebug()<<" ==>2.1 ch="<<ch<<" !ch.isNull() && !currentFM.inFont(ch)";
if (!chFallbackSym.isNull() && fallbackSymbolsFM.inFont(chFallbackSym)) {
//qDebug()<<" ==>2.1.1 !chFallbackSym.isNull() && fallbackSymbolsFM.inFont(chFallbackSym)";
outProps=props[fallbackSymbolsFontEnc];
currentEv.font=MTEFallbackSymbols;
outProps=props.value(currentEv.getFontEncoding(parent), outProps);
}
}
if (props.contains(currentEv.getFontEncoding(parent))) outProps=props[currentEv.getFontEncoding(parent)];
} else {
//qDebug()<<" ==>3 else";
currentEv.font=fontType;
outProps=getProps(currentEv.getFontEncoding(parent), outProps);
QFont localFont=currentEv.getFont(parent);
localFont.setStyleStrategy(QFont::NoFontMerging);
const QFontMetricsF localFM(localFont);
const QChar chLocal=outProps.getSymbolSingleChar();
if (!chLocal.isNull() && !localFM.inFont(chLocal) && fallbackSymbolsFM.inFont(chFallbackSym)) {
//qDebug()<<" ==>3.1 !chLocal.isNull() && !localFM.inFont(chLocal) && fallbackSymbolsFM.inFont(chFallbackSym)";
currentEv.font=MTEFallbackSymbols;
outProps=getProps(fallbackSymbolsFontEnc, outProps);
}
}
outFont=currentEv.getFont(parent);
if (outProps.fontScalingFactor!=1) outFont.setPointSizeF(outFont.pointSizeF()*outProps.fontScalingFactor);
if (has(outProps.flags, ItalicOn)) outFont.setItalic(true);

View File

@ -57,7 +57,7 @@ class JKQTMathText; // forward
*/
class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
public:
explicit JKQTMathTextSymbolNode(JKQTMathText* parent, const QString& name, bool addWhitespace);
explicit JKQTMathTextSymbolNode(JKQTMathText* parent, const QString& name);
virtual ~JKQTMathTextSymbolNode() override;
/** \copydoc JKQTMathTextNode::getTypeName() */
virtual QString getTypeName() const override;
@ -67,8 +67,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) override;
/** \copydoc symbolName */
QString getSymbolName() const;
/** \copydoc addWhitespace */
bool getAddWhitespace() const;
/** \brief determine the size of the node, calls getSizeInternal() implementation of the actual type \see getSizeInternal()
*
* \param painter painter to use for determining the size
@ -94,8 +92,6 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
/** \brief this string will be sent to the drawText method with properly set fonts */
QString symbolName;
/** \brief add a whitespace to the symbol? */
bool addWhitespace;
/** \brief flags specifying additional symbol features */
enum SymbolFlags: uint64_t {
@ -104,12 +100,15 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
ItalicOff= 1 << 1, /*!< \brief make font non-italic (i.e. upright) in any case */
BoldOn= 1 << 2, /*!< \brief make font bold in any case */
BoldOff= 1 << 3, /*!< \brief make font non-bold (i,,e, normal weight) in any case */
DrawBar= 1 << 4, /*!< \brief indicates whether to draw a bar (like for \c \\hbar ) */
FlipUpDown=1 << 5, /*!< \brief indicates to flip the given symbol upside-down */
FlipLeftRight=1 << 6, /*!< \brief indicates to flip the given symbol left-right */
Rotate90=1 << 7, /*!< \brief indicates to rotate the symbol 90 degree */
DrawSlash=1 << 8, /*!< \brief indicates to overdraw a backslash (e.g. to combine 0 and / to form \\varnothing ) */
HeightIsAscent= 1 << 9, /*!< \brief if true, the height of the symbol equals the ascent of the font */
DrawLeftHBar= 1 << 4, /*!< \brief indicates whether to draw a bar on the left half of the character, above the xHeight (like for \c \\hbar ), implements an italic-correction */
DrawRightHBar= 1 << 5, /*!< \brief indicates whether to draw a bar on the right half of the character, above the xHeight, implements an italic-correction */
FlipSymbolUpDown=1 << 6, /*!< \brief indicates to flip the given symbol upside-down */
FlipSymbolLeftRight=1 << 7, /*!< \brief indicates to flip the given symbol left-right */
RotateSymbol90=1 << 8, /*!< \brief indicates to rotate the symbol 90 degree */
DrawSlash=1 << 9, /*!< \brief indicates to overdraw a slash (e.g. to combine 0 and / to form \\varnothing ) */
DrawBackSlash=1 << 10, /*!< \brief indicates to overdraw a backslash */
DrawVertLine=1 << 11, /*!< \brief indicates to overdraw a centered vertical line (slightly tilted if italic) */
HeightIsAscent= 1 << 12, /*!< \brief if true, the height of the symbol equals the ascent of the font */
Upright=ItalicOff,
NormalWeight=BoldOff,
};
@ -145,13 +144,17 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
/** \brief calculates the tight bounding rect of \a text using \a fm and taking the flags from \a globalFlags into account */
static QRectF getTightBoundingRect(const QFontMetricsF& fm, const QString& text, GlobalSymbolFlags globalFlags);
/** \brief draw \a text at (0,0) using QPainter \a p and taking the flags from \a globalFlags into account */
static void drawText(QPainter &p, const QString &text, GlobalSymbolFlags globalFlags);
static void drawText(QPainter &p, const QString &text, GlobalSymbolFlags globalFlags, SymbolFlags symflags);
/** \brief properties of the symbol */
struct SymbolProps {
SymbolProps();
/** \brief this constructor sets the given properties and sets html=symbol! replaces whitespaces in \a _ymbol with \c &thinsp; for html, iff MakeWhitespaceHalf is set in \a _flags*/
SymbolProps(const QString& _symbol, SymbolFlags _flags=AsOutside, double _fontScalingFactor=1.0, double _yShiftFactor=0.0);
SymbolProps(SymbolProps&& other)=default;
SymbolProps(const SymbolProps& other)=default;
SymbolProps& operator=(SymbolProps&& other)=default;
SymbolProps& operator=(const SymbolProps& other)=default;
/** \brief the symbol or text used to render the symbol (i.e. not the name,
* e.g. if the instruction/symbol name \c \\int is used, this would be \c QChar(0xF2) ,
* for \c \\sin it would be \c QString("sin") ...) */
@ -173,6 +176,10 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
struct SymbolFullProps {
/** \brief default constructor */
SymbolFullProps();
SymbolFullProps(SymbolFullProps&& other)=default;
SymbolFullProps(const SymbolFullProps& other)=default;
SymbolFullProps& operator=(SymbolFullProps&& other)=default;
SymbolFullProps& operator=(const SymbolFullProps& other)=default;
/** \brief typesets the symbol (described in \a props ) from the specified \a font, \a props is stored with encoding MTFEStandard, an optional HTML-string \A _html can be given */
SymbolFullProps(const QString& font, const SymbolProps& props, const QString& _html=QString(), SymbolFlags _htmlflags=AsOutside, double _htmlfontScalingFactor=1.0, double _htmlyShiftFactor=0.0);
/** \brief typesets the \a symbol from the specified \a font, \a props is stored with encoding MTFEStandard, an optional HTML-string \A _html can be given */
@ -205,6 +212,8 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
SymbolProps html;
/** \brief specifies global symbol flags */
GlobalSymbolFlags globalFlags;
/** \brief accesses entries in props for a given \a key. This also looks for fallback options (e.g. MTFEStandard when MTFEUnicode is not available). Returns \a defaultValue when nothing is found */
SymbolProps getProps(JKQTMathTextFontEncoding key, const SymbolProps& defaultValue=SymbolProps(), JKQTMathTextFontEncoding* foundEncodingOut=nullptr) const;
SymbolFullProps &add(JKQTMathTextFontEncoding enc, const SymbolProps& props);
SymbolFullProps& addWinSymbol(const QString& _symbol, SymbolFlags _flags=AsOutside, double _fontScalingFactor=1.0, double _yShiftFactor=0.0);
@ -227,7 +236,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
};
/** \brief creates a SymbolFullProps object for a symbol that can be typeset in any font, for SymbolFullProps::html the same text as a\a symbol is used */
static SymbolFullProps SimpleTextSymbol(const QString& symbol);
static SymbolFullProps SimpleTextSymbol(const QString& symbol, SymbolFlags _flags=AsOutside, double _fontScalingFactor=1.0, double _yShiftFactor=0.0);
/** \brief creates a SymbolFullProps object for a symbol that can be typeset in any font, a special html-string is given */
static SymbolFullProps SimpleTextSymbol(const QString& symbol, const QString& html);
/** \brief creates a SymbolFullProps object for a symbol that can be typeset in any font, for SymbolFullProps::html the same text as a\a symbol is used */
@ -242,12 +251,20 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
static SymbolFullProps MathOperatorText(const QString& op);
/** \brief constructs a SymbolProps with explicit HTML for a math-operator like \c \\sin ..., i.e. ItalicOff, BoldOff, HeightIsAscent, ExtendWidthInMathmode */
static SymbolFullProps MathOperatorText(const QString& op, const QString& ophtml);
/** \brief constructs a SymbolProps for greek letter with the symbol in unicode-encoding \a letterUnicode and in WinSymbol-encoding letterWinWsymbol */
/** \brief constructs a SymbolProps for a greek letter with the symbol in unicode-encoding \a letterUnicode and in WinSymbol-encoding letterWinWsymbol */
static SymbolFullProps GreekLetter_WinSymbol_Unicode_Html(const QString& letterWinSymbol, const QString& letterUnicode, const QString& html);
/** \brief constructs a SymbolProps for an upright greek letter with the symbol in unicode-encoding \a letterUnicode and in WinSymbol-encoding letterWinWsymbol */
static SymbolFullProps UprightGreekLetter_WinSymbol_Unicode_Html(const QString& letterWinSymbol, const QString& letterUnicode, const QString& html);
/** \brief insert GreekLetter_WinSymbol_Unicode_Html() as \a baseInstructionName and UprightGreekLetter_WinSymbol_Unicode_Html and "up"+\a letterWinSymbol into symbols */
static void addGreekLetterVariants_WinSymbol_Unicode_Html(const QString& baseInstructionName, const QString& letterWinSymbol, const QString& letterUnicode, const QString& html);
/** \brief constructs a SymbolProps for a symbol with encoding in Standard-fonts a */
static SymbolFullProps SymbolStd(const QString& symbol, const QString& html=QString());
static SymbolFullProps SymbolStd(const QString& symbol, const QString& html);
/** \brief constructs a SymbolProps for a symbol with encoding in UnicodeFull-fonts a */
static SymbolFullProps SymbolUnicode(const QString& symbol, const QString& html=QString());
static SymbolFullProps SymbolUnicode(const QString& symbol, const QString& html);
/** \brief constructs a SymbolProps for a symbol with encoding in Standard-fonts a */
static SymbolFullProps SymbolStd(const QString& symbol, SymbolFlags _flags=AsOutside, double _fontScalingFactor=1.0, double _yShiftFactor=0.0);
/** \brief constructs a SymbolProps for a symbol with encoding in UnicodeFull-fonts a */
static SymbolFullProps SymbolUnicode(const QString& symbol, SymbolFlags _flags=AsOutside, double _fontScalingFactor=1.0, double _yShiftFactor=0.0);
/** \brief constructs a SymbolProps for a symbol with encoding in Standard-fonts a */
static SymbolFullProps UprightSymbolStd(const QString& symbol, const QString& html=QString());
/** \brief constructs a SymbolProps for a symbol with encoding in UnicodeFull-fonts a */
@ -255,6 +272,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
/** \brief constructs a SymbolProps for a math-operator symbol like \c \\pm ... in unicode-full-encoding, i.e. ItalicOff, BoldOff, ExtendWidthInMathmode */
static SymbolFullProps MathOperatorSymbolUnicode(const QString& unicode);
/** \brief symbols that can be generated in any standard-font */
static QHash<QString, SymbolFullProps> symbols;