improvements to JKQtMathText when rendering non-XITS unicode fonts

This commit is contained in:
jkriege2 2019-03-06 23:18:29 +01:00
parent 6f703ad2c4
commit 14d4857670
4 changed files with 237 additions and 176 deletions

View File

@ -39,8 +39,17 @@ TestForm::TestForm(QWidget *parent) :
ui->cmbTestset->addItem("arrowtest 2", "$\\nwarrow \\nearrow \\searrow \\swarrow \\mapsto \\leftharpoonup \\rightharpoonup \\upharpoonleft \\downharpoonleft \\leftrightharpoon \\rightleftharpoon \\leftharpoondown \\rightharpoondown \\upharpoonright \\downharpoonright $"); ui->cmbTestset->addItem("arrowtest 2", "$\\nwarrow \\nearrow \\searrow \\swarrow \\mapsto \\leftharpoonup \\rightharpoonup \\upharpoonleft \\downharpoonleft \\leftrightharpoon \\rightleftharpoon \\leftharpoondown \\rightharpoondown \\upharpoonright \\downharpoonright $");
ui->cmbTestset->addItem("math: blackboard", "$\\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("math: blackboard", "$\\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$");
ui->cmbTestset->addItem("math: bf", "$\\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("math: bf", "$\\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$");
ui->cmbTestset->addItem("math: it", "$\\mathit{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$");
ui->cmbTestset->addItem("math: sf", "$\\mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$");
ui->cmbTestset->addItem("math: rm", "$\\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("math: rm", "$\\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$");
ui->cmbTestset->addItem("math: cal", "$\\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$"); ui->cmbTestset->addItem("math: cal", "$\\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$");
ui->cmbTestset->addItem("math: tt", "$\\mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}$");
ui->cmbTestset->addItem("bf", "\\textbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}");
ui->cmbTestset->addItem("it", "\\textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}");
ui->cmbTestset->addItem("sf", "\\textsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}");
ui->cmbTestset->addItem("rm", "\\textrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}");
ui->cmbTestset->addItem("cal", "\\textcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}");
ui->cmbTestset->addItem("tt", "\\texttt{ABCDEFGHIJKLMNOPQRSTUVWXYZ120}");
ui->cmbTestset->addItem("subscript test", "$r_{123}\\ \\ r_{\\frac{1}{2}}$"); ui->cmbTestset->addItem("subscript test", "$r_{123}\\ \\ r_{\\frac{1}{2}}$");
ui->cmbTestset->addItem("subscript0 test", "$r_{123}$"); ui->cmbTestset->addItem("subscript0 test", "$r_{123}$");
ui->cmbTestset->addItem("subscript1 test", "$r_{123}\\ $"); ui->cmbTestset->addItem("subscript1 test", "$r_{123}\\ $");
@ -254,7 +263,7 @@ QTreeWidgetItem *TestForm::createTree(JKQTMathText::MTnode *node, QTreeWidgetIte
ti->addChild(createTree(list[i], ti)); ti->addChild(createTree(list[i], ti));
} }
} else if (symN) { } else if (symN) {
name=QString("MTsymbolNode: \'%1\'").arg(symN->getSymbolName()); name=QString("MTsymbolNode: \'%1\' (%2)").arg(symN->getSymbolName()).arg(symN->getSymbolFontName());
} else if (spN) { } else if (spN) {
name=QString("MTwhitespaceNode :\'%1\'").arg(txtN->getText()); name=QString("MTwhitespaceNode :\'%1\'").arg(txtN->getText());
} else if (txtN) { } else if (txtN) {
@ -322,19 +331,20 @@ void TestForm::updateMath()
ht.start(); ht.start();
mt.setFontRoman(ui->cmbUnicodeSerif->currentFont().family()); mt.setFontRoman(ui->cmbUnicodeSerif->currentFont().family());
mt.setFontMathRoman(ui->cmbUnicodeSerif->currentFont().family());
mt.setFontSans(ui->cmbUnicodeSans->currentFont().family()); mt.setFontSans(ui->cmbUnicodeSans->currentFont().family());
mt.setFontMathSans(ui->cmbUnicodeSans->currentFont().family());
mt.setFontTypewriter(ui->cmbUnicodeFixed->currentFont().family()); mt.setFontTypewriter(ui->cmbUnicodeFixed->currentFont().family());
mt.setFontSymbol(ui->cmbUnicodeSymbol->currentFont().family()); mt.setFontSymbol(ui->cmbUnicodeSymbol->currentFont().family());
mt.setFontCaligraphic(ui->cmbCaligraphic->currentFont().family());
switch (ui->cmbFont->currentIndex()) { switch (ui->cmbFont->currentIndex()) {
case 1: mt.useXITS(); break; case 1: mt.useXITS(); break;
case 2: mt.useSTIX(); break; case 2: mt.useSTIX(); break;
case 3: mt.useAnyUnicode(ui->cmbUnicodeSans->currentFont().family(),ui->cmbUnicodeSerif->currentFont().family()); break; case 3: mt.useAnyUnicode(ui->cmbUnicodeSerif->currentFont().family(),ui->cmbUnicodeSans->currentFont().family(), false); break;
case 4: mt.useLatexFonts(ui->edtLatexPrefix->text(), ui->edtLatexPostfix->text()); break; case 4: mt.useAnyUnicode(ui->cmbUnicodeSerif->currentFont().family(),ui->cmbUnicodeSans->currentFont().family(), true); break;
case 5: mt.useASANA(); break; case 5: mt.useLatexFonts(ui->edtLatexPrefix->text(), ui->edtLatexPostfix->text()); break;
case 6: mt.useASANA(); break;
} }

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1238</width> <width>1518</width>
<height>742</height> <height>742</height>
</rect> </rect>
</property> </property>
@ -24,7 +24,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>605</width> <width>745</width>
<height>616</height> <height>616</height>
</rect> </rect>
</property> </property>
@ -104,7 +104,12 @@
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Unicode</string> <string>Unicode, limited</string>
</property>
</item>
<item>
<property name="text">
<string>Unicode, full</string>
</property> </property>
</item> </item>
<item> <item>
@ -290,7 +295,7 @@
<item> <item>
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>Symbol/Unicode fonts:</string> <string>Symbol/Unicode fonts: rm:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -303,6 +308,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>sf:</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QFontComboBox" name="cmbUnicodeSans"> <widget class="QFontComboBox" name="cmbUnicodeSans">
<property name="currentFont"> <property name="currentFont">
@ -312,6 +324,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>tt:</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QFontComboBox" name="cmbUnicodeFixed"> <widget class="QFontComboBox" name="cmbUnicodeFixed">
<property name="currentFont"> <property name="currentFont">
@ -321,6 +340,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="label_16">
<property name="text">
<string>cal:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="cmbCaligraphic">
<property name="currentFont">
<font>
<family>Script</family>
</font>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="text"> <property name="text">

View File

@ -139,14 +139,12 @@ QFont JKQTMathText::MTenvironment::getFont(JKQTMathText* parent) const {
QFont f; QFont f;
switch (font) { switch (font) {
case MTEsans: case MTEsans:
if (insideMath) f.setFamily(parent->getFontMathSans()); f.setFamily(parent->getFontSans());
else f.setFamily(parent->getFontSans());
break; break;
case MTEtypewriter: f.setFamily(parent->getFontTypewriter()); break; case MTEtypewriter: f.setFamily(parent->getFontTypewriter()); break;
case MTEscript: f.setFamily(parent->getFontScript()); break; case MTEscript: f.setFamily(parent->getFontScript()); break;
case MTEroman: case MTEroman:
if (insideMath) f.setFamily(parent->getFontMathRoman()); f.setFamily(parent->getFontRoman());
else f.setFamily(parent->getFontRoman());
break; break;
case MTEcaligraphic: f.setFamily(parent->getFontCaligraphic()); break; case MTEcaligraphic: f.setFamily(parent->getFontCaligraphic()); break;
case MTEblackboard: f.setFamily(parent->getFontBlackboard()); break; case MTEblackboard: f.setFamily(parent->getFontBlackboard()); break;
@ -386,7 +384,7 @@ QString JKQTMathText::MTtextNode::getTypeName() const
QString JKQTMathText::MTtextNode::textTransform(const QString &text, JKQTMathText::MTenvironment currentEv, bool /*forSize*/) QString JKQTMathText::MTtextNode::textTransform(const QString &text, JKQTMathText::MTenvironment currentEv, bool /*forSize*/)
{ {
QString txt=text; QString txt=text;
if (parent->getFontEncoding()==MTFEunicode) { if (parent->getFontEncoding()==MTFEunicode || parent->getFontEncoding()==MTFEunicodeLimited) {
if (currentEv.insideMath) { if (currentEv.insideMath) {
txt=""; txt="";
for (int i=0; i<text.size(); i++) { for (int i=0; i<text.size(); i++) {
@ -421,32 +419,6 @@ QString JKQTMathText::MTtextNode::textTransform(const QString &text, JKQTMathTex
case 'e': txt+=QChar(0x2147); break; case 'e': txt+=QChar(0x2147); break;
case 'i': txt+=QChar(0x2148); break; case 'i': txt+=QChar(0x2148); break;
case 'j': txt+=QChar(0x2149); break; case 'j': txt+=QChar(0x2149); break;
default: txt+=c; break;
}
}
}
if (currentEv.font==MTEcaligraphic && parent->getFontEncoding()==MTFEunicode) {
txt="";
for (int i=0; i<text.size(); i++) {
QChar c=text[i];
switch(c.unicode()) {
case 'I': txt+=QChar(0x2110); break;
case 'g': txt+=QChar(0x210A); break;
case 'H': txt+=QChar(0x210B); break;
case 'L': txt+=QChar(0x2112); break;
case 'l': txt+=QChar(0x2113); break;
case 'p': txt+=QChar(0x2118); break;
case 'R': txt+=QChar(0x211B); break;
case 'B': txt+=QChar(0x212C); break;
case 'e': txt+=QChar(0x212F); break;
case 'E': txt+=QChar(0x2130); break;
case 'F': txt+=QChar(0x2131); break;
case 'M': txt+=QChar(0x2133); break;
case 'o': txt+=QChar(0x2134); break;
default: txt+=c; break; default: txt+=c; break;
} }
@ -614,14 +586,14 @@ double JKQTMathText::MTsubscriptNode::draw(QPainter& painter, double x, double y
double shift=parent->getSubShiftFactor()*tbr.height(); double shift=parent->getSubShiftFactor()*tbr.height();
if (prevNodeSize!=nullptr && prevNodeSize->overallHeight-prevNodeSize->baselineHeight>shift) { if (prevNodeSize!=nullptr && prevNodeSize->overallHeight-prevNodeSize->baselineHeight>shift) {
qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight; //qDebug()<<"oldshift="<<shift<<", prevNodeSize->overallHeight="<<prevNodeSize->overallHeight<<", prevNodeSize->baselineHeight="<<prevNodeSize->baselineHeight;
shift=-1.0*(prevNodeSize->overallHeight-prevNodeSize->baselineHeight-shift); shift=-1.0*(prevNodeSize->overallHeight-prevNodeSize->baselineHeight-shift);
qDebug()<<"newshift="<<shift; //qDebug()<<"newshift="<<shift;
} }
double yshift=baselineHeight-shift; double yshift=baselineHeight-shift;
qDebug()<<"baselineHeight="<<baselineHeight<<", overallHeight="<<overallHeight<<", strikeoutPos="<<strikeoutPos; //qDebug()<<"baselineHeight="<<baselineHeight<<", overallHeight="<<overallHeight<<", strikeoutPos="<<strikeoutPos;
qDebug()<<"shift="<<shift<<", yshift="<<yshift; //qDebug()<<"shift="<<shift<<", yshift="<<yshift;
double xx=x; double xx=x;
if (currentEv.italic && prevNodeSize==nullptr) xx=xx-double(fm.width(' '))*parent->getItalicCorrectionFactor(); if (currentEv.italic && prevNodeSize==nullptr) xx=xx-double(fm.width(' '))*parent->getItalicCorrectionFactor();
return child->draw(painter, xx, y+yshift, ev);//+0.5*fm.boundingRect("A").width(); return child->draw(painter, xx, y+yshift, ev);//+0.5*fm.boundingRect("A").width();
@ -2264,15 +2236,9 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na
unicodeSymbol.insert("Uparrow", QChar(0x21D1)); unicodeSymbol.insert("Uparrow", QChar(0x21D1));
unicodeSymbol.insert("Downarrow", QChar(0x21D3)); unicodeSymbol.insert("Downarrow", QChar(0x21D3));
unicodeSymbol.insert("Updownarrow", QChar(0x21D5)); unicodeSymbol.insert("Updownarrow", QChar(0x21D5));
unicodeSymbol.insert("pm", QChar(0x00B1));
unicodeSymbol.insert("mp", QChar(0x2213)); unicodeSymbol.insert("mp", QChar(0x2213));
unicodeSymbol.insert("leq", QChar(0x2264));
unicodeSymbol.insert("geq", QChar(0x2265));
unicodeSymbol.insert("ll", QChar(0x226A)); unicodeSymbol.insert("ll", QChar(0x226A));
unicodeSymbol.insert("gg", QChar(0x226B)); unicodeSymbol.insert("gg", QChar(0x226B));
unicodeSymbol.insert("hbar", QChar(0x210F));
unicodeSymbol.insert("euro", QChar(0x20AC));
unicodeSymbol.insert("Angstrom", QChar(0x212B));
unicodeSymbol.insert("Alef", QChar(0x2135)); unicodeSymbol.insert("Alef", QChar(0x2135));
unicodeSymbol.insert("Bet", QChar(0x2136)); unicodeSymbol.insert("Bet", QChar(0x2136));
unicodeSymbol.insert("Gimel", QChar(0x2137)); unicodeSymbol.insert("Gimel", QChar(0x2137));
@ -2284,7 +2250,6 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na
unicodeSymbol.insert("nexists", QChar(0x2204)); unicodeSymbol.insert("nexists", QChar(0x2204));
unicodeSymbol.insert("ni", QChar(0x220B)); unicodeSymbol.insert("ni", QChar(0x220B));
unicodeSymbol.insert("notni", QChar(0x220C)); unicodeSymbol.insert("notni", QChar(0x220C));
unicodeSymbol.insert("circ", QChar(0x2218));
unicodeSymbol.insert("tilde", QChar(0x223C)); unicodeSymbol.insert("tilde", QChar(0x223C));
unicodeSymbol.insert("emptyset", QChar(0x2300)); unicodeSymbol.insert("emptyset", QChar(0x2300));
unicodeSymbol.insert("varnothing", QChar(0x2300)); unicodeSymbol.insert("varnothing", QChar(0x2300));
@ -2298,12 +2263,9 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na
unicodeSymbol.insert("DC", QChar(0x2393)); unicodeSymbol.insert("DC", QChar(0x2393));
unicodeSymbol.insert("bot", QChar(0x22A4)); unicodeSymbol.insert("bot", QChar(0x22A4));
unicodeSymbol.insert("mid", QChar(0xFF5C)); unicodeSymbol.insert("mid", QChar(0xFF5C));
unicodeSymbol.insert("cdots", QString(QChar(0x00B7)) + QString(QChar(0x00B7)) + QString(QChar(0x00B7)));
unicodeSymbol.insert("vdots", QChar(0x22EE)); unicodeSymbol.insert("vdots", QChar(0x22EE));
unicodeSymbol.insert("iddots", QChar(0x22F0)); unicodeSymbol.insert("iddots", QChar(0x22F0));
unicodeSymbol.insert("ddots", QChar(0x22F1)); unicodeSymbol.insert("ddots", QChar(0x22F1));
unicodeSymbol.insert("dots", "...");
unicodeSymbol.insert("ldots", "...");
unicodeSymbol.insert("perthousand", QChar(0x2030)); unicodeSymbol.insert("perthousand", QChar(0x2030));
unicodeSymbol.insert("leftharpoonup", QChar(0x21BC)); unicodeSymbol.insert("leftharpoonup", QChar(0x21BC));
unicodeSymbol.insert("rightharpoonup", QChar(0x21C0)); unicodeSymbol.insert("rightharpoonup", QChar(0x21C0));
@ -2320,22 +2282,14 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na
unicodeSymbol.insert("searrow", QChar(0x2198)); unicodeSymbol.insert("searrow", QChar(0x2198));
unicodeSymbol.insert("swarrow", QChar(0x2199)); unicodeSymbol.insert("swarrow", QChar(0x2199));
unicodeSymbol.insert("mapsto", QChar(0x21A6)); unicodeSymbol.insert("mapsto", QChar(0x21A6));
unicodeSymbol.insert("cent", QChar(0x00A2));
unicodeSymbol.insert("pound", QChar(0x00A3));
unicodeSymbol.insert("yen", QChar(0x00A5));
unicodeSymbol.insert("div", QChar(0x00F7)); unicodeSymbol.insert("div", QChar(0x00F7));
unicodeSymbol.insert("multimap", QChar(0x22B8)); unicodeSymbol.insert("multimap", QChar(0x22B8));
unicodeSymbol.insert("maporiginal", QChar(0x22B6)); unicodeSymbol.insert("maporiginal", QChar(0x22B6));
unicodeSymbol.insert("mapimage", QChar(0x22B7)); unicodeSymbol.insert("mapimage", QChar(0x22B7));
unicodeSymbol.insert("benzene", QChar(0x232C)); unicodeSymbol.insert("benzene", QChar(0x232C));
unicodeSymbol.insert("times", QChar(0x2A2F));
unicodeSymbol.insert("propto", QChar(0x221D)); unicodeSymbol.insert("propto", QChar(0x221D));
unicodeSymbol.insert("partial", QChar(0x2202));
unicodeSymbol.insert("bullet", QChar(0x2219));
unicodeSymbol.insert("neq", QChar(0x2260));
unicodeSymbol.insert("ne", QChar(0x2260)); unicodeSymbol.insert("ne", QChar(0x2260));
unicodeSymbol.insert("equiv", QChar(0x2261)); unicodeSymbol.insert("equiv", QChar(0x2261));
unicodeSymbol.insert("approx", QChar(0x2245));
unicodeSymbol.insert("ellipsis", QChar(0x2026)); unicodeSymbol.insert("ellipsis", QChar(0x2026));
unicodeSymbol.insert("Im", QChar(0x2111)); unicodeSymbol.insert("Im", QChar(0x2111));
unicodeSymbol.insert("Re", QChar(0x211C)); unicodeSymbol.insert("Re", QChar(0x211C));
@ -2355,17 +2309,11 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na
unicodeSymbol.insert("notin", QChar(0x2209)); unicodeSymbol.insert("notin", QChar(0x2209));
unicodeSymbol.insert("angle", QChar(0x2221)); unicodeSymbol.insert("angle", QChar(0x2221));
unicodeSymbol.insert("nabla", QChar(0x2207)); unicodeSymbol.insert("nabla", QChar(0x2207));
unicodeSymbol.insert("copyright", QChar(0x00A9));
unicodeSymbol.insert("registered", QChar(0x00AE));
unicodeSymbol.insert("trademark", QChar(0x2122));
unicodeSymbol.insert("cdot", QChar(0x00B7));
unicodeSymbol.insert("neg", QChar(0x00AC)); unicodeSymbol.insert("neg", QChar(0x00AC));
unicodeSymbol.insert("wedge", QChar(0x2227)); unicodeSymbol.insert("wedge", QChar(0x2227));
unicodeSymbol.insert("vee", QChar(0x2228)); unicodeSymbol.insert("vee", QChar(0x2228));
unicodeSymbol.insert("diamond", QChar(0xE0));
unicodeSymbol.insert("langle", QChar(0x2329)); unicodeSymbol.insert("langle", QChar(0x2329));
unicodeSymbol.insert("rangle", QChar(0x232A)); unicodeSymbol.insert("rangle", QChar(0x232A));
unicodeSymbol.insert("infty", QChar(0x221E));
unicodeSymbol.insert("forall", QChar(0x2200)); unicodeSymbol.insert("forall", QChar(0x2200));
unicodeSymbol.insert("exists", QChar(0x2203)); unicodeSymbol.insert("exists", QChar(0x2203));
unicodeSymbol.insert("cong", QChar(0x2245)); unicodeSymbol.insert("cong", QChar(0x2245));
@ -2373,6 +2321,36 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na
} }
static QHash<QString, QString> 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("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));
}
static QHash<QString, QString> latexSimpleSymbol; static QHash<QString, QString> latexSimpleSymbol;
if (latexSimpleSymbol.isEmpty()) { if (latexSimpleSymbol.isEmpty()) {
latexSimpleSymbol.insert("_", "_"); latexSimpleSymbol.insert("_", "_");
@ -2590,8 +2568,7 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na
//else if (n=="") { symbol=QChar(); font=MTSFdefault; } //else if (n=="") { symbol=QChar(); font=MTSFdefault; }
//else if (n=="") symbol=QChar(0x); //else if (n=="") symbol=QChar(0x);
} }
} } else if (parent->getFontEncoding() == MTFEunicode) { // use UNICODE encoding for special characters
else if (parent->getFontEncoding() == MTFEunicode) { // use UNICODE encoding for special characters
// first we start with greek characters // first we start with greek characters
font = MTSFdefault; //MTSFgreek; font = MTSFdefault; //MTSFgreek;
//std::cout<<"encoding unicode\n"; //std::cout<<"encoding unicode\n";
@ -2602,9 +2579,13 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na
// now we set the symbols from the Symbol font // now we set the symbols from the Symbol font
font = MTSFsymbol; font = MTSFsymbol;
QHash<QString, QString>::iterator itsymbol = unicodeSymbol.find(n); QHash<QString, QString>::iterator itsymbol = unicodeSymbol.find(n);
if (itsymbol!=unicodeSymbol.end()) { QHash<QString, QString>::iterator itbasesymbol = unicodeBaseSymbol.find(n);
if (itbasesymbol!=unicodeBaseSymbol.end()) {
symbol = itbasesymbol.value();
} else if (itsymbol!=unicodeSymbol.end()) {
symbol = itsymbol.value(); symbol = itsymbol.value();
} if (n == "sum") { symbol = QChar(0x2211); heightIsAscent = true; exactAscent = true; } }
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 == "prod") { symbol = QChar(0x220F); heightIsAscent = true; exactAscent = true; }
else if (n == "bbC") { symbol = QChar(0x2102); italic = -1; } else if (n == "bbC") { symbol = QChar(0x2102); italic = -1; }
else if (n == "bbH") { symbol = QChar(0x210D); italic = -1; } else if (n == "bbH") { symbol = QChar(0x210D); italic = -1; }
@ -2613,17 +2594,17 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na
else if (n == "bbQ") { symbol = QChar(0x211A); italic = -1; } else if (n == "bbQ") { symbol = QChar(0x211A); italic = -1; }
else if (n == "bbR") { symbol = QChar(0x211D); italic = -1; } else if (n == "bbR") { symbol = QChar(0x211D); italic = -1; }
else if (n == "bbZ") { symbol = QChar(0x2124); 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 == "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 == "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 == "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 == "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 == "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 == "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 == "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 == "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 == "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 == "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 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 else { // here are text mode symbols, i.e. bold and italic won't be touched
bold = -1; bold = -1;
@ -2651,8 +2632,79 @@ JKQTMathText::MTsymbolNode::MTsymbolNode(JKQTMathText* parent, const QString& na
//else if (n=="") { symbol=QChar(); font=MTSFdefault; } //else if (n=="") { symbol=QChar(); font=MTSFdefault; }
//else if (n=="") symbol=QChar(0x); //else if (n=="") symbol=QChar(0x);
} }
} } else if (parent->getFontEncoding() == MTFEunicodeLimited) { // use UNICODE encoding for special characters
else if (parent->getFontEncoding() == MTFElatex) { // use UNICODE encoding for special characters
// now we set the symbols from the Symbol font
font = MTSFdefault;
QHash<QString, QString>::iterator itsymbol = unicodeBaseSymbol.find(n);
if (itsymbol!=unicodeBaseSymbol.end()) {
symbol = itsymbol.value();
//qDebug()<<"unicodeBaseSymbol: "<<symbol<<font;
} else {
font = MTSFsymbol;
italic = -1;
QHash<QString, QString>::iterator itgreek = winSymbolGreek.find(n);
if (itgreek!=winSymbolGreek.end()) {
symbol = itgreek.value();
//qDebug()<<"winSymbolGreek: "<<symbol<<font;
} 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<QString, QString>::iterator itsymbol = winSymbolSymbol.find(n);
if (itsymbol!=winSymbolSymbol.end()) {
symbol = itsymbol.value();
//qDebug()<<"winSymbolSymbol: "<<symbol<<font;
} 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;
//qDebug()<<"else: "<<symbol<<font;
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; }
}
}
}
} else if (parent->getFontEncoding() == MTFElatex) { // use UNICODE encoding for special characters
// first we start with greek characters // first we start with greek characters
font = MTSFdefault; //MTSFgreek; font = MTSFdefault; //MTSFgreek;
//std::cout<<"encoding unicode\n"; //std::cout<<"encoding unicode\n";
@ -2719,7 +2771,7 @@ QString JKQTMathText::MTsymbolNode::getTypeName() const
return QLatin1String("MTsymbolNode(")+symbolName+QLatin1String(")"); return QLatin1String("MTsymbolNode(")+symbolName+QLatin1String(")");
} }
QFont JKQTMathText::MTsymbolNode::getFontName(symbolFont f, QFont& fi) { QFont JKQTMathText::MTsymbolNode::getFontName(symbolFont f, QFont& fi) const {
QFont fr=fi; QFont fr=fi;
switch(f) { switch(f) {
case MTSFgreek: fr.setFamily(parent->getFontGreek()); break; case MTSFgreek: fr.setFamily(parent->getFontGreek()); break;
@ -3116,6 +3168,21 @@ bool JKQTMathText::MTsymbolNode::toHtml(QString &html, JKQTMathText::MTenvironme
return ok; return ok;
} }
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()+"]";
}
}
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
// -- implementation of the JKQTMathText methods // -- implementation of the JKQTMathText methods
@ -3133,7 +3200,7 @@ JKQTMathText::JKQTMathText(QObject* parent):
QString typewriterFont="typewriter"; QString typewriterFont="typewriter";
QString decorativeFont="decorative"; QString decorativeFont="decorative";
QStringList fonts=fontdb.families(); QStringList fonts=fontdb.families();
//qDebug()<<"fonts:\n"<<fonts; //qDebug()<<"fonts:\n"<<fonts;
if (fonts.contains("Times New Roman")) { if (fonts.contains("Times New Roman")) {
@ -3176,10 +3243,8 @@ JKQTMathText::JKQTMathText(QObject* parent):
default_fontSymbol=fontSymbol=symbolFont; default_fontSymbol=fontSymbol=symbolFont;
default_fontCaligraphic=fontCaligraphic=decorativeFont; default_fontCaligraphic=fontCaligraphic=decorativeFont;
default_fontBlackboard=fontBlackboard=serifFont; default_fontBlackboard=fontBlackboard=serifFont;
default_fontMathRoman=fontMathRoman=serifFont; default_fontBraces=fontBraces=fontRoman;
default_fontMathSans=fontMathSans=sansFont; default_fontIntegrals=fontIntegrals=fontRoman;
default_fontBraces=fontBraces=fontMathRoman;
default_fontIntegrals=fontIntegrals=fontMathRoman;
default_fontEncoding=fontEncoding=MTFEwinSymbol; default_fontEncoding=fontEncoding=MTFEwinSymbol;
default_fontLatexPostfix=fontLatexPostfix="10"; default_fontLatexPostfix=fontLatexPostfix="10";
default_fontLatexPrefix=fontLatexPrefix="jlm_"; default_fontLatexPrefix=fontLatexPrefix="jlm_";
@ -3231,8 +3296,6 @@ void JKQTMathText::loadSettings(const QSettings& settings, const QString& group)
fontScript=settings.value(group+"font_script", fontScript).toString(); fontScript=settings.value(group+"font_script", fontScript).toString();
fontGreek=settings.value(group+"font_greek", fontGreek).toString(); fontGreek=settings.value(group+"font_greek", fontGreek).toString();
fontSymbol=settings.value(group+"font_symbol", fontSymbol).toString(); fontSymbol=settings.value(group+"font_symbol", fontSymbol).toString();
fontMathRoman=settings.value(group+"font_math_roman", fontRoman).toString();
fontMathSans=settings.value(group+"font_math_sans", fontSans).toString();
fontBraces=settings.value(group+"font_braces", fontRoman).toString(); fontBraces=settings.value(group+"font_braces", fontRoman).toString();
fontIntegrals=settings.value(group+"font_integrals", fontSans).toString(); fontIntegrals=settings.value(group+"font_integrals", fontSans).toString();
fontBlackboard=settings.value(group+"font_blackboard", fontSans).toString(); fontBlackboard=settings.value(group+"font_blackboard", fontSans).toString();
@ -3274,8 +3337,6 @@ void JKQTMathText::saveSettings(QSettings& settings, const QString& group) const
JKQTMTPROPERTYsave(settings, group, fontScript, "font_script"); JKQTMTPROPERTYsave(settings, group, fontScript, "font_script");
JKQTMTPROPERTYsave(settings, group, fontGreek, "font_greek"); JKQTMTPROPERTYsave(settings, group, fontGreek, "font_greek");
JKQTMTPROPERTYsave(settings, group, fontSymbol, "font_symbol"); JKQTMTPROPERTYsave(settings, group, fontSymbol, "font_symbol");
JKQTMTPROPERTYsave(settings, group, fontMathRoman, "font_math_roman");
JKQTMTPROPERTYsave(settings, group, fontMathSans, "font_math_sans");
JKQTMTPROPERTYsave(settings, group, fontBraces, "font_braces"); JKQTMTPROPERTYsave(settings, group, fontBraces, "font_braces");
JKQTMTPROPERTYsave(settings, group, fontIntegrals, "font_integrals"); JKQTMTPROPERTYsave(settings, group, fontIntegrals, "font_integrals");
JKQTMTPROPERTYsave(settings, group, fontBlackboard, "font_blackboard"); JKQTMTPROPERTYsave(settings, group, fontBlackboard, "font_blackboard");
@ -3327,7 +3388,6 @@ void JKQTMathText::useSTIX() {
fontBraces=fontname; fontBraces=fontname;
fontIntegrals=fontname; fontIntegrals=fontname;
fontRoman=fontnametxt; fontRoman=fontnametxt;
fontMathRoman=fontname;
fontEncoding=MTFEunicode; fontEncoding=MTFEunicode;
brace_shrink_factor=0.6; brace_shrink_factor=0.6;
} }
@ -3378,10 +3438,8 @@ void JKQTMathText::useXITS()
if (hasXITS) fam=defaultXITSFontName; if (hasXITS) fam=defaultXITSFontName;
//if (hasXITSMath) fam=defaultXITSMathFontName; //if (hasXITSMath) fam=defaultXITSMathFontName;
useXITSfonts=true; useXITSfonts=true;
//fontRoman=fam; fontRoman=fam;
//fontSans=fam; //fontSans=fam;
fontMathRoman=fam;
fontMathSans=fam;
//fontTypewriter=fam; //fontTypewriter=fam;
fontBlackboard=fam; fontBlackboard=fam;
//fontCaligraphic=fam; //fontCaligraphic=fam;
@ -3421,10 +3479,8 @@ void JKQTMathText::useASANA()
QString fam="Asana Math"; QString fam="Asana Math";
if (hasXITS) fam=XITSfam; if (hasXITS) fam=XITSfam;
useXITSfonts=true; useXITSfonts=true;
//fontRoman=fam; fontRoman=fam;
//fontSans=fam; //fontSans=fam;
fontMathRoman=fam;
fontMathSans=fam;
fontTypewriter=fam; fontTypewriter=fam;
fontBlackboard=fam; fontBlackboard=fam;
fontCaligraphic=fam; fontCaligraphic=fam;
@ -3441,8 +3497,6 @@ void JKQTMathText::useLatexFonts(QString prefix, const QString& postfix) {
fontLatexPrefix=prefix; fontLatexPrefix=prefix;
fontRoman=prefix+"cmr"+postfix; fontRoman=prefix+"cmr"+postfix;
fontSans=prefix+"cmss"+postfix; fontSans=prefix+"cmss"+postfix;
fontMathRoman=prefix+"cmr"+postfix;
fontMathSans=prefix+"cmss"+postfix;
fontTypewriter=prefix+"cmtt"+postfix; fontTypewriter=prefix+"cmtt"+postfix;
fontBlackboard=prefix+"dsrom"+postfix; fontBlackboard=prefix+"dsrom"+postfix;
fontCaligraphic=prefix+"csmy"+postfix; fontCaligraphic=prefix+"csmy"+postfix;
@ -3495,33 +3549,22 @@ void JKQTMathText::setFontRomanOrSpecial(const QString &__value)
} }
} }
void JKQTMathText::setFontRomanOrSpecial(const QString &roman, const QString &math)
{
if (math.toUpper()=="XITS") {
useXITS();
} else if (math.toUpper()=="STIX") {
useSTIX();
} else if (math.toUpper()=="ASANA") {
useASANA();
} else {
setFontMathRoman(math);
}
setFontRoman(roman); void JKQTMathText::useAnyUnicode(QString timesFont, const QString& sansFont, bool fullMathUnicodeFont) {
if (!timesFont.isEmpty()) { fontRoman=timesFont; }
} if (!sansFont.isEmpty()) { fontSans=sansFont; }
void JKQTMathText::useAnyUnicode(QString timesFont, const QString& sansFont) {
if (!timesFont.isEmpty()) { fontMathRoman=timesFont; fontRoman=timesFont; }
if (!sansFont.isEmpty()) { fontMathSans=sansFont; fontSans=sansFont; }
useSTIXfonts=false; useSTIXfonts=false;
useXITSfonts=false; useXITSfonts=false;
useASANAfonts=false; useASANAfonts=false;
fontGreek=fontMathRoman; if (fullMathUnicodeFont) {
fontSymbol=fontMathRoman; fontGreek=fontRoman;
fontBraces=fontMathRoman; fontSymbol=fontRoman;
fontIntegrals=fontMathRoman; fontIntegrals=fontRoman;
fontEncoding=MTFEunicode; fontEncoding=MTFEunicode;
} else {
fontEncoding=MTFEunicodeLimited;
}
fontBraces=fontRoman;
brace_shrink_factor=0.6; brace_shrink_factor=0.6;
} }
@ -4274,7 +4317,7 @@ void JKQTMathTextLabel::internalPaint()
repaintDo=false; repaintDo=false;
//qDebug()<<"internalPaint(): parse "<<m_mathText->parse(lastText)<<"\n "<<m_mathText->getErrorList().join("\n")<<"\n\n"; //qDebug()<<"internalPaint(): parse "<<m_mathText->parse(lastText)<<"\n "<<m_mathText->getErrorList().join("\n")<<"\n\n";
if (!m_mathText->parse(lastText)) { if (!m_mathText->parse(lastText)) {
qDebug()<<"JKQTMathTextLabel::internalPaint(): parse '"<<lastText<<"': "<<m_mathText->parse(lastText)<<"\n "<<m_mathText->getErrorList().join("\n")<<"\n\n"; //qDebug()<<"JKQTMathTextLabel::internalPaint(): parse '"<<lastText<<"': "<<m_mathText->parse(lastText)<<"\n "<<m_mathText->getErrorList().join("\n")<<"\n\n";
} }
if (buffer.width()<=0 || buffer.height()<=0) buffer=QPixmap(1000,100); if (buffer.width()<=0 || buffer.height()<=0) buffer=QPixmap(1000,100);

View File

@ -180,8 +180,8 @@ JKQTP_LIB_EXPORT void initJKQTMathTextResources();
\section JKQTMathTextSuppoertedFonts Font Handling \section JKQTMathTextSuppoertedFonts Font Handling
Several fonts are defined as properties to the class: Several fonts are defined as properties to the class:
- A "roman" font used as the standard font ( setFontRoman() in math-mode setFontMathRoman() ) - A "roman" font used as the standard font ( setFontRoman() )
- A "sans-serif" font which may be activated with \c \\sf ... ( setFontSans() in math-mode setFontMathSans() ) - A "sans-serif" font which may be activated with \c \\sf ... ( setFontSans() )
- A "typewriter" font which may be activated with \c \\tt ... ( setFontTypewriter() ) - A "typewriter" font which may be activated with \c \\tt ... ( setFontTypewriter() )
- A "script" font which may be activated with \c \\script ... ( setFontScript() ) - 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 greek font which is used to display greek letters \c \\alpha ... ( setFontGreek() )
@ -282,8 +282,11 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject {
* <code>setAnyUnicode("Arial", "Arial")</code>:<br>\image html jkqtmathparser_arial.png * <code>setAnyUnicode("Arial", "Arial")</code>:<br>\image html jkqtmathparser_arial.png
* <code>setAnyUnicode("Courier New", "Courier New")</code>:<br>\image html jkqtmathparser_couriernew.png * <code>setAnyUnicode("Courier New", "Courier New")</code>:<br>\image html jkqtmathparser_couriernew.png
* <code>setAnyUnicode("Comic Sans MS", "Comic Sans MS")</code>:<br>\image html jkqtmathparser_comicsans.png * <code>setAnyUnicode("Comic Sans MS", "Comic Sans MS")</code>:<br>\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("")); void useAnyUnicode(QString timesFont=QString(""), const QString& sansFont=QString(""), bool fullMathUnicodeFont=false);
void useLatexFonts(QString prefix=QString(""), const QString& postfix=QString("")); void useLatexFonts(QString prefix=QString(""), const QString& postfix=QString(""));
@ -296,11 +299,14 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject {
- \c MTFElatex: This assumes that symbols shal be taken from the CM (computer modern) fonts, used by LaTeX - \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 - \c MTFEunicode: This assumes that symbols shall be taken from a Unicode font
(e.g. the STIX fonts from <a href="http://www.stixfonts.org/">http://www.stixfonts.org/</a>) (e.g. the STIX fonts from <a href="http://www.stixfonts.org/">http://www.stixfonts.org/</a>)
- \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 { enum MTfontEncoding {
MTFEwinSymbol, MTFEwinSymbol,
MTFEunicode, MTFEunicode,
MTFEunicodeLimited,
MTFElatex MTFElatex
}; };
@ -335,10 +341,6 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject {
\see fontRoman for more information */ \see fontRoman for more information */
void setFontRomanOrSpecial(const QString & __value); void setFontRomanOrSpecial(const QString & __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 & roman, const QString & math);
/*! \copydoc fontRoman \see fontRoman */ /*! \copydoc fontRoman \see fontRoman */
inline QString getFontRoman() const inline QString getFontRoman() const
{ {
@ -434,26 +436,6 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject {
{ {
return this->fontBlackboard; return this->fontBlackboard;
} }
/*! \copydoc fontMathRoman \see fontMathRoman */
inline void setFontMathRoman(const QString & __value)
{
this->fontMathRoman = __value;
}
/*! \copydoc fontMathRoman \see fontMathRoman */
inline QString getFontMathRoman() const
{
return this->fontMathRoman;
}
/*! \copydoc fontMathSans \see fontMathSans */
inline void setFontMathSans(const QString & __value)
{
this->fontMathSans = __value;
}
/*! \copydoc fontMathSans \see fontMathSans */
inline QString getFontMathSans() const
{
return this->fontMathSans;
}
/*! \copydoc fontLatexPrefix \see fontLatexPrefix */ /*! \copydoc fontLatexPrefix \see fontLatexPrefix */
inline void setFontLatexPrefix(const QString & __value) inline void setFontLatexPrefix(const QString & __value)
{ {
@ -862,6 +844,7 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject {
inline QString getSymbolName() const { inline QString getSymbolName() const {
return this->symbolName; return this->symbolName;
} }
QString getSymbolFontName() const;
protected: protected:
/** \copydoc MTnode::getSizeInternal() */ /** \copydoc MTnode::getSizeInternal() */
virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const MTnodeSize* prevNodeSize=nullptr) override; virtual void getSizeInternal(QPainter& painter, MTenvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, const MTnodeSize* prevNodeSize=nullptr) override;
@ -872,7 +855,7 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject {
/** \brief these fonts may be used for symbols */ /** \brief these fonts may be used for symbols */
enum symbolFont { MTSFdefault, MTSFsymbol, MTSFgreek, MTSFbraces, MTSFintegrals, MTSFcaligraphic, MTSFblackboard }; enum symbolFont { MTSFdefault, MTSFsymbol, MTSFgreek, MTSFbraces, MTSFintegrals, MTSFcaligraphic, MTSFblackboard };
/** \brief changes the font name according to a given symbolFont value */ /** \brief changes the font name according to a given symbolFont value */
QFont getFontName(symbolFont f, QFont& fi); QFont getFontName(symbolFont f, QFont& fi) const;
/** \brief magnification factor for the font size */ /** \brief magnification factor for the font size */
symbolFont font; symbolFont font;
/** \brief magnification factor for the font size */ /** \brief magnification factor for the font size */
@ -1279,16 +1262,6 @@ class JKQTP_LIB_EXPORT JKQTMathText : public QObject {
/*! \brief default value for property fontBlackboard. /*! \brief default value for property fontBlackboard.
\see fontBlackboard for more information */ \see fontBlackboard for more information */
QString default_fontBlackboard; QString default_fontBlackboard;
/** \brief roman font for math environment */
QString fontMathRoman;
/*! \brief default value for property fontMathRoman.
\see fontMathRoman for more information */
QString default_fontMathRoman;
/** \brief sans font for math environment */
QString fontMathSans;
/*! \brief default value for property fontMathSans.
\see fontMathSans for more information */
QString default_fontMathSans;
/** \brief prefix for LaTeX fonts */ /** \brief prefix for LaTeX fonts */
QString fontLatexPrefix; QString fontLatexPrefix;
/*! \brief default value for property fontLatexPrefix. /*! \brief default value for property fontLatexPrefix.