diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox
index 06131a38bb..3e52467834 100644
--- a/doc/dox/whatsnew.dox
+++ b/doc/dox/whatsnew.dox
@@ -67,7 +67,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
NEW: added \c \\acute{X}, \c \\grave{X}, \c \\acute{X}
NEW: added functions to set the font-size in pixels (as alternative to the existing functions that set them in points), implements request #76 from user:igormironchik
NEW: added \c \\userfont{SystemFontName}{Text} instruction
- NEW: added \c \\unicode{HEX} instruction to draw unicide characters by code
+ NEW: added \c \\unicode{HEX} and \c \\utfeight{HEX} instruction to draw unicide characters by code
diff --git a/doc/images/jkqtmathtext/jkqtmathtext_unicode.png b/doc/images/jkqtmathtext/jkqtmathtext_unicode.png
index fe4cb185a0..5a8ecef507 100644
Binary files a/doc/images/jkqtmathtext/jkqtmathtext_unicode.png and b/doc/images/jkqtmathtext/jkqtmathtext_unicode.png differ
diff --git a/examples/jkqtmathtext_test/testform.cpp b/examples/jkqtmathtext_test/testform.cpp
index f860d83ccf..7280cc7fe5 100644
--- a/examples/jkqtmathtext_test/testform.cpp
+++ b/examples/jkqtmathtext_test/testform.cpp
@@ -67,7 +67,7 @@ TestForm::TestForm(QWidget *parent) :
ui->cmbTestset->addItem("text (bold)", "text \\mathbf{bold}");
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("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}"; };
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}");
diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h
index 41b5cc7e58..550ce704dc 100644
--- a/lib/jkqtmathtext/jkqtmathtext.h
+++ b/lib/jkqtmathtext/jkqtmathtext.h
@@ -133,7 +133,7 @@ class JKQTMathTextNode; // forward
- \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 \\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 star: \\unicode{2605}, circonflex: \\unicode{109}
)
+ - \c \\unicode{HEX} and \\utfeight{HEX} : draws a unicode character \image html jkqtmathtext/jkqtmathtext_unicode.png (generated by star: \\unicode{2605}, circonflex: \\unicode{109} emoticons on UTF-8: \\utfeight{F09F9881} \\utfeight{f09f98bb}
)
- \c ^{...} \c _{...} : display the contents of braces in superscript/subscript \image html jkqtmathtext/jkqtmathtext_supersub.png
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
diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp
index 1e25d5f2b6..9b28a9f623 100644
--- a/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp
+++ b/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp
@@ -90,7 +90,6 @@ double JKQTMathTextSimpleInstructionNode::draw(QPainter &painter, double x, doub
painter.setFont(f);
painter.drawText(x,y,txt);
-
return x+bb.width();
}
@@ -134,7 +133,7 @@ void JKQTMathTextSimpleInstructionNode::getSizeInternal(QPainter &painter, JKQTM
const QString txt=executeInstruction();
const QRectF bb=fm.boundingRect(txt);
width=bb.width();
- baselineHeight=bb.height()+bb.y();
+ baselineHeight=-bb.y();
overallHeight=bb.height();
strikeoutPos=fm.strikeOutPos();
}
@@ -146,18 +145,30 @@ void JKQTMathTextSimpleInstructionNode::fillInstructions()
{
InstructionProperties i([](const QStringList& parameters) -> QString {
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);
- if (ok&&(code<=0xFFFF)) return QChar(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);
- }
+ if (ok&&(code<=0xFFFF)) return QChar(static_cast(code));
return QChar(0);
}, 1);
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(code&0xFF));
+ code=code>>8;
+ }
+ return QString::fromUtf8(bytes);
+ }
+ return QChar(0);
+ }, 1);
+ instructions["utfeight"]= i;
+ }
}
QString JKQTMathTextSimpleInstructionNode::executeInstruction() const