mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-11-15 18:15:52 +08:00
JKQTMathText: \\unicode{} now always accepts a codepoint and \utfeight{} a UTF8-seuqnece
This commit is contained in:
parent
e469dbb9ae
commit
edd7784d47
Binary file not shown.
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
doc/images/jkqtmathtext/jkqtmathtext_utf8.png
Normal file
BIN
doc/images/jkqtmathtext/jkqtmathtext_utf8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
@ -67,7 +67,8 @@ 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} emoticons on UTF-8: \\utfeight{F09F9881} \\utfeight{f09f98bb}");
|
ui->cmbTestset->addItem("unicode", "star: \\unicode{2605}, circonflex: \\unicode{109} emoticons: \\usym{1F440} \\usym{1F929}");
|
||||||
|
ui->cmbTestset->addItem("UTF8", "star: \\utfeight{e29885} emoticons \\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}");
|
||||||
|
@ -837,3 +837,30 @@ Qt::MouseButton jkqtp_String2MouseButton(const QString &button)
|
|||||||
if (but=="EXTRA24") return Qt::ExtraButton24;
|
if (but=="EXTRA24") return Qt::ExtraButton24;
|
||||||
return Qt::NoButton;
|
return Qt::NoButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string jkqtp_UnicodeToUTF8(uint32_t codepoint)
|
||||||
|
{
|
||||||
|
std::string out;
|
||||||
|
|
||||||
|
if (codepoint <= 0x7f)
|
||||||
|
out.append(1, static_cast<char>(codepoint));
|
||||||
|
else if (codepoint <= 0x7ff)
|
||||||
|
{
|
||||||
|
out.append(1, static_cast<char>(0xc0 | ((codepoint >> 6) & 0x1f)));
|
||||||
|
out.append(1, static_cast<char>(0x80 | (codepoint & 0x3f)));
|
||||||
|
}
|
||||||
|
else if (codepoint <= 0xffff)
|
||||||
|
{
|
||||||
|
out.append(1, static_cast<char>(0xe0 | ((codepoint >> 12) & 0x0f)));
|
||||||
|
out.append(1, static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
|
||||||
|
out.append(1, static_cast<char>(0x80 | (codepoint & 0x3f)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out.append(1, static_cast<char>(0xf0 | ((codepoint >> 18) & 0x07)));
|
||||||
|
out.append(1, static_cast<char>(0x80 | ((codepoint >> 12) & 0x3f)));
|
||||||
|
out.append(1, static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
|
||||||
|
out.append(1, static_cast<char>(0x80 | (codepoint & 0x3f)));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
@ -48,6 +48,12 @@ JKQTCOMMON_LIB_EXPORT QString jkqtp_QBrushStyle2String(Qt::BrushStyle style);
|
|||||||
JKQTCOMMON_LIB_EXPORT Qt::BrushStyle jkqtp_String2QBrushStyle(const QString& style);
|
JKQTCOMMON_LIB_EXPORT Qt::BrushStyle jkqtp_String2QBrushStyle(const QString& style);
|
||||||
|
|
||||||
|
|
||||||
|
/** \brief converts a Unicode codepoint into a UTF8-sequence
|
||||||
|
* \ingroup jkqtptools_string
|
||||||
|
*
|
||||||
|
* \see https://stackoverflow.com/questions/19968705/unsigned-integer-as-utf-8-value
|
||||||
|
*/
|
||||||
|
JKQTCOMMON_LIB_EXPORT std::string jkqtp_UnicodeToUTF8(uint32_t codepoint);
|
||||||
|
|
||||||
/** \brief convert a double to a string, using the loacle "C"
|
/** \brief convert a double to a string, using the loacle "C"
|
||||||
* \ingroup jkqtptools_string
|
* \ingroup jkqtptools_string
|
||||||
|
@ -133,7 +133,8 @@ 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} 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 \\unicode{HEX} and \c \\usym{HEX} : draws a unicode character from its 32-bit codepoint \image html jkqtmathtext/jkqtmathtext_unicode.png (generated by <code>star: \\unicode{2605}, circonflex: \\unicode{109} emoticons: \\usym{1F440} \\usym{1F929}</code>)
|
||||||
|
- \c \\utfeight{HEX} : draws a unicode character from its UTF-8 encoding \image html jkqtmathtext/jkqtmathtext_utf8.png (generated by <code>star: \\utfeight{e29885} emoticons \\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
|
||||||
|
@ -147,10 +147,11 @@ void JKQTMathTextSimpleInstructionNode::fillInstructions()
|
|||||||
bool ok=false;
|
bool ok=false;
|
||||||
qlonglong code=parameters.value(0, "0").toLongLong(&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(static_cast<uint16_t>(code));
|
if (ok&&(code>=0)&&(code<=0xFFFFFFFF)) return QString::fromStdString(jkqtp_UnicodeToUTF8(static_cast<uint32_t>(code)));
|
||||||
return QChar(0);
|
else return QString();
|
||||||
}, 1);
|
}, 1);
|
||||||
instructions["unicode"]= i;
|
instructions["unicode"]= i;
|
||||||
|
instructions["usym"]= i;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
InstructionProperties i([](const QStringList& parameters) -> QString {
|
InstructionProperties i([](const QStringList& parameters) -> QString {
|
||||||
|
Loading…
Reference in New Issue
Block a user