JKQTMathText: added instruction \\utfeight{HEX}

This commit is contained in:
jkriege2 2022-07-25 23:29:32 +02:00
parent 2ec3d12507
commit e469dbb9ae
5 changed files with 23 additions and 12 deletions

View File

@ -67,7 +67,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
<li>NEW: added \c \\acute{X}, \c \\grave{X}, \c \\acute{X}</li> <li>NEW: added \c \\acute{X}, \c \\grave{X}, \c \\acute{X}</li>
<li>NEW: added functions to set the font-size in pixels (as alternative to the existing functions that set them in points), implements request <a href="https://github.com/jkriege2/JKQtPlotter/issues/76">#76</a> from <a href="https://github.com/igormironchik">user:igormironchik</a> </li> <li>NEW: added functions to set the font-size in pixels (as alternative to the existing functions that set them in points), implements request <a href="https://github.com/jkriege2/JKQtPlotter/issues/76">#76</a> from <a href="https://github.com/igormironchik">user:igormironchik</a> </li>
<li>NEW: added \c \\userfont{SystemFontName}{Text} instruction</li> <li>NEW: added \c \\userfont{SystemFontName}{Text} instruction</li>
<li>NEW: added \c \\unicode{HEX} instruction to draw unicide characters by code</li> <li>NEW: added \c \\unicode{HEX} and \c \\utfeight{HEX} instruction to draw unicide characters by code</li>
</ul></li> </ul></li>
</ul> </ul>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -67,7 +67,7 @@ TestForm::TestForm(QWidget *parent) :
ui->cmbTestset->addItem("text (bold)", "text \\mathbf{bold}"); ui->cmbTestset->addItem("text (bold)", "text \\mathbf{bold}");
ui->cmbTestset->addItem("textcolor", "text \\mathbf{bold}\\textcolor{red}{RED}"); ui->cmbTestset->addItem("textcolor", "text \\mathbf{bold}\\textcolor{red}{RED}");
ui->cmbTestset->addItem("userfont", "text, \\userfont{Arial}{Arial}, \\userfont{Comic Sans MS}{Comic Sans MS}"); ui->cmbTestset->addItem("userfont", "text, \\userfont{Arial}{Arial}, \\userfont{Comic Sans MS}{Comic Sans MS}");
ui->cmbTestset->addItem("unicode", "star: \\unicode{2605}, circonflex: \\unicode{109}"); ui->cmbTestset->addItem("unicode", "star: \\unicode{2605}, circonflex: \\unicode{109} emoticons on UTF-8: \\utfeight{F09F9881} \\utfeight{f09f98bb}");
const auto mathDecoExample=[](const QString& deco)->QString { return "\\"+deco+"{x}\\"+deco+"{i}\\"+deco+"{X}\\"+deco+"{\\psi}\\"+deco+"{abc}"; }; const auto mathDecoExample=[](const QString& deco)->QString { return "\\"+deco+"{x}\\"+deco+"{i}\\"+deco+"{X}\\"+deco+"{\\psi}\\"+deco+"{abc}"; };
ui->cmbTestset->addItem("decoration: math", "$"+mathDecoExample("vec")+" -- "+mathDecoExample("grave")+" -- "+mathDecoExample("acute")+" -- "+mathDecoExample("dot")+" -- "+mathDecoExample("ddot")+" -- "+mathDecoExample("ocirc")+" -- "+mathDecoExample("overline")+" -- "+mathDecoExample("underline")+" -- "+mathDecoExample("hat")+" -- "+mathDecoExample("widehat")+" -- "+mathDecoExample("check")+" -- "+mathDecoExample("widecheck")+" -- "+mathDecoExample("breve")+" -- "+mathDecoExample("tilde")+" -- "+mathDecoExample("widetilde")+" -- "+mathDecoExample("uul")+" -- "+mathDecoExample("ool")+" -- "+mathDecoExample("bar")+" -- "+mathDecoExample("arrow")+" -- "+mathDecoExample("cancel")+" -- "+mathDecoExample("bcancel")+" -- "+mathDecoExample("xcancel")+" -- "+mathDecoExample("sout")+"$"); ui->cmbTestset->addItem("decoration: math", "$"+mathDecoExample("vec")+" -- "+mathDecoExample("grave")+" -- "+mathDecoExample("acute")+" -- "+mathDecoExample("dot")+" -- "+mathDecoExample("ddot")+" -- "+mathDecoExample("ocirc")+" -- "+mathDecoExample("overline")+" -- "+mathDecoExample("underline")+" -- "+mathDecoExample("hat")+" -- "+mathDecoExample("widehat")+" -- "+mathDecoExample("check")+" -- "+mathDecoExample("widecheck")+" -- "+mathDecoExample("breve")+" -- "+mathDecoExample("tilde")+" -- "+mathDecoExample("widetilde")+" -- "+mathDecoExample("uul")+" -- "+mathDecoExample("ool")+" -- "+mathDecoExample("bar")+" -- "+mathDecoExample("arrow")+" -- "+mathDecoExample("cancel")+" -- "+mathDecoExample("bcancel")+" -- "+mathDecoExample("xcancel")+" -- "+mathDecoExample("sout")+"$");
ui->cmbTestset->addItem("decoration: text", "Text \\ul{underlined Text Equator} -- \\ol{overlined Text Equator} -- \\sout{striked out Text Equator} -- \\cancel{canceled out Text Equator} -- \\bcancel{b-canceled out Text Equator} -- \\xcancel{x-canceled out Text Equator}"); ui->cmbTestset->addItem("decoration: text", "Text \\ul{underlined Text Equator} -- \\ol{overlined Text Equator} -- \\sout{striked out Text Equator} -- \\cancel{canceled out Text Equator} -- \\bcancel{b-canceled out Text Equator} -- \\xcancel{x-canceled out Text Equator}");

View File

@ -133,7 +133,7 @@ class JKQTMathTextNode; // forward
- \c \\fcolorbox{bordercolor}{backgroundcolor}{...} : draw a colored, filled box \image html jkqtmathtext/jkqtmathtext_fcolorbox.png - \c \\fcolorbox{bordercolor}{backgroundcolor}{...} : draw a colored, filled box \image html jkqtmathtext/jkqtmathtext_fcolorbox.png
- \c \\colorbox{color}{...} : draw a colored box around text \image html jkqtmathtext/jkqtmathtext_colorbox.png - \c \\colorbox{color}{...} : draw a colored box around text \image html jkqtmathtext/jkqtmathtext_colorbox.png
- \c \\alpha ... : display the according greek letter \image html jkqtmathtext/jkqtmathtext_greek.png - \c \\alpha ... : display the according greek letter \image html jkqtmathtext/jkqtmathtext_greek.png
- \c \\unicode{HEX} : draws a unicode character \image html jkqtmathtext/jkqtmathtext_unicode.png (generated by <code>star: \\unicode{2605}, circonflex: \\unicode{109}</code>) - \c \\unicode{HEX} and \\utfeight{HEX} : draws a unicode character \image html jkqtmathtext/jkqtmathtext_unicode.png (generated by <code>star: \\unicode{2605}, circonflex: \\unicode{109} emoticons on UTF-8: \\utfeight{F09F9881} \\utfeight{f09f98bb}</code>)
- \c ^{...} \c _{...} : display the contents of braces in superscript/subscript \image html jkqtmathtext/jkqtmathtext_supersub.png - \c ^{...} \c _{...} : display the contents of braces in superscript/subscript \image html jkqtmathtext/jkqtmathtext_supersub.png
<br>Special subscript/superscript typesetting applies, when the sub/super follows \c \\sum \c \\Prod ...: \image html jkqtmathtext/jkqtmathtext_specialsubsuper.png <br>Special subscript/superscript typesetting applies, when the sub/super follows \c \\sum \c \\Prod ...: \image html jkqtmathtext/jkqtmathtext_specialsubsuper.png
- \c \\{ / \\} : display opening/closing brace - \c \\{ / \\} : display opening/closing brace

View File

@ -90,7 +90,6 @@ double JKQTMathTextSimpleInstructionNode::draw(QPainter &painter, double x, doub
painter.setFont(f); painter.setFont(f);
painter.drawText(x,y,txt); painter.drawText(x,y,txt);
return x+bb.width(); return x+bb.width();
} }
@ -134,7 +133,7 @@ void JKQTMathTextSimpleInstructionNode::getSizeInternal(QPainter &painter, JKQTM
const QString txt=executeInstruction(); const QString txt=executeInstruction();
const QRectF bb=fm.boundingRect(txt); const QRectF bb=fm.boundingRect(txt);
width=bb.width(); width=bb.width();
baselineHeight=bb.height()+bb.y(); baselineHeight=-bb.y();
overallHeight=bb.height(); overallHeight=bb.height();
strikeoutPos=fm.strikeOutPos(); strikeoutPos=fm.strikeOutPos();
} }
@ -146,18 +145,30 @@ void JKQTMathTextSimpleInstructionNode::fillInstructions()
{ {
InstructionProperties i([](const QStringList& parameters) -> QString { InstructionProperties i([](const QStringList& parameters) -> QString {
bool ok=false; bool ok=false;
const int code=parameters.value(0, "0").toInt(&ok, 16); qlonglong code=parameters.value(0, "0").toLongLong(&ok, 16);
ok=ok&&(code>=0); ok=ok&&(code>=0);
if (ok&&(code<=0xFFFF)) return QChar(code); if (ok&&(code<=0xFFFF)) return QChar(static_cast<uint16_t>(code));
else if (ok&&(code>0xFFFF && code<0xFFFFFFFF)) {
const char16_t unicodeSmile[] = { char16_t((code&0xFFFF0000)>>16), char16_t(code&0xFFFF), 0 };
return QString::fromUtf16(unicodeSmile);
}
return QChar(0); return QChar(0);
}, 1); }, 1);
instructions["unicode"]= i; instructions["unicode"]= i;
} }
{
InstructionProperties i([](const QStringList& parameters) -> QString {
bool ok=false;
qlonglong code=parameters.value(0, "0").toLongLong(&ok, 16);
ok=ok&&(code>=0);
if (ok) {
QByteArray bytes;
while (code!=0) {
bytes.prepend(static_cast<char>(code&0xFF));
code=code>>8;
}
return QString::fromUtf8(bytes);
}
return QChar(0);
}, 1);
instructions["utfeight"]= i;
}
} }
QString JKQTMathTextSimpleInstructionNode::executeInstruction() const QString JKQTMathTextSimpleInstructionNode::executeInstruction() const