mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 01:51:49 +08:00
JKQTMathText: added instruction \\utfeight{HEX}
This commit is contained in:
parent
2ec3d12507
commit
e469dbb9ae
@ -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 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 \\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>
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 3.0 KiB |
@ -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}");
|
||||
|
@ -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 <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
|
||||
<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
|
||||
|
@ -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<uint16_t>(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<char>(code&0xFF));
|
||||
code=code>>8;
|
||||
}
|
||||
return QString::fromUtf8(bytes);
|
||||
}
|
||||
return QChar(0);
|
||||
}, 1);
|
||||
instructions["utfeight"]= i;
|
||||
}
|
||||
}
|
||||
|
||||
QString JKQTMathTextSimpleInstructionNode::executeInstruction() const
|
||||
|
Loading…
Reference in New Issue
Block a user