diff --git a/doc/images/palettes/palette_alpha.png b/doc/images/palettes/palette_alpha.png new file mode 100644 index 0000000000..d3476a28fa Binary files /dev/null and b/doc/images/palettes/palette_alpha.png differ diff --git a/doc/images/palettes/palette_invalpha.png b/doc/images/palettes/palette_invalpha.png new file mode 100644 index 0000000000..d3476a28fa Binary files /dev/null and b/doc/images/palettes/palette_invalpha.png differ diff --git a/examples/multithreaded/README.md b/examples/multithreaded/README.md index a448c091aa..fb1ea0eb7f 100644 --- a/examples/multithreaded/README.md +++ b/examples/multithreaded/README.md @@ -94,10 +94,13 @@ This test results in the following numbers (on my AMD Ryzen5 8/16-core laptop): [comment]:RESULTS -SERIAL RESULTS:
runtime, overall = 1822.3ms
single runtimes = (227.7 +/- 306.8) ms
speedup = 1.00x
threads / available = 1 / 16

+VERSION: 5.0.0 +BUILD MODE: Release + +SERIAL RESULTS:
runtime, overall = 1896.0ms
single runtimes = (236.9 +/- 379.1) ms
speedup = 1.00x
threads / available = 1 / 16

PARALLEL RESULTS:
-runtime, overall = 811.1ms
single runtimes = (760.8 +/- 63.8) ms
speedup = 7.50x
threads / available = 8 / 16

speedup vs. serial = 2.2x +runtime, overall = 624.7ms
single runtimes = (564.3 +/- 107.7) ms
speedup = 7.23x
threads / available = 8 / 16

speedup vs. serial = 3.0x [comment]:RESULTS_END diff --git a/examples/multithreaded/multithreaded.cpp b/examples/multithreaded/multithreaded.cpp index 026c80a9e8..a0f60c9dc3 100644 --- a/examples/multithreaded/multithreaded.cpp +++ b/examples/multithreaded/multithreaded.cpp @@ -15,6 +15,7 @@ #include "multithreaded_thread.h" #include "jkqtmath/jkqtpstatbasics.h" #include "jkqtpexampleapplication.h" +#include "jkqtplotter_version.h" #define NUM_SHOWN_PLOTS 3 #define NUM_PLOTS 8 @@ -129,7 +130,9 @@ int main(int argc, char* argv[]) const auto iend=md.indexOf("[comment]:RESULTS_END"); qDebug()<<" istart="<SERIAL RESULTS:
"+ser_result.toUtf8() + const QByteArray newResults="[comment]:RESULTS\n\nVERSION: "+QByteArray(JKQTPLOTTER_VERSION::PROJECT_VERSION) + +"\nBUILD MODE: "+QByteArray(JKQTPLOTTER_VERSION::PROJECT_BUILDTYPE) + +"\n\nSERIAL RESULTS:
"+ser_result.toUtf8() +"\n\nPARALLEL RESULTS:
\n"+par_result.toUtf8()+"\n\n"; md.replace(istart,iend-istart,newResults); if (f.open(QFile::WriteOnly)) { diff --git a/lib/jkqtcommon/jkqtpbasicimagetools.cpp b/lib/jkqtcommon/jkqtpbasicimagetools.cpp index 9f349360c3..e2d60fe80c 100644 --- a/lib/jkqtcommon/jkqtpbasicimagetools.cpp +++ b/lib/jkqtcommon/jkqtpbasicimagetools.cpp @@ -40,7 +40,9 @@ const int JKQTPImageTools::NDEFAULTSTEPS = 5; QMap JKQTPImageTools::global_jkqtpimagetools_lutstore = JKQTPImageTools::getDefaultLUTs(); int JKQTPImageTools::global_next_userpalette = JKQTPMathImageFIRST_REGISTERED_USER_PALETTE; -std::mutex JKQTPImageTools::lutMutex; +QReadWriteLock JKQTPImageTools::lutMutex; +QStringList JKQTPImageTools::getPredefinedPalettesGlobalList = QStringList(); +QStringList JKQTPImageTools::getPredefinedPalettesMachineReadableGlobalList = QStringList(); @@ -2040,38 +2042,44 @@ bool JKQTPImagePlot_QPairCompareFirst(const QPair &s1, const QPair lock(JKQTPImageTools::lutMutex); - static QStringList sl; + QReadLocker lock(&JKQTPImageTools::lutMutex); - if (sl.size()!=JKQTPImageTools::global_jkqtpimagetools_lutstore.size()) { - sl.clear(); - for (auto it=JKQTPImageTools::global_jkqtpimagetools_lutstore.begin(); it!=JKQTPImageTools::global_jkqtpimagetools_lutstore.end(); ++it) { - if (it.key()>=0 && it.key()<=JKQTPMathImageLAST_POSSIBLE_REGISTERED_USER_PALETTE) { - if (it.value().nameT.size()!=0) sl<=0 && it.key()<=JKQTPMathImageLAST_POSSIBLE_REGISTERED_USER_PALETTE) { + if (it.value().nameT.size()!=0) getPredefinedPalettesGlobalList< lock(JKQTPImageTools::lutMutex); - static QStringList sl; + QReadLocker lock(&JKQTPImageTools::lutMutex); - if (sl.size()!=JKQTPImageTools::global_jkqtpimagetools_lutstore.size()) { - sl.clear(); - for (auto it=JKQTPImageTools::global_jkqtpimagetools_lutstore.begin(); it!=JKQTPImageTools::global_jkqtpimagetools_lutstore.end(); ++it) { - if (it.key()>=0) { - if (it.value().name.size()!=0) sl<=0) { + if (it.value().name.size()!=0) getPredefinedPalettesMachineReadableGlobalList< lock(JKQTPImageTools::lutMutex); + QReadLocker lock(&JKQTPImageTools::lutMutex); auto it=JKQTPImageTools::global_jkqtpimagetools_lutstore.find(p); if (it==JKQTPImageTools::global_jkqtpimagetools_lutstore.end()) return QString::number(static_cast(p)); else { @@ -2091,7 +2099,7 @@ QString JKQTPImageTools::JKQTPMathImageColorPalette2String(JKQTPMathImageColorPa QString JKQTPImageTools::JKQTPMathImageColorPalette2StringHumanReadable(JKQTPMathImageColorPalette p) { - std::lock_guard lock(JKQTPImageTools::lutMutex); + QReadLocker lock(&JKQTPImageTools::lutMutex); auto it=JKQTPImageTools::global_jkqtpimagetools_lutstore.find(p); if (it==JKQTPImageTools::global_jkqtpimagetools_lutstore.end()) return QString::number(static_cast(p)); else { @@ -2103,7 +2111,7 @@ QString JKQTPImageTools::JKQTPMathImageColorPalette2StringHumanReadable(JKQTPMat JKQTPMathImageColorPalette JKQTPImageTools::String2JKQTPMathImageColorPalette(const QString &p) { - std::lock_guard lock(JKQTPImageTools::lutMutex); + QReadLocker lock(&JKQTPImageTools::lutMutex); for (auto it=JKQTPImageTools::global_jkqtpimagetools_lutstore.begin(); it!=JKQTPImageTools::global_jkqtpimagetools_lutstore.end(); ++it) { if (QString::compare(p, it.value().name, Qt::CaseInsensitive)==0) { return static_cast(it.key()); @@ -2234,7 +2242,7 @@ QVector JKQTPImageTools::getColorsforPalette(JKQTPMathImageColorPalette int JKQTPImageTools::registerPalette(const QString &name, const JKQTPImageTools::LUTType &paletteLut, const QString &nameT) { - std::lock_guard lock(JKQTPImageTools::lutMutex); + QWriteLocker lock(&JKQTPImageTools::lutMutex); int id=JKQTPImageTools::global_next_userpalette++; JKQTPImageTools::global_jkqtpimagetools_lutstore[id].name=name; JKQTPImageTools::global_jkqtpimagetools_lutstore[id].nameT=((nameT.size()>0)?nameT:name); diff --git a/lib/jkqtcommon/jkqtpbasicimagetools.h b/lib/jkqtcommon/jkqtpbasicimagetools.h index ac32c11ac3..f73528e6fe 100644 --- a/lib/jkqtcommon/jkqtpbasicimagetools.h +++ b/lib/jkqtcommon/jkqtpbasicimagetools.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include "jkqtcommon/jkqtcommon_imexport.h" #include "jkqtcommon/jkqtpmathtools.h" @@ -341,16 +341,16 @@ enum JKQTPMathImageColorPalette { JKQTPMathImagePastel2_STEP, /*!< \image{inline} html palettes/palette_pastel2_step.png */ JKQTPMathImageSet1_STEP, /*!< \image{inline} html palettes/palette_set1_step.png */ JKQTPMathImageSet2_STEP, /*!< \image{inline} html palettes/palette_set2_step.png */ + JKQTPMathImageALPHA, /*!< \brief special palette with increasing alpha values */ + JKQTPMathImageINVERTED_ALPHA, /*!< \brief special palette with decreasing alpha values */ JKQTPMathImagePREDEFINED_PALETTES_COUNT, /*!< \brief the number of predefined palettes */ JKQTPMathImageUSER_PALETTE=65000, /*!< \brief special value for JKQTPImageTools::array2image(), which signals the usage of a provided user-defined palette */ - JKQTPMathImageALPHA=JKQTPMathImageUSER_PALETTE-2, /*!< \brief special palette with increasing alpha values */ - JKQTPMathImageINVERTED_ALPHA=JKQTPMathImageUSER_PALETTE-1, /*!< \brief special palette with decreasing alpha values */ JKQTPMathImageFIRST_REGISTERED_USER_PALETTE=JKQTPMathImagePREDEFINED_PALETTES_COUNT, /*!< \brief the ID of the first user-defined paletted, registered with JKQTPImageTools::registerPalette() or JKQTPImageTools::registerPalettesFromFile() */ - JKQTPMathImageLAST_POSSIBLE_REGISTERED_USER_PALETTE=JKQTPMathImageUSER_PALETTE-10, /*!< \brief the ID of the first user-defined paletted, registered with JKQTPImageTools::registerPalette() or JKQTPImageTools::registerPalettesFromFile() */ + JKQTPMathImageLAST_POSSIBLE_REGISTERED_USER_PALETTE=JKQTPMathImageUSER_PALETTE-10, /*!< \brief the ID of the last user-defined paletted, registered with JKQTPImageTools::registerPalette() or JKQTPImageTools::registerPalettesFromFile() */ }; @@ -664,8 +664,12 @@ struct JKQTPImageTools { \see registerPalette() registerPalettesFromFile() */ static JKQTCOMMON_LIB_EXPORT int global_next_userpalette; - /** \brief Mutex to protect global_jkqtpimagetools_lutstore and global_next_userpalette */ - static JKQTCOMMON_LIB_EXPORT std::mutex lutMutex; + /** \brief storage for the palette names in getPredefinedPalettes() \internal */ + static JKQTCOMMON_LIB_EXPORT QStringList getPredefinedPalettesGlobalList; + /** \brief storage for the palette names in etPredefinedPalettesMachineReadable() \internal */ + static JKQTCOMMON_LIB_EXPORT QStringList getPredefinedPalettesMachineReadableGlobalList; + /** \brief Mutex to protect global_jkqtpimagetools_lutstore, getPredefinedPalettesGlobalList, getPredefinedPalettesMachineReadableGlobalList and global_next_userpalette */ + static JKQTCOMMON_LIB_EXPORT QReadWriteLock lutMutex; /*! \brief returns data of the default LUTs, used to initialize global_jkqtpimagetools_lutstore diff --git a/lib/jkqtcommon/jkqtpconcurrencytools.h b/lib/jkqtcommon/jkqtpconcurrencytools.h index a4e1e31e1c..b1f8cf8238 100644 --- a/lib/jkqtcommon/jkqtpconcurrencytools.h +++ b/lib/jkqtcommon/jkqtpconcurrencytools.h @@ -25,6 +25,9 @@ #define JKQTPCONCURRENCYTOOLS_H #include "jkqtcommon/jkqtcommon_imexport.h" +#include +#include +#include #include /** \brief template class that wraps any datatype and combines it with a mutex, exposes the lock()/unlock() @@ -37,9 +40,39 @@ template class JKQTPSynchronized { public: /** \brief Mutex used by this temmplate */ - typedef std::mutex MutexType; - /** \brief type of a lock_guard for a JKQTPSynchronized */ - typedef std::lock_guard > Locker; + typedef QReadWriteLock MutexType; + + /** \brief type of AdoptLock tag, which is used in ReadLocker and WriteLocker to adopt a pre-locked JKQTPSynchronized */ + struct AdoptLockType { explicit AdoptLockType() = default; }; + /** \brief tag, which is used in ReadLocker and WriteLocker to adopt a pre-locked JKQTPSynchronized */ + static constexpr AdoptLockType AdoptLock { }; + + /** \brief type of a lock_guard for a JKQTPSynchronized for reading */ + class ReadLocker + { + public: + inline ReadLocker(const JKQTPSynchronized &sync) noexcept: m_sync(sync) { m_sync.lockForRead(); }; + inline ReadLocker(const JKQTPSynchronized &sync, AdoptLockType) noexcept : m_sync(sync) { }; + inline ~ReadLocker() { m_sync.unlock(); } + private: + Q_DISABLE_COPY(ReadLocker) + const JKQTPSynchronized &m_sync; + }; + + /** \brief type of a lock_guard for a JKQTPSynchronized for writing */ + class WriteLocker + { + public: + inline WriteLocker(JKQTPSynchronized &sync) noexcept: m_sync(sync) { m_sync.lockForWrite(); }; + inline WriteLocker(JKQTPSynchronized &sync, AdoptLockType) noexcept : m_sync(sync) { }; + inline ~WriteLocker() { m_sync.unlock(); } + private: + Q_DISABLE_COPY(WriteLocker) + JKQTPSynchronized &m_sync; + }; + + /** \brief type of a lock_guard for a JKQTPSynchronized for writing */ + typedef JKQTPSynchronized::WriteLocker Locker; /** \brief contained data type T */ typedef T data_type; /** \brief default constructor, the internal data is default-initialized */ @@ -59,18 +92,32 @@ public: m_data=std::move(other.m_data); } - /** \brief locks the internal mutex until unlock() is called, + /** \brief locks the internal mutex for writing, until unlock() is called * - * \note Use Locker instances to actually lock, using a RAII-idiom, as this is safer than doing this by hand! + * \note Use WriteLocker or Locker instances to actually lock, using a RAII-idiom, as this is safer than doing this by hand! */ - inline void lock() { - m_mutex.lock(); + inline void lock() const { + lockForWrite(); } - /** \brief unlocks the internal mutex from a previous lock() call + /** \brief locks the internal mutex for writing, until unlock() is called + * + * \note Use WriteLocker or Locker instances to actually lock, using a RAII-idiom, as this is safer than doing this by hand! + */ + inline void lockForWrite() const { + m_mutex.lockForWrite(); + } + /** \brief locks the internal mutex for writing, until unlock() is called + * + * \note Use WriteLocker or Locker instances to actually lock, using a RAII-idiom, as this is safer than doing this by hand! + */ + inline void lockForRead() const { + m_mutex.lockForRead(); + } + /** \brief unlocks the internal mutex from a previous lock(), lockForWrite() or lockForRead() call * * \note Use Locker instances to actually lock, using a RAII-idiom, as this is safer than doing this by hand! */ - inline void unlock() { + inline void unlock() const { m_mutex.unlock(); } /** \brief assign a value to the internal data storage, not thread-safe. @@ -130,7 +177,7 @@ public: /** \brief returns the value in the internal data storage, thread-safe. */ inline T get_safe() const { - Locker lck(m_mutex); + ReadLocker lck(this); return m_data; } diff --git a/lib/jkqtcommon/jkqtpdrawingtools.cpp b/lib/jkqtcommon/jkqtpdrawingtools.cpp index c85cae705c..0de9c43d4d 100644 --- a/lib/jkqtcommon/jkqtpdrawingtools.cpp +++ b/lib/jkqtcommon/jkqtpdrawingtools.cpp @@ -556,14 +556,14 @@ JKQTPSynchronized > JKQTPlotterDrawingToo JKQTPGraphSymbols JKQTPRegisterCustomGraphSymbol(JKQTPCustomGraphSymbolFunctor&& f) { - JKQTPlotterDrawingTools::SymbolsLocker lock(JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore); + JKQTPlotterDrawingTools::SymbolsWriteLocker lock(JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore); JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore->push_back(std::move(f)); return static_cast(static_cast(JKQTPFirstCustomSymbol)+static_cast(JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore->size()-1)); } JKQTPGraphSymbols JKQTPRegisterCustomGraphSymbol(const JKQTPCustomGraphSymbolFunctor& f) { - JKQTPlotterDrawingTools::SymbolsLocker lock(JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore); + JKQTPlotterDrawingTools::SymbolsWriteLocker lock(JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore); JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore->push_back(f); return static_cast(static_cast(JKQTPFirstCustomSymbol)+static_cast(JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore->size()-1)); } diff --git a/lib/jkqtcommon/jkqtpdrawingtools.h b/lib/jkqtcommon/jkqtpdrawingtools.h index 2910710926..3046e8740a 100644 --- a/lib/jkqtcommon/jkqtpdrawingtools.h +++ b/lib/jkqtcommon/jkqtpdrawingtools.h @@ -87,7 +87,8 @@ struct JKQTPlotterDrawingTools { * \internal */ static JKQTCOMMON_LIB_EXPORT JKQTPSynchronized > JKQTPCustomGraphSymbolStore; - typedef JKQTPSynchronized >::Locker SymbolsLocker; + typedef JKQTPSynchronized >::ReadLocker SymbolsReadLocker; + typedef JKQTPSynchronized >::WriteLocker SymbolsWriteLocker; }; @@ -982,7 +983,7 @@ inline void JKQTPPlotSymbol(TPainter& painter, double x, double y, JKQTPGraphSym painter.drawPath(path); } if (symbol>=JKQTPFirstCustomSymbol) { - JKQTPlotterDrawingTools::SymbolsLocker lock(JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore); + JKQTPlotterDrawingTools::SymbolsReadLocker lock(JKQTPlotterDrawingTools::JKQTPCustomGraphSymbolStore); const int idx(static_cast(symbol-JKQTPFirstCustomSymbol)); if (idx>=0 && idxsize()) { painter.setPen(p); diff --git a/lib/jkqtmathtext/jkqtmathtexttools.cpp b/lib/jkqtmathtext/jkqtmathtexttools.cpp index 4b50daf5a8..56da2c014d 100644 --- a/lib/jkqtmathtext/jkqtmathtexttools.cpp +++ b/lib/jkqtmathtext/jkqtmathtexttools.cpp @@ -29,22 +29,21 @@ #include #include #include +#include void initJKQTMathTextResources() { - static bool initialized=false; - static std::mutex mutex_initialized; - std::lock_guard lock(mutex_initialized); - if (!initialized) { -#ifdef JKQTMATHTEXT_COMPILED_WITH_XITS - Q_INIT_RESOURCE(xits); -#endif -#ifdef JKQTMATHTEXT_COMPILED_WITH_FIRAMATH - Q_INIT_RESOURCE(firamath); -#endif - initialized=true; - } + static std::once_flag flag; + std::call_once(flag, []() { + #ifdef JKQTMATHTEXT_COMPILED_WITH_XITS + Q_INIT_RESOURCE(xits); + #endif + #ifdef JKQTMATHTEXT_COMPILED_WITH_FIRAMATH + Q_INIT_RESOURCE(firamath); + #endif + } + ); } JKQTMathTextFontSpecifier::JKQTMathTextFontSpecifier(): @@ -234,6 +233,8 @@ bool JKQTMathTextFontSpecifier::hasFallbackSymbolFontName() const JKQTMathTextFontSpecifier JKQTMathTextFontSpecifier::getXITSFamilies() { initJKQTMathTextResources(); + + #if (QT_VERSION lock(fontSpecMutex); + static JKQTMathTextFontSpecifier fontSpec; if (fontSpec.m_fontName.isEmpty() && fontSpec.m_mathFontName.isEmpty()) { fontSpec.m_transformOnOutput=false; for (int i=0; i JKQTMathTextFontSpecifier { + initJKQTMathTextResources(); + #if (QT_VERSION lock(fontSpecMutex); - if (fontSpec.m_fontName.isEmpty() && fontSpec.m_mathFontName.isEmpty()) { + JKQTMathTextFontSpecifier fontSpec; fontSpec.m_transformOnOutput=false; for (int i=0; i JKQTMathTextFontSpecifier { + initJKQTMathTextResources(); + static QStringList mathNames{"STIX Two Math", "STIX Math", "STIX Two Math Standard", "STIX Math Standard"}; + static QStringList textNames{"STIX", "STIXGeneral", "STIX General"}; - static JKQTMathTextFontSpecifier fontSpec; - static std::mutex fontSpecMutex; - std::lock_guard lock(fontSpecMutex); - if (fontSpec.m_fontName.isEmpty() && fontSpec.m_mathFontName.isEmpty()) { + JKQTMathTextFontSpecifier fontSpec; fontSpec.m_transformOnOutput=false; #if (QT_VERSION JKQTMathTextFontSpecifier { + initJKQTMathTextResources(); + #if (QT_VERSION lock(fontSpecMutex); - if (fontSpec.m_fontName.isEmpty() && fontSpec.m_mathFontName.isEmpty()) { + JKQTMathTextFontSpecifier fontSpec; fontSpec.m_transformOnOutput=false; for (int i=0; i lock(fontSpecMutex); - if (fontSpec.m_fontName.isEmpty() && fontSpec.m_mathFontName.isEmpty()) { + static JKQTMathTextFontSpecifier fontSpec=[]() -> JKQTMathTextFontSpecifier { + JKQTMathTextFontSpecifier fontSpec; #if (QT_VERSION lock(fontSpecMutex); - if (fontSpec.m_fontName.isEmpty() && fontSpec.m_mathFontName.isEmpty()) { + static JKQTMathTextFontSpecifier fontSpec=[]() -> JKQTMathTextFontSpecifier { const QFont f=QGuiApplication::font().family(); QFont testFnt; if (f.styleHint()==QFont::SansSerif) { @@ -467,7 +457,8 @@ JKQTMathTextFontSpecifier JKQTMathTextFontSpecifier::getAppFontSFFamilies() testFnt.setStyleHint(QFont::StyleHint::SansSerif); fontSpec.m_fontName=fontSpec.m_mathFontName=testFnt.defaultFamily(); } - } + return fontSpec; + }(); return fontSpec; } diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextboxinstructionnode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextboxinstructionnode.cpp index b05b256018..74b14ac266 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextboxinstructionnode.cpp +++ b/lib/jkqtmathtext/nodes/jkqtmathtextboxinstructionnode.cpp @@ -41,7 +41,7 @@ JKQTMathTextBoxInstructionNode::JKQTMathTextBoxInstructionNode(JKQTMathText* _parent, const QString& name, JKQTMathTextNode* child, const QStringList& parameters): JKQTMathTextInstruction1Node(_parent, name, child, parameters) { - fillInstructions(); + } JKQTMathTextBoxInstructionNode::~JKQTMathTextBoxInstructionNode() { @@ -56,7 +56,7 @@ QString JKQTMathTextBoxInstructionNode::getTypeName() const JKQTMathTextNodeSize JKQTMathTextBoxInstructionNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const { JKQTMathTextEnvironment ev=currentEv; - const auto& inst=instructions.value(getInstructionName()); + const auto& inst=instructions().value(getInstructionName()); inst.modifier(ev, getParameters()); const QPen p=inst.pen(ev, getParameters(), parentMathText); const QBrush b=inst.brush(ev, getParameters(), parentMathText); @@ -77,7 +77,7 @@ double JKQTMathTextBoxInstructionNode::draw(QPainter& painter, double x, double doDrawBoxes(painter, x, y, currentEv); JKQTMathTextEnvironment ev=currentEv; - const auto& inst=instructions.value(getInstructionName()); + const auto& inst=instructions().value(getInstructionName()); inst.modifier(ev, getParameters()); const QPen p=inst.pen(ev, getParameters(), parentMathText); const QBrush b=inst.brush(ev, getParameters(), parentMathText); @@ -111,8 +111,8 @@ double JKQTMathTextBoxInstructionNode::draw(QPainter& painter, double x, double bool JKQTMathTextBoxInstructionNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const { JKQTMathTextEnvironment ev=currentEv; - fillInstructions(); - const auto& inst=instructions.value(getInstructionName()); + + const auto& inst=instructions().value(getInstructionName()); inst.modifier(ev, getParameters()); const QPen p=inst.pen(ev, getParameters(), parentMathText); const QBrush b=inst.brush(ev, getParameters(), parentMathText); @@ -140,174 +140,172 @@ bool JKQTMathTextBoxInstructionNode::toHtml(QString &html, JKQTMathTextEnvironme bool JKQTMathTextBoxInstructionNode::supportsInstructionName(const QString &instructionName) { - fillInstructions(); - return instructions.contains(instructionName); + return instructions().contains(instructionName); } size_t JKQTMathTextBoxInstructionNode::countParametersOfInstruction(const QString &instructionName) { - fillInstructions(); - if (instructions.contains(instructionName)) return instructions[instructionName].NParams; + if (instructions().contains(instructionName)) return instructions()[instructionName].NParams; return 0; } void JKQTMathTextBoxInstructionNode::modifyInMathEnvironment(const QString &instructionName, bool &insideMath, bool& insideMathTextStyle, const QStringList& params) { - fillInstructions(); - if (instructions.contains(instructionName)) { + + if (instructions().contains(instructionName)) { JKQTMathTextEnvironment ev; ev.insideMath=insideMath; ev.insideMathUseTextStyle=insideMathTextStyle; - instructions[instructionName].modifier(ev, params); + instructions()[instructionName].modifier(ev, params); insideMath=ev.insideMath; insideMathTextStyle=ev.insideMathUseTextStyle; } } -QHash JKQTMathTextBoxInstructionNode::instructions; +const QHash& JKQTMathTextBoxInstructionNode::instructions() { + static QHash table=[](){ + QHash instructions; -void JKQTMathTextBoxInstructionNode::fillInstructions() -{ - static std::mutex sMutex; - std::lock_guard lock(sMutex); - if (instructions.size()>0) return; - - { - InstructionProperties i(InstructionProperties::NoModification, - InstructionProperties::DefaultPen, - InstructionProperties::NoBrush, - InstructionProperties::DefaultPadding, - /*Nparams=*/0); - instructions["fbox"] = i; - instructions["framebox"] = i; - instructions["boxed"] = i; - instructions["framed"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - InstructionProperties::DefaultPen, - InstructionProperties::NoBrush, - InstructionProperties::DefaultPadding, - /*Nparams=*/0); - i.doubleLine=true; - instructions["doublebox"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - InstructionProperties::DefaultPen, - InstructionProperties::NoBrush, - InstructionProperties::DefaultPadding, - /*Nparams=*/0); - i.roundingFactor=0.7; - instructions["ovalbox"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - [](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){ - QPen p=InstructionProperties::DefaultPen(ev, parameters, parent); - p.setWidthF(p.widthF()*1.5); - return p; - }, - InstructionProperties::NoBrush, - InstructionProperties::DefaultPadding, - /*Nparams=*/0); - i.roundingFactor=0.8; - instructions["Ovalbox"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - InstructionProperties::DefaultPen, - InstructionProperties::NoBrush, - InstructionProperties::DefaultPadding, - /*Nparams=*/0); - i.roundingFactor=0.7; - i.doubleLine=true; - instructions["ovaldoublebox"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - [](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){ - QPen p=InstructionProperties::DefaultPen(ev, parameters, parent); - p.setColor(jkqtp_String2QColor(parameters.value(0, p.color().name()))); - return p; - }, - InstructionProperties::NoBrush, - InstructionProperties::DefaultPadding, - /*Nparams=*/1); - instructions["colorbox"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - [](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){ - QPen p=InstructionProperties::DefaultPen(ev, parameters, parent); - p.setStyle(Qt::DashLine); - return p; - }, - InstructionProperties::NoBrush, - InstructionProperties::DefaultPadding, - /*Nparams=*/0); - instructions["dashbox"] = i; - instructions["dashedbox"] = i; - instructions["dbox"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - [](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){ - QPen p=InstructionProperties::DefaultPen(ev, parameters, parent); - p.setStyle(Qt::DotLine); - return p; - }, - InstructionProperties::NoBrush, - InstructionProperties::DefaultPadding, - /*Nparams=*/0); - instructions["dottedbox"] = i; - instructions["dotbox"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - InstructionProperties::NoPen, - [](JKQTMathTextEnvironment& /*ev*/, const QStringList& parameters, JKQTMathText* /*parent*/){ - return QBrush(jkqtp_String2QColor(parameters.value(0, QColor(Qt::transparent).name())), Qt::SolidPattern); - }, - InstructionProperties::DefaultPadding, - /*Nparams=*/1); - instructions["shaded"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - InstructionProperties::NoPen, - [](JKQTMathTextEnvironment& /*ev*/, const QStringList& parameters, JKQTMathText* /*parent*/){ - return QBrush(jkqtp_String2QColor(parameters.value(0, QColor(Qt::transparent).name())), Qt::SolidPattern); - }, - 0, - /*Nparams=*/1); - instructions["snugshade"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - InstructionProperties::DefaultPen, - InstructionProperties::NoBrush, - 0, - /*Nparams=*/0); - instructions["snugbox"] = i; - } - { - InstructionProperties i(InstructionProperties::NoModification, - [](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){ - QPen p=InstructionProperties::DefaultPen(ev, parameters, parent); - p.setColor(jkqtp_String2QColor(parameters.value(0, p.color().name()))); - return p; - }, - [](JKQTMathTextEnvironment& /*ev*/, const QStringList& parameters, JKQTMathText* /*parent*/){ - return QBrush(jkqtp_String2QColor(parameters.value(1, QColor(Qt::transparent).name())), Qt::SolidPattern); - }, - InstructionProperties::DefaultPadding, - /*Nparams=*/2); - instructions["fcolorbox"] = i; - } + { + InstructionProperties i(InstructionProperties::NoModification, + InstructionProperties::DefaultPen, + InstructionProperties::NoBrush, + InstructionProperties::DefaultPadding, + /*Nparams=*/0); + instructions["fbox"] = i; + instructions["framebox"] = i; + instructions["boxed"] = i; + instructions["framed"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + InstructionProperties::DefaultPen, + InstructionProperties::NoBrush, + InstructionProperties::DefaultPadding, + /*Nparams=*/0); + i.doubleLine=true; + instructions["doublebox"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + InstructionProperties::DefaultPen, + InstructionProperties::NoBrush, + InstructionProperties::DefaultPadding, + /*Nparams=*/0); + i.roundingFactor=0.7; + instructions["ovalbox"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + [](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){ + QPen p=InstructionProperties::DefaultPen(ev, parameters, parent); + p.setWidthF(p.widthF()*1.5); + return p; + }, + InstructionProperties::NoBrush, + InstructionProperties::DefaultPadding, + /*Nparams=*/0); + i.roundingFactor=0.8; + instructions["Ovalbox"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + InstructionProperties::DefaultPen, + InstructionProperties::NoBrush, + InstructionProperties::DefaultPadding, + /*Nparams=*/0); + i.roundingFactor=0.7; + i.doubleLine=true; + instructions["ovaldoublebox"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + [](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){ + QPen p=InstructionProperties::DefaultPen(ev, parameters, parent); + p.setColor(jkqtp_String2QColor(parameters.value(0, p.color().name()))); + return p; + }, + InstructionProperties::NoBrush, + InstructionProperties::DefaultPadding, + /*Nparams=*/1); + instructions["colorbox"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + [](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){ + QPen p=InstructionProperties::DefaultPen(ev, parameters, parent); + p.setStyle(Qt::DashLine); + return p; + }, + InstructionProperties::NoBrush, + InstructionProperties::DefaultPadding, + /*Nparams=*/0); + instructions["dashbox"] = i; + instructions["dashedbox"] = i; + instructions["dbox"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + [](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){ + QPen p=InstructionProperties::DefaultPen(ev, parameters, parent); + p.setStyle(Qt::DotLine); + return p; + }, + InstructionProperties::NoBrush, + InstructionProperties::DefaultPadding, + /*Nparams=*/0); + instructions["dottedbox"] = i; + instructions["dotbox"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + InstructionProperties::NoPen, + [](JKQTMathTextEnvironment& /*ev*/, const QStringList& parameters, JKQTMathText* /*parent*/){ + return QBrush(jkqtp_String2QColor(parameters.value(0, QColor(Qt::transparent).name())), Qt::SolidPattern); + }, + InstructionProperties::DefaultPadding, + /*Nparams=*/1); + instructions["shaded"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + InstructionProperties::NoPen, + [](JKQTMathTextEnvironment& /*ev*/, const QStringList& parameters, JKQTMathText* /*parent*/){ + return QBrush(jkqtp_String2QColor(parameters.value(0, QColor(Qt::transparent).name())), Qt::SolidPattern); + }, + 0, + /*Nparams=*/1); + instructions["snugshade"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + InstructionProperties::DefaultPen, + InstructionProperties::NoBrush, + 0, + /*Nparams=*/0); + instructions["snugbox"] = i; + } + { + InstructionProperties i(InstructionProperties::NoModification, + [](JKQTMathTextEnvironment& ev, const QStringList& parameters, JKQTMathText* parent){ + QPen p=InstructionProperties::DefaultPen(ev, parameters, parent); + p.setColor(jkqtp_String2QColor(parameters.value(0, p.color().name()))); + return p; + }, + [](JKQTMathTextEnvironment& /*ev*/, const QStringList& parameters, JKQTMathText* /*parent*/){ + return QBrush(jkqtp_String2QColor(parameters.value(1, QColor(Qt::transparent).name())), Qt::SolidPattern); + }, + InstructionProperties::DefaultPadding, + /*Nparams=*/2); + instructions["fcolorbox"] = i; + } + return instructions; + }(); + return table; } + JKQTMathTextBoxInstructionNode::InstructionProperties::ModifyEnvironmentFunctor JKQTMathTextBoxInstructionNode::InstructionProperties::NoModification= [](JKQTMathTextEnvironment& /*ev*/, const QStringList& /*parameters*/){}; diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextboxinstructionnode.h b/lib/jkqtmathtext/nodes/jkqtmathtextboxinstructionnode.h index cfa069c223..e183b5180a 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextboxinstructionnode.h +++ b/lib/jkqtmathtext/nodes/jkqtmathtextboxinstructionnode.h @@ -106,13 +106,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextBoxInstructionNode: public JKQTMathTex double roundingFactor; }; - /** \brief fills instructions + /** \brief defines all implemented instructions in this node * * \note this is the customization point for new instructions! */ - static void fillInstructions(); - /** \brief defines all implemented instructions in this node */ - static QHash instructions; + static const QHash& instructions(); }; diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.cpp index d32af005f4..069cddcb5d 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.cpp +++ b/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.cpp @@ -108,14 +108,12 @@ QString JKQTMathTextDecoratedNode::DecorationType2String(JKQTMathTextDecoratedNo JKQTMathTextDecoratedNode::DecorationType JKQTMathTextDecoratedNode::InstructionName2DecorationType(const QString &mode) { - fillInstructions(); - return instructions[mode]; + return instructions()[mode]; } bool JKQTMathTextDecoratedNode::supportsInstructionName(const QString &instructionName) { - fillInstructions(); - return instructions.contains(instructionName); + return instructions().contains(instructionName); } @@ -168,64 +166,64 @@ JKQTMathTextNodeSize JKQTMathTextDecoratedNode::getSizeInternal(QPainter& painte return s; } -QHash JKQTMathTextDecoratedNode::instructions; +const QHash& JKQTMathTextDecoratedNode::instructions() { + static QHash table =[](){ + QHash instructions; -void JKQTMathTextDecoratedNode::fillInstructions() -{ - static std::mutex sMutex; - std::lock_guard lock(sMutex); - if (instructions.size()>0) return; + instructions["vec"]=MTDvec; + instructions["overline"]=MTDoverline; + instructions["oline"]=MTDoverline; + instructions["ol"]=MTDoverline; + instructions["underline"]=MTDunderline; + instructions["uline"]=MTDunderline; + instructions["ul"]=MTDunderline; + instructions["dashuline"]=MTDunderlineDashed; + instructions["dotuline"]=MTDunderlineDotted; + instructions["uuline"]=MTDdoubleunderline; + instructions["uul"]=MTDdoubleunderline; + instructions["ooline"]=MTDdoubleoverline; + instructions["ool"]=MTDdoubleoverline; + instructions["arrow"]=MTDarrow; + instructions["overrightarrow"]=MTDarrow; + instructions["overarrow"]=MTDarrow; + instructions["hat"]=MTDhat; + instructions["^"]=MTDhat; + instructions["widehat"]=MTDwidehat; + instructions["check"]=MTDcheck; + instructions["v"]=MTDcheck; + instructions["widecheck"]=MTDwidecheck; + instructions["bar"]=MTDbar; + instructions["="]=MTDbar; + instructions["dot"]=MTDdot; + instructions["."]=MTDdot; + instructions["ocirc"]=MTDocirc; + instructions["tilde"]=MTDtilde; + instructions["~"]=MTDtilde; + instructions["acute"]=MTDacute; + instructions["'"]=MTDacute; + instructions["grave"]=MTDgrave; + instructions["`"]=MTDgrave; + instructions["breve"]=MTDbreve; + instructions["u"]=MTDbreve; + instructions["widetilde"]=MTDwidetilde; + instructions["ddot"]=MTDddot; + instructions["cancel"]=MTDcancel; + instructions["xcancel"]=MTDxcancel; + instructions["bcancel"]=MTDbcancel; + instructions["strike"]=MTDstrike; + instructions["st"]=MTDstrike; + instructions["sout"]=MTDstrike; + instructions["overleftarrow"]=MTDoverleftarrow; + instructions["overrightarrow"]=MTDoverrightarrow; + instructions["overleftrightarrow"]=MTDoverleftrightarrow; + instructions["underleftarrow"]=MTDunderleftarrow; + instructions["underrightarrow"]=MTDunderrightarrow; + instructions["underleftrightarrow"]=MTDunderleftrightarrow; - instructions["vec"]=MTDvec; - instructions["overline"]=MTDoverline; - instructions["oline"]=MTDoverline; - instructions["ol"]=MTDoverline; - instructions["underline"]=MTDunderline; - instructions["uline"]=MTDunderline; - instructions["ul"]=MTDunderline; - instructions["dashuline"]=MTDunderlineDashed; - instructions["dotuline"]=MTDunderlineDotted; - instructions["uuline"]=MTDdoubleunderline; - instructions["uul"]=MTDdoubleunderline; - instructions["ooline"]=MTDdoubleoverline; - instructions["ool"]=MTDdoubleoverline; - instructions["arrow"]=MTDarrow; - instructions["overrightarrow"]=MTDarrow; - instructions["overarrow"]=MTDarrow; - instructions["hat"]=MTDhat; - instructions["^"]=MTDhat; - instructions["widehat"]=MTDwidehat; - instructions["check"]=MTDcheck; - instructions["v"]=MTDcheck; - instructions["widecheck"]=MTDwidecheck; - instructions["bar"]=MTDbar; - instructions["="]=MTDbar; - instructions["dot"]=MTDdot; - instructions["."]=MTDdot; - instructions["ocirc"]=MTDocirc; - instructions["tilde"]=MTDtilde; - instructions["~"]=MTDtilde; - instructions["acute"]=MTDacute; - instructions["'"]=MTDacute; - instructions["grave"]=MTDgrave; - instructions["`"]=MTDgrave; - instructions["breve"]=MTDbreve; - instructions["u"]=MTDbreve; - instructions["widetilde"]=MTDwidetilde; - instructions["ddot"]=MTDddot; - instructions["cancel"]=MTDcancel; - instructions["xcancel"]=MTDxcancel; - instructions["bcancel"]=MTDbcancel; - instructions["strike"]=MTDstrike; - instructions["st"]=MTDstrike; - instructions["sout"]=MTDstrike; - instructions["overleftarrow"]=MTDoverleftarrow; - instructions["overrightarrow"]=MTDoverrightarrow; - instructions["overleftrightarrow"]=MTDoverleftrightarrow; - instructions["underleftarrow"]=MTDunderleftarrow; - instructions["underrightarrow"]=MTDunderrightarrow; - instructions["underleftrightarrow"]=MTDunderleftrightarrow; + return instructions; + }(); + return table; } double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const { diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.h b/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.h index cf6ea52086..1d634ce350 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.h +++ b/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.h @@ -104,9 +104,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextSing /** \brief type of decoration that is added to the child node */ DecorationType decoration; /** \brief lists all supported instructions */ - static QHash instructions; - /** \brief fills instructions */ - static void fillInstructions(); + static const QHash& instructions(); }; #endif // JKQTMATHTEXTDECORATEDNODE_H diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextfracnode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextfracnode.cpp index 758d6670d9..5f2a773f02 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextfracnode.cpp +++ b/lib/jkqtmathtext/nodes/jkqtmathtextfracnode.cpp @@ -34,38 +34,36 @@ #include -QHash JKQTMathTextFracNode::instructions; - - -void JKQTMathTextFracNode::fillInstructions() -{ - static std::mutex sMutex; - std::lock_guard lock(sMutex); - if (instructions.size()>0) return; - instructions["frac"]=MTFMfrac; - instructions["dfrac"] = MTFMdfrac; - instructions["cfrac"]=MTFMdfrac; - instructions["sfrac"] = MTFMsfrac; - instructions["slantfrac"] = MTFMsfrac; - instructions["xfrac"]=MTFMsfrac; - instructions["stfrac"] = MTFMstfrac; - instructions["nicefrac"] = MTFMstfrac; - instructions["slanttextfrac"] = MTFMstfrac; - instructions["xtfrac"]=MTFMstfrac; - instructions["tfrac"]=MTFMtfrac; - instructions["stackrel"]=MTFMstackrel; - instructions["underbrace"]=MTFMunderbrace; - instructions["underbracket"]=MTFMunderbracket; - instructions["underset"]=MTFMunderset; - instructions["overbrace"]=MTFMoverbrace; - instructions["overbracket"]=MTFMoverbracket; - instructions["overset"]=MTFMoverset; +const QHash& JKQTMathTextFracNode::instructions() { + static QHash table=[]() + { + QHash instructions; + instructions["frac"]=MTFMfrac; + instructions["dfrac"] = MTFMdfrac; + instructions["cfrac"]=MTFMdfrac; + instructions["sfrac"] = MTFMsfrac; + instructions["slantfrac"] = MTFMsfrac; + instructions["xfrac"]=MTFMsfrac; + instructions["stfrac"] = MTFMstfrac; + instructions["nicefrac"] = MTFMstfrac; + instructions["slanttextfrac"] = MTFMstfrac; + instructions["xtfrac"]=MTFMstfrac; + instructions["tfrac"]=MTFMtfrac; + instructions["stackrel"]=MTFMstackrel; + instructions["underbrace"]=MTFMunderbrace; + instructions["underbracket"]=MTFMunderbracket; + instructions["underset"]=MTFMunderset; + instructions["overbrace"]=MTFMoverbrace; + instructions["overbracket"]=MTFMoverbracket; + instructions["overset"]=MTFMoverset; + return instructions; + }(); + return table; } - QString JKQTMathTextFracNode::FracType2String(JKQTMathTextFracNode::FracType mode) { switch(mode) { @@ -99,14 +97,12 @@ QString JKQTMathTextFracNode::FracType2String(JKQTMathTextFracNode::FracType mod JKQTMathTextFracNode::FracType JKQTMathTextFracNode::InstructionName2FracType(const QString &mode) { - fillInstructions(); - return instructions.value(mode, MTFMfrac); + return instructions().value(mode, MTFMfrac); } bool JKQTMathTextFracNode::supportsInstructionName(const QString &instructionName) { - fillInstructions(); - return instructions.contains(instructionName); + return instructions().contains(instructionName); } diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextfracnode.h b/lib/jkqtmathtext/nodes/jkqtmathtextfracnode.h index aff8c56c47..f22449353e 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextfracnode.h +++ b/lib/jkqtmathtext/nodes/jkqtmathtextfracnode.h @@ -90,9 +90,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFracNode: public JKQTMathTextDualChild JKQTMathTextFracNode::FracType getMode() const; protected: /** \brief lists all supported instructions */ - static QHash instructions; - /** \brief fills instructions */ - static void fillInstructions(); + static const QHash& instructions(); /** \copydoc JKQTMathTextNode::getSizeInternal() */ virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override; /** \brief actual display type of fraction object */ diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp index 43b988f7f8..1d3f66347b 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp +++ b/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.cpp @@ -64,7 +64,6 @@ JKQTMathTextSimpleInstructionNode::JKQTMathTextSimpleInstructionNode(JKQTMathTex instructionName(_name), parameters(_parameters) { - fillInstructions(); } @@ -81,7 +80,6 @@ QString JKQTMathTextSimpleInstructionNode::getTypeName() const double JKQTMathTextSimpleInstructionNode::draw(QPainter &painter, double x, double y, JKQTMathTextEnvironment currentEv) const { doDrawBoxes(painter, x, y, currentEv); - fillInstructions(); QFont f=currentEv.getFont(parentMathText); f.setStyleStrategy(QFont::PreferDefault); const QFontMetricsF fm(f, painter.device()); @@ -95,7 +93,6 @@ double JKQTMathTextSimpleInstructionNode::draw(QPainter &painter, double x, doub bool JKQTMathTextSimpleInstructionNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const { - fillInstructions(); const QString txt=executeInstruction(); html+=txt; return true; @@ -113,20 +110,17 @@ const QStringList &JKQTMathTextSimpleInstructionNode::getParameters() const bool JKQTMathTextSimpleInstructionNode::supportsInstructionName(const QString &instructionName) { - fillInstructions(); - return instructions.contains(instructionName); + return instructions().contains(instructionName); } size_t JKQTMathTextSimpleInstructionNode::countParametersOfInstruction(const QString &instructionName) { - fillInstructions(); - if (instructions.contains(instructionName)) return instructions[instructionName].NParams; + if (instructions().contains(instructionName)) return instructions()[instructionName].NParams; return 0; } JKQTMathTextNodeSize JKQTMathTextSimpleInstructionNode::getSizeInternal(QPainter &painter, JKQTMathTextEnvironment currentEv) const { - fillInstructions(); QFont f=currentEv.getFont(parentMathText); f.setStyleStrategy(QFont::PreferDefault); const QFontMetricsF fm(f, painter.device()); @@ -140,47 +134,46 @@ JKQTMathTextNodeSize JKQTMathTextSimpleInstructionNode::getSizeInternal(QPainter return s; } -QHash JKQTMathTextSimpleInstructionNode::instructions; - -void JKQTMathTextSimpleInstructionNode::fillInstructions() -{ - static std::mutex sMutex; - std::lock_guard lock(sMutex); - if (instructions.size()>0) return; - { - InstructionProperties i([](const QStringList& parameters) -> QString { - bool ok=false; - qlonglong code=parameters.value(0, "0").toLongLong(&ok, 16); - ok=ok&&(code>=0); - if (ok&&(code>=0)&&(code<=0xFFFFFFFF)) return QString::fromStdString(jkqtp_UnicodeToUTF8(static_cast(code))); - else return QString(); - }, 1); - instructions["unicode"]= i; - instructions["usym"]= 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); +const QHash& JKQTMathTextSimpleInstructionNode::instructions() { + static QHash table=[]() + { + QHash instructions; + { + InstructionProperties i([](const QStringList& parameters) -> QString { + bool ok=false; + qlonglong code=parameters.value(0, "0").toLongLong(&ok, 16); + ok=ok&&(code>=0); + if (ok&&(code>=0)&&(code<=0xFFFFFFFF)) return QString::fromStdString(jkqtp_UnicodeToUTF8(static_cast(code))); + else return QString(); + }, 1); + instructions["unicode"]= i; + instructions["usym"]= i; } - return QChar(0); - }, 1); - instructions["utfeight"]= 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; + } + return instructions; + }(); + return table; } QString JKQTMathTextSimpleInstructionNode::executeInstruction() const { - fillInstructions(); - return instructions.value(getInstructionName(), InstructionProperties()).evaluator(getParameters()); + return instructions().value(getInstructionName(), InstructionProperties()).evaluator(getParameters()); } JKQTMathTextSimpleInstructionNode::InstructionProperties::InstructionProperties(): diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.h b/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.h index 408bc1c757..1ce40c6a5f 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.h +++ b/lib/jkqtmathtext/nodes/jkqtmathtextinstructionnode.h @@ -103,14 +103,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSimpleInstructionNode: public JKQTMath /** \brief output of the instruction */ EvaluateInstructionFunctor evaluator; }; - - /** \brief fills instructions + /** \brief defines all implemented instructions in this node * * \note this is the customization point for new instructions! */ - static void fillInstructions(); - /** \brief defines all implemented instructions in this node */ - static QHash instructions; + static const QHash& instructions(); /** \brief executes the instruction on \a ev */ QString executeInstruction() const; /** \brief instruction name */ diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextmodifyenvironmentnode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextmodifyenvironmentnode.cpp index 4ea968edc0..a275c8e772 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextmodifyenvironmentnode.cpp +++ b/lib/jkqtmathtext/nodes/jkqtmathtextmodifyenvironmentnode.cpp @@ -38,7 +38,6 @@ JKQTMathTextModifiedTextPropsInstructionNode::JKQTMathTextModifiedTextPropsInstructionNode(JKQTMathText* _parent, const QString& name, JKQTMathTextNode* child, const QStringList& parameters): JKQTMathTextInstruction1Node(_parent, name, child, parameters) { - fillInstructions(); } JKQTMathTextModifiedTextPropsInstructionNode::~JKQTMathTextModifiedTextPropsInstructionNode() { @@ -51,7 +50,6 @@ QString JKQTMathTextModifiedTextPropsInstructionNode::getTypeName() const } JKQTMathTextNodeSize JKQTMathTextModifiedTextPropsInstructionNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const { - fillInstructions(); JKQTMathTextEnvironment ev=currentEv; executeInstruction(ev); @@ -60,7 +58,6 @@ JKQTMathTextNodeSize JKQTMathTextModifiedTextPropsInstructionNode::getSizeIntern } double JKQTMathTextModifiedTextPropsInstructionNode::draw(QPainter& painter, double x, double y, JKQTMathTextEnvironment currentEv) const { - fillInstructions(); doDrawBoxes(painter, x, y, currentEv); JKQTMathTextEnvironment ev=currentEv; @@ -71,7 +68,6 @@ double JKQTMathTextModifiedTextPropsInstructionNode::draw(QPainter& painter, dou bool JKQTMathTextModifiedTextPropsInstructionNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const { JKQTMathTextEnvironment ev=currentEv; - fillInstructions(); executeInstruction(ev); return getChild()->toHtml(html, ev, defaultEv); @@ -79,25 +75,22 @@ bool JKQTMathTextModifiedTextPropsInstructionNode::toHtml(QString &html, JKQTMat bool JKQTMathTextModifiedTextPropsInstructionNode::supportsInstructionName(const QString &instructionName) { - fillInstructions(); - return instructions.contains(instructionName); + return instructions().contains(instructionName); } size_t JKQTMathTextModifiedTextPropsInstructionNode::countParametersOfInstruction(const QString &instructionName) { - fillInstructions(); - if (instructions.contains(instructionName)) return instructions[instructionName].NParams; + if (instructions().contains(instructionName)) return instructions()[instructionName].NParams; return 0; } void JKQTMathTextModifiedTextPropsInstructionNode::modifyInMathEnvironment(const QString &instructionName, bool &insideMath, bool& insideMathTextStyle, const QStringList& params) { - fillInstructions(); - if (instructions.contains(instructionName)) { + if (instructions().contains(instructionName)) { JKQTMathTextEnvironment ev; ev.insideMath=insideMath; ev.insideMathUseTextStyle=insideMathTextStyle; - instructions[instructionName].modifier(ev, params); + instructions()[instructionName].modifier(ev, params); insideMath=ev.insideMath; insideMathTextStyle=ev.insideMathUseTextStyle; } @@ -106,356 +99,355 @@ void JKQTMathTextModifiedTextPropsInstructionNode::modifyInMathEnvironment(const void JKQTMathTextModifiedTextPropsInstructionNode::executeInstruction(JKQTMathTextEnvironment &ev) const { - fillInstructions(); - instructions.value(getInstructionName(), InstructionProperties()).modifier(ev, getParameters()); + instructions().value(getInstructionName(), InstructionProperties()).modifier(ev, getParameters()); } -QHash JKQTMathTextModifiedTextPropsInstructionNode::instructions; +const QHash& JKQTMathTextModifiedTextPropsInstructionNode::instructions() { + static QHash table=[]() + { -void JKQTMathTextModifiedTextPropsInstructionNode::fillInstructions() -{ - - static std::mutex sMutex; - std::lock_guard lock(sMutex); - if (instructions.size()>0) return; - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.bold=false; - ev.insideMathForceDigitsUpright=true; - ev.italic=false; - ev.underlined=false; - ev.overline=false; - ev.strike=false; - ev.font=MTEroman; - }, 0); - instructions["textnormal"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.bold=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["textbf"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.bold=true; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathbf"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.italic=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["textit"] = i; - instructions["mathit"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.italic=!ev.italic; - }, 0); - instructions["emph"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.italic=false; - }, 0); - instructions["textup"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& parameters) { - ev.color=jkqtp_String2QColor(parameters.value(0, ev.color.name())); - }, 1); - instructions["textcolor"] = i; - instructions["mathcolor"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& parameters) { - ev.customFontName=parameters.value(0, ""); - ev.font=MTECustomFont; - }, 1); - instructions["userfont"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.beginMathMode(); - }, 0); - instructions["ensuremath"] = i; - instructions["equation"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.capitalization=QFont::SmallCaps; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["textsc"] = i; - instructions["mathsc"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.capitalization=QFont::AllUppercase; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["uppercase"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.capitalization=QFont::AllLowercase; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["lowercase"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.underlined=true; - }, 0); - instructions["ul"] = i; - instructions["underlined"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.overline=true; - }, 0); - instructions["ol"] = i; - instructions["overlined"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.strike=true; - }, 0); - instructions["strike"]= i; - instructions["st"]= i; - instructions["sout"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEroman; - ev.italic=false; - }, 0); - instructions["textrm"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEroman; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathrm"] = i; - instructions["unit"] = i; - instructions["operatorname"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.bold=true; - ev.italic=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathbfit"] = i; - instructions["textbfit"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.endMathMode(); - ev.font=JKQTMathTextEnvironmentFont::MTEroman; - }, 0); - instructions["text"] = i; - instructions["mbox"] = i; - instructions["ensuretext"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEroman; - ev.italic=false; - ev.bold=true; - }, 0); - instructions["mat"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathcal"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; - }, 0); - instructions["textcal"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; - ev.italic=false; - ev.bold=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathbfcal"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; - ev.bold=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["textfcal"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; - }, 0); - instructions["textfrak"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathfrak"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; - ev.bold=true; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathbffrak"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; - ev.bold=true; - }, 0); - instructions["textbffrak"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEblackboard; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["textbb"] = i; - instructions["mathbb"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; - }, 0); - instructions["texttt"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathtt"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; - ev.bold=true; - }, 0); - instructions["textbftt"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; - ev.italic=false; - ev.bold=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathbftt"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEsans; - }, 0); - instructions["textsf"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEsans; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathsf"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEsans; - ev.italic=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["textitsf"] = i; - instructions["mathitsf"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEscript; - }, 0); - instructions["textscript"] = i; - instructions["textscr"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEscript; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathscript"] = i; - instructions["mathscr"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEscript; - ev.bold=true; - }, 0); - instructions["textbfscript"] = i; - instructions["textbfscr"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.font=JKQTMathTextEnvironmentFont::MTEscript; - ev.bold=true; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["mathbfscript"] = i; - instructions["mathbfscr"]= i; - } + QHash instructions; + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.bold=false; + ev.insideMathForceDigitsUpright=true; + ev.italic=false; + ev.underlined=false; + ev.overline=false; + ev.strike=false; + ev.font=MTEroman; + }, 0); + instructions["textnormal"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.bold=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["textbf"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.bold=true; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathbf"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.italic=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["textit"] = i; + instructions["mathit"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.italic=!ev.italic; + }, 0); + instructions["emph"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.italic=false; + }, 0); + instructions["textup"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& parameters) { + ev.color=jkqtp_String2QColor(parameters.value(0, ev.color.name())); + }, 1); + instructions["textcolor"] = i; + instructions["mathcolor"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& parameters) { + ev.customFontName=parameters.value(0, ""); + ev.font=MTECustomFont; + }, 1); + instructions["userfont"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.beginMathMode(); + }, 0); + instructions["ensuremath"] = i; + instructions["equation"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.capitalization=QFont::SmallCaps; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["textsc"] = i; + instructions["mathsc"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.capitalization=QFont::AllUppercase; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["uppercase"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.capitalization=QFont::AllLowercase; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["lowercase"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.underlined=true; + }, 0); + instructions["ul"] = i; + instructions["underlined"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.overline=true; + }, 0); + instructions["ol"] = i; + instructions["overlined"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.strike=true; + }, 0); + instructions["strike"]= i; + instructions["st"]= i; + instructions["sout"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEroman; + ev.italic=false; + }, 0); + instructions["textrm"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEroman; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathrm"] = i; + instructions["unit"] = i; + instructions["operatorname"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.bold=true; + ev.italic=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathbfit"] = i; + instructions["textbfit"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.endMathMode(); + ev.font=JKQTMathTextEnvironmentFont::MTEroman; + }, 0); + instructions["text"] = i; + instructions["mbox"] = i; + instructions["ensuretext"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEroman; + ev.italic=false; + ev.bold=true; + }, 0); + instructions["mat"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathcal"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; + }, 0); + instructions["textcal"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; + ev.italic=false; + ev.bold=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathbfcal"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; + ev.bold=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["textfcal"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; + }, 0); + instructions["textfrak"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathfrak"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; + ev.bold=true; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathbffrak"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; + ev.bold=true; + }, 0); + instructions["textbffrak"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEblackboard; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["textbb"] = i; + instructions["mathbb"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; + }, 0); + instructions["texttt"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathtt"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; + ev.bold=true; + }, 0); + instructions["textbftt"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; + ev.italic=false; + ev.bold=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathbftt"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEsans; + }, 0); + instructions["textsf"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEsans; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathsf"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEsans; + ev.italic=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["textitsf"] = i; + instructions["mathitsf"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEscript; + }, 0); + instructions["textscript"] = i; + instructions["textscr"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEscript; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathscript"] = i; + instructions["mathscr"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEscript; + ev.bold=true; + }, 0); + instructions["textbfscript"] = i; + instructions["textbfscr"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.font=JKQTMathTextEnvironmentFont::MTEscript; + ev.bold=true; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["mathbfscript"] = i; + instructions["mathbfscr"]= i; + } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.fontSize=ev.fontSize*1.2; - }, 0); - instructions["bigsize"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.fontSize=ev.fontSize*1.85; - }, 0); - instructions["Bigsize"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.fontSize=ev.fontSize*2.4; - }, 0); - instructions["biggsize"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { - ev.fontSize=ev.fontSize*3.1; - }, 0); - instructions["Biggsize"]= i; - } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.fontSize=ev.fontSize*1.2; + }, 0); + instructions["bigsize"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.fontSize=ev.fontSize*1.85; + }, 0); + instructions["Bigsize"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.fontSize=ev.fontSize*2.4; + }, 0); + instructions["biggsize"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/) { + ev.fontSize=ev.fontSize*3.1; + }, 0); + instructions["Biggsize"]= i; + } + return instructions; + }(); + return table; } JKQTMathTextModifiedTextPropsInstructionNode::InstructionProperties::InstructionProperties(): @@ -479,7 +471,6 @@ JKQTMathTextModifiedEnvironmentInstructionNode::JKQTMathTextModifiedEnvironmentI instructionName(name_), parameters(parameters_) { - fillInstructions(); } JKQTMathTextModifiedEnvironmentInstructionNode::~JKQTMathTextModifiedEnvironmentInstructionNode() @@ -504,323 +495,316 @@ const QStringList &JKQTMathTextModifiedEnvironmentInstructionNode::getParameters void JKQTMathTextModifiedEnvironmentInstructionNode::modifyEnvironment(JKQTMathTextEnvironment ¤tEv) const { - fillInstructions(); - instructions.value(getInstructionName(), InstructionProperties()).modifier(currentEv, getParameters(), parentMathText); + instructions().value(getInstructionName(), InstructionProperties()).modifier(currentEv, getParameters(), parentMathText); } bool JKQTMathTextModifiedEnvironmentInstructionNode::supportsInstructionName(const QString &instructionName) { - fillInstructions(); - return instructions.contains(instructionName); + return instructions().contains(instructionName); } size_t JKQTMathTextModifiedEnvironmentInstructionNode::countParametersOfInstruction(const QString &instructionName) { - fillInstructions(); - if (instructions.contains(instructionName)) return instructions[instructionName].NParams; + if (instructions().contains(instructionName)) return instructions()[instructionName].NParams; return 0; } void JKQTMathTextModifiedEnvironmentInstructionNode::modifyInMathTextStyleEnvironment(const QString &instructionName, bool &insideMathTextStyle, JKQTMathText* parentMathText, const QStringList ¶ms) { - fillInstructions(); - if (instructions.contains(instructionName)) { + if (instructions().contains(instructionName)) { JKQTMathTextEnvironment ev; ev.insideMathUseTextStyle=insideMathTextStyle; - instructions[instructionName].modifier(ev, params, parentMathText); + instructions()[instructionName].modifier(ev, params, parentMathText); insideMathTextStyle=ev.insideMathUseTextStyle; } } -QHash JKQTMathTextModifiedEnvironmentInstructionNode::instructions; +const QHash& JKQTMathTextModifiedEnvironmentInstructionNode::instructions() { + static QHash table=[](){ + QHash instructions; -void JKQTMathTextModifiedEnvironmentInstructionNode::fillInstructions() -{ - static std::mutex sMutex; - std::lock_guard lock(sMutex); - if (instructions.size()>0) return; - - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.bold=false; - ev.insideMathForceDigitsUpright=true; - ev.italic=false; - ev.underlined=false; - ev.overline=false; - ev.strike=false; - ev.font=MTEroman; - ev.fontSize=parentMathText->getFontSize(); - ev.capitalization=QFont::MixedCase; - ev.color=parentMathText->getFontColor(); - }, 0); - instructions["normalfont"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.bold=false; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["md"] = i; - instructions["mdseries"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.bold=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["bf"] = i; - instructions["bfseries"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.italic=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["it"] = i; - instructions["itshape"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["up"] = i; - instructions["upshape"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.italic=!ev.italic; - }, 0); - instructions["em"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& parameters, const JKQTMathText* parentMathText) { - ev.color=jkqtp_String2QColor(parameters.value(0, ev.color.name())); - }, 1); - instructions["color"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& parameters, const JKQTMathText* parentMathText) { - ev.customFontName=parameters.value(0, ""); - ev.font=MTECustomFont; - }, 1); - instructions["setfont"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.capitalization=QFont::SmallCaps; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["sc"] = i; - instructions["scshape"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEroman; - ev.italic=false; - }, 0); - instructions["rm"] = i; - instructions["rmfamily"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.bold=true; - ev.italic=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["bfit"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; - }, 0); - instructions["cal"] = i; - instructions["calfamily"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; - ev.bold=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["bbfcal"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; - }, 0); - instructions["frak"] = i; - instructions["frakfamily"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; - ev.bold=true; - }, 0); - instructions["bffrak"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEblackboard; - ev.italic=false; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["bb"] = i; - instructions["bbfamily"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; - }, 0); - instructions["tt"] = i; - instructions["ttfamily"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; - ev.bold=true; - }, 0); - instructions["bftt"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEsans; - }, 0); - instructions["sf"] = i; - instructions["sffamily"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEsans; - ev.italic=true; - ev.insideMathForceDigitsUpright=false; - }, 0); - instructions["itsf"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEscript; - }, 0); - instructions["script"] = i; - instructions["scr"] = i; - instructions["scriptseries"] = i; - instructions["scrseries"] = i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.font=JKQTMathTextEnvironmentFont::MTEscript; - ev.bold=true; - }, 0); - instructions["bfscript"] = i; - instructions["bfscr"] = i; - } - - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize(); - ev.insideMathUseTextStyle=false; - }, 0); - instructions["displaystyle"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize(); - ev.insideMathUseTextStyle=true; - }, 0); - instructions["textstyle"]= i; - } - - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*0.75; - ev.insideMathUseTextStyle=true; - }, 0); - instructions["scriptstyle"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*0.5; - ev.insideMathUseTextStyle=true; - }, 0); - instructions["scriptscriptstyle"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*6.0/11.0; - }, 0); - instructions["tiny"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*7.0/11.0; - }, 0); - instructions["ssmall"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*8.0/11.0; - }, 0); - instructions["scriptsize"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*9.0/11.0; - }, 0); - instructions["footnotesize"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*10.0/11.0; - }, 0); - instructions["small"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*11.0/11.0; - }, 0); - instructions["normalsize"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*12.0/11.0; - }, 0); - instructions["large"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*14.4/11.0; - }, 0); - instructions["Large"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*17.28/11.0; - }, 0); - instructions["LARGE"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*20.74/11.0; - }, 0); - instructions["huge"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { - ev.fontSize=parentMathText->getFontSize()*24.88/11.0; - }, 0); - instructions["Huge"]= i; - } - { - InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& parameters, const JKQTMathText* parentMathText) { - ev.fontSize=parameters.value(0, QString::number(ev.fontSize)).toDouble(); - ev.fontSizeUnit=JKQTMathTextEnvironment::POINTS; - }, 1); - instructions["userfontsize"]= i; - instructions["fontsize"]= i; - } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.bold=false; + ev.insideMathForceDigitsUpright=true; + ev.italic=false; + ev.underlined=false; + ev.overline=false; + ev.strike=false; + ev.font=MTEroman; + ev.fontSize=parentMathText->getFontSize(); + ev.capitalization=QFont::MixedCase; + ev.color=parentMathText->getFontColor(); + }, 0); + instructions["normalfont"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.bold=false; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["md"] = i; + instructions["mdseries"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.bold=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["bf"] = i; + instructions["bfseries"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.italic=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["it"] = i; + instructions["itshape"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["up"] = i; + instructions["upshape"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.italic=!ev.italic; + }, 0); + instructions["em"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& parameters, const JKQTMathText* parentMathText) { + ev.color=jkqtp_String2QColor(parameters.value(0, ev.color.name())); + }, 1); + instructions["color"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& parameters, const JKQTMathText* parentMathText) { + ev.customFontName=parameters.value(0, ""); + ev.font=MTECustomFont; + }, 1); + instructions["setfont"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.capitalization=QFont::SmallCaps; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["sc"] = i; + instructions["scshape"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEroman; + ev.italic=false; + }, 0); + instructions["rm"] = i; + instructions["rmfamily"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.bold=true; + ev.italic=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["bfit"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; + }, 0); + instructions["cal"] = i; + instructions["calfamily"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEcaligraphic; + ev.bold=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["bbfcal"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; + }, 0); + instructions["frak"] = i; + instructions["frakfamily"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEfraktur; + ev.bold=true; + }, 0); + instructions["bffrak"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEblackboard; + ev.italic=false; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["bb"] = i; + instructions["bbfamily"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; + }, 0); + instructions["tt"] = i; + instructions["ttfamily"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEtypewriter; + ev.bold=true; + }, 0); + instructions["bftt"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEsans; + }, 0); + instructions["sf"] = i; + instructions["sffamily"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEsans; + ev.italic=true; + ev.insideMathForceDigitsUpright=false; + }, 0); + instructions["itsf"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEscript; + }, 0); + instructions["script"] = i; + instructions["scr"] = i; + instructions["scriptseries"] = i; + instructions["scrseries"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.font=JKQTMathTextEnvironmentFont::MTEscript; + ev.bold=true; + }, 0); + instructions["bfscript"] = i; + instructions["bfscr"] = i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize(); + ev.insideMathUseTextStyle=false; + }, 0); + instructions["displaystyle"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize(); + ev.insideMathUseTextStyle=true; + }, 0); + instructions["textstyle"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*0.75; + ev.insideMathUseTextStyle=true; + }, 0); + instructions["scriptstyle"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*0.5; + ev.insideMathUseTextStyle=true; + }, 0); + instructions["scriptscriptstyle"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*6.0/11.0; + }, 0); + instructions["tiny"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*7.0/11.0; + }, 0); + instructions["ssmall"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*8.0/11.0; + }, 0); + instructions["scriptsize"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*9.0/11.0; + }, 0); + instructions["footnotesize"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*10.0/11.0; + }, 0); + instructions["small"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*11.0/11.0; + }, 0); + instructions["normalsize"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*12.0/11.0; + }, 0); + instructions["large"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*14.4/11.0; + }, 0); + instructions["Large"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*17.28/11.0; + }, 0); + instructions["LARGE"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*20.74/11.0; + }, 0); + instructions["huge"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& /*parameters*/, const JKQTMathText* parentMathText) { + ev.fontSize=parentMathText->getFontSize()*24.88/11.0; + }, 0); + instructions["Huge"]= i; + } + { + InstructionProperties i([](JKQTMathTextEnvironment& ev, const QStringList& parameters, const JKQTMathText* parentMathText) { + ev.fontSize=parameters.value(0, QString::number(ev.fontSize)).toDouble(); + ev.fontSizeUnit=JKQTMathTextEnvironment::POINTS; + }, 1); + instructions["userfontsize"]= i; + instructions["fontsize"]= i; + } + return instructions; + }(); + return table; } JKQTMathTextModifiedEnvironmentInstructionNode::InstructionProperties::InstructionProperties(): diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextmodifyenvironmentnode.h b/lib/jkqtmathtext/nodes/jkqtmathtextmodifyenvironmentnode.h index 00a7d772fa..039d610701 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextmodifyenvironmentnode.h +++ b/lib/jkqtmathtext/nodes/jkqtmathtextmodifyenvironmentnode.h @@ -53,15 +53,15 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextModifiedTextPropsInstructionNode: publ virtual bool toHtml(QString& html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const override; /** \brief returns true, if the given \a instructionName can be represented by this node - * \see instructions + * \see instructions() */ static bool supportsInstructionName(const QString& instructionName); /** \brief returns the number of additional string parameters, required for the given \a instructionName - * \see instructions + * \see instructions() */ static size_t countParametersOfInstruction(const QString& instructionName); /** \brief sets \a insideMath to \c true if inside the node is to be parsed in math mode and \c false else - * \see instructions + * \see instructions() */ static void modifyInMathEnvironment(const QString& instructionName, bool& insideMath, bool &insideMathTextStyle, const QStringList ¶ms=QStringList()); @@ -82,13 +82,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextModifiedTextPropsInstructionNode: publ ModifyEnvironmentFunctor modifier; }; - /** \brief fills instructions + /** \brief defines all implemented instructions in this node * * \note this is the customization point for new instructions! */ - static void fillInstructions(); - /** \brief defines all implemented instructions in this node */ - static QHash instructions; + static const QHash& instructions(); /** \brief executes the instruction on \a ev */ void executeInstruction(JKQTMathTextEnvironment& ev) const; }; @@ -116,15 +114,15 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextModifiedEnvironmentInstructionNode: pu virtual void modifyEnvironment(JKQTMathTextEnvironment& currentEv) const override; /** \brief returns true, if the given \a instructionName can be represented by this node - * \see instructions + * \see instructions() */ static bool supportsInstructionName(const QString& instructionName); /** \brief returns the number of additional string parameters, required for the given \a instructionName - * \see instructions + * \see instructions() */ static size_t countParametersOfInstruction(const QString& instructionName); /** \brief sets \a insideMathTextStyle to \c true if textstyle is set inside math - * \see instructions + * \see instructions() */ static void modifyInMathTextStyleEnvironment(const QString& instructionName, bool &insideMathTextStyle, JKQTMathText *parentMathText, const QStringList ¶ms=QStringList()); protected: @@ -146,13 +144,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextModifiedEnvironmentInstructionNode: pu ModifyEnvironmentFunctor modifier; }; - /** \brief fills instructions + /** \brief defines all implemented instructions in this node * * \note this is the customization point for new instructions! */ - static void fillInstructions(); - /** \brief defines all implemented instructions in this node */ - static QHash instructions; + static const QHash& instructions(); }; diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.cpp index ff9c064a5b..68cdfc9c05 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.cpp +++ b/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.cpp @@ -38,7 +38,6 @@ JKQTMathTextSymbolNode::JKQTMathTextSymbolNode(JKQTMathText* _parent, const QString& name): JKQTMathTextNode(_parent), symbolName(name) { - fillSymbolTables(); } JKQTMathTextSymbolNode::~JKQTMathTextSymbolNode() { @@ -142,7 +141,7 @@ double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTM const NodeSize s=getSymbolSize(painter, currentEv); doDrawBoxes(painter, x, y, s); - const auto fullProps=symbols.value(symbolName, SymbolFullProps()); + const auto fullProps=symbols().value(symbolName, SymbolFullProps()); const GlobalSymbolFlags globalFlags=fullProps.globalFlags; const auto drawProps=fullProps.getDrawingData(currentEv, parentMathText, painter); const QFont f=drawProps.first; @@ -217,7 +216,7 @@ double JKQTMathTextSymbolNode::draw(QPainter& painter, double x, double y, JKQTM bool JKQTMathTextSymbolNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const { bool ok=true; - const auto props=symbols.value(symbolName, SymbolFullProps()); + const auto props=symbols().value(symbolName, SymbolFullProps()); QString s=props.html.symbol; JKQTMathTextEnvironment ev=currentEv; ev.fontSize=ev.fontSize*props.html.fontScalingFactor; @@ -235,7 +234,7 @@ JKQTMathTextSymbolNode::NodeSize JKQTMathTextSymbolNode::getSymbolSize(QPainter { NodeSize s; - const auto fullProps=symbols.value(symbolName, SymbolFullProps()); + const auto fullProps=symbols().value(symbolName, SymbolFullProps()); const GlobalSymbolFlags globalFlags=fullProps.globalFlags; const auto drawProps=fullProps.getDrawingData(currentEv, parentMathText, painter); const QFont f=drawProps.first; @@ -297,39 +296,34 @@ JKQTMathTextSymbolNode::NodeSize JKQTMathTextSymbolNode::getSymbolSize(QPainter bool JKQTMathTextSymbolNode::hasSymbol(const QString &symbolName) { - fillSymbolTables(); - return symbols.contains(symbolName); + return symbols().contains(symbolName); } QStringList JKQTMathTextSymbolNode::getSymbols() { - fillSymbolTables(); - return symbols.keys(); + return symbols().keys(); } bool JKQTMathTextSymbolNode::isSubSuperscriptBelowAboveSymbol(const QString &symbolName) { - fillSymbolTables(); - if (symbols.contains(symbolName)) { - return has(symbols[symbolName].globalFlags, SubSuperscriptBelowAboveSymbol); + if (symbols().contains(symbolName)) { + return has(symbols()[symbolName].globalFlags, SubSuperscriptBelowAboveSymbol); } return false; } bool JKQTMathTextSymbolNode::isExtendedWidthSymbol(const QString &symbolName) { - fillSymbolTables(); - if (symbols.contains(symbolName)) { - return has(symbols[symbolName].globalFlags, ExtendWidthInMathmode) || has(symbols[symbolName].globalFlags, SmallExtendWidthInMathmode); + if (symbols().contains(symbolName)) { + return has(symbols()[symbolName].globalFlags, ExtendWidthInMathmode) || has(symbols()[symbolName].globalFlags, SmallExtendWidthInMathmode); } return false; } int JKQTMathTextSymbolNode::getSymbolLength(const QString &symbolName) { - fillSymbolTables(); - if (symbols.contains(symbolName)) { - return symbols[symbolName].props.value(MTFEUnicode, symbols[symbolName].props.value(MTFEStandard, SymbolProps())).symbol.size(); + if (symbols().contains(symbolName)) { + return symbols()[symbolName].props.value(MTFEUnicode, symbols()[symbolName].props.value(MTFEStandard, SymbolProps())).symbol.size(); } return 0; } @@ -381,6 +375,439 @@ JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::NarrowMathOperat return SymbolFullProps(SymbolProps(op, ItalicOff|BoldOff|HeightIsAscent, 1.0, 0.0)).addGlobalFlags(SmallExtendWidthInMathmode|MakeWhitespaceHalf).addHtml(ophtml, ItalicOff|BoldOff|HeightIsAscent, 1.0, 0.0); } +const QHash &JKQTMathTextSymbolNode::symbols() +{ + static QHash s_symbols=[](){ + QHash symbols; + + /************************************************************************************** + * STANDARD Symbols available in all standard fonts + **************************************************************************************/ + symbols["#"]=SimpleTextSymbol("#", "#"); + symbols["%"]=SimpleTextSymbol("%", "≫"); + symbols["&"]=SimpleTextSymbol("&", "&"); + symbols["("]=SimpleUprightTextSymbol("("); + symbols[")"]=SimpleUprightTextSymbol(")"); + symbols["["]=SimpleUprightTextSymbol("["); + symbols["]"]=SimpleUprightTextSymbol("]"); + symbols["_"]=SimpleTextSymbol("_"); + symbols["{"]=SimpleUprightTextSymbol("{"); + symbols["|"]=SimpleUprightTextSymbol("||", "‖").addUprightUnicode(QChar(0x2016)); + symbols["}"]=SimpleUprightTextSymbol("}"); + symbols["AC"]=UprightSymbolUnicode(QChar(0x223F)).addUprightHtml("∿").addUprightStd("~"); + symbols["circonflex"]=SimpleTextSymbol("^"); + symbols["aa"]=SimpleTextSymbol(QChar(0xE5)); + symbols["ae"]=SimpleTextSymbol(QChar(0xE6)); + symbols["AE"]=SimpleTextSymbol(QChar(0xC6)); + symbols["AA"]=SimpleTextSymbol(QChar(0xC5)); + symbols["oe"]=UnicodeSymbol(QChar(0x153)).addStd("oe").addHtml("œ"); + symbols["OE"]=UnicodeSymbol(QChar(0x152)).addStd("OE").addHtml("Œ"); + symbols["ss"]=SimpleTextSymbol(QChar(0xDF)).addHtml("ß"); + symbols["l"]=UnicodeSymbol(QChar(0x141)).addHtml("ł"); + symbols["L"]=UnicodeSymbol(QChar(0x142)).addHtml("Ł"); + symbols["o"]=SimpleTextSymbol(QChar(0xF8)).addHtml("ø"); + symbols["O"]=SimpleTextSymbol(QChar(0xD8)).addHtml("Ø"); + { auto s=UprightSymbolUnicode(QChar(0x212B)).addUprightStd(QChar(0xC5)); + symbols["Angstrom"]=s; symbols["angstrom"]=s; } + { auto s=UnicodeSymbol(QChar(0x2136)).addHtml("ℶ"); + symbols["Beth"]=s; symbols["Bet"]=s; symbols["beth"]=s; symbols["bet"]=s; } + symbols["Box"]=UprightSymbolUnicode(QChar(0x25A1)); + symbols["DC"]=UnicodeSymbol(QChar(0x2393)).addWinSymbol(QChar(0xBB)).addStd("="); + symbols["EUR"]=UnicodeSymbol(QChar(0x20AC)); + symbols["Im"]=UprightSymbolUnicode(QChar(0x2111)).addHtml("ℑ").addWinSymbol(QChar(0xC1)); + symbols["No"]=UnicodeSymbol(QChar(0x2116)); + { auto s=UprightSymbolUnicode(QChar(0x2126)).addUprightWinSymbol("W").addUprightHtml("Ω"); + symbols["Ohm"]=s; symbols["ohm"]=s; } + symbols["P"]=SimpleTextSymbol(QChar(0xB6)).addHtml("¶"); + symbols["Re"]=UnicodeSymbol(QChar(0x211C)).addHtml("ℜ").addWinSymbol(QChar(0xC2)); + { auto s=SimpleTextSymbol(QChar(0xA7)).addHtml("§"); + symbols["S"]=s; symbols["§"]=s;} + symbols["accurrent"]=UnicodeSymbol(QChar(0x23E6)); + { auto s=UnicodeSymbol(QChar(0x2135)).addHtml("ℵ").addWinSymbol(QChar(0xC0)); + symbols["alef"]=s; symbols["aleph"]=s; symbols["Aleph"]=s; symbols["Alef"]=s; } + symbols["angle"]=UprightSymbolUnicode(QChar(0x2220)).addHtml("∠").addWinSymbol(QChar(0xD0)); + symbols["backslash"]=SimpleTextSymbol("\\"); + symbols["benzene"]=UprightSymbolUnicode(QChar(0x232C)); + symbols["benzenr"]=UprightSymbolUnicode(QChar(0x23E3)); + symbols["blacksquare"]=UprightSymbolUnicode(QChar(0x220E)).addUprightHtml("□"); + { auto s=UprightSymbolUnicode(QChar(0x231E)); + symbols["blcorner"]=s; symbols["llcorner"]=s; } + { auto s=UprightSymbolUnicode(QChar(0x231F)); + symbols["brcorner"]=s; symbols["lrcorner"]=s; } + { auto s=UprightSymbolUnicode(QChar(0x2022)).addUprightHtml("•").addUprightWinSymbol(QChar(0xB7)); + symbols["bullet"]=s; symbols["textbullet"]=s; } + symbols["cdots"]=UprightSymbolUnicode(QChar(0x22EF)).addUprightHtml("···").addUprightStd(QString(3, QChar(0xB7))); + { auto s=UnicodeSymbol(QChar(0x2103)).addUprightStd("°C").addUprightHtml("°C"); + symbols["celsius"]=s; symbols["degC"]=s; symbols["degreeCelsius"]=s; } + symbols["ell"]=UprightSymbolUnicode(QChar(0x2113), "ℓ"); + symbols["wp"]=UprightSymbolUnicode(QChar(0x2118), "℘").addGlobalFlags(SubscriptCorrection); + symbols["mho"]=UprightSymbolUnicode(QChar(0x2127), "℧"); + symbols["lozenge"]=UprightSymbolUnicode(QChar(0x25CA), "◊"); + symbols["cent"]=SimpleTextSymbol(QChar(0xA2), "¢"); + symbols["checkmark"]=UprightSymbolStd(QChar(0x2713)).addUprightHtml("✓"); + symbols["circ"]=UprightSymbolStd(QChar(0x2218)).addUprightHtml("∘").addStd("o", ItalicOff,0.7, -0.25); + symbols["co"]=UprightSymbolUnicode(QChar(0x2105)); + { auto s=SimpleTextSymbol(QChar(0xA9), "©"); + symbols["copyright"]=s; symbols["textcopyright"]=s; symbols["circledC"]=s; } + { auto s=UprightSymbolUnicode(QChar(0x2020)).addUprightHtml("†"); + symbols["dagger"]=s; symbols["dag"]=s; symbols["textdagger"]=s; } + { auto s=UprightSymbolUnicode(QChar(0x2021)).addUprightHtml("‡"); + symbols["ddagger"]=s; symbols["ddag"]=s; symbols["textdaggerdbl"]=s; } + { auto s=UnicodeSymbol(QChar(0x2138)).addHtml("ℸ"); + symbols["dalet"]=s; symbols["Dalet"]=s; symbols["daleth"]=s; symbols["Daleth"]=s; } + symbols["dd"] = SymbolFullProps(SymbolProps("d", Upright|BoldOff), "d", Upright|BoldOff); + symbols["diamond"]=UprightSymbolUnicode(QChar(0x22C4)).addHtml("⋄").addWinSymbol(QChar(0xE0)); + symbols["dollar"]=UnicodeSymbol(QChar(0x0024)); + { auto s=SimpleTextSymbol(QChar(0x24), "$"); + symbols["dollar"]=s; symbols["$"]=s; } + symbols["dprime"]=UnicodeSymbol(QChar(0x2033)).addHtml("″").addStd("''"); + symbols["complement"] = SymbolFullProps(SymbolProps("C", Upright|BoldOff), "C", Upright|BoldOff).addUnicode(QChar(0x2201), Upright|BoldOff); + symbols["ee"] = SymbolFullProps(SymbolProps("e", Upright|BoldOff), "e", Upright|BoldOff); + { auto s=UnicodeSymbol(QChar(0x2026)).addHtml("…").addWinSymbol(QChar(0xBC)).addStd("..."); + symbols["ellipsis"]=s; symbols["dots"]=s; symbols["ldots"]=s; } + { auto s=SimpleTextSymbol(QChar(0x20AC), "€"); + symbols["euro"]=s; symbols["EUR"]=s; } + { auto s=UnicodeSymbol(QChar(0x2109)); + symbols["fahrenheit"]=s; symbols["degF"]=s; } + symbols["female"]=UnicodeSymbol(QChar(0x2640)).addHtml("♀"); + symbols["flq"]=UnicodeSymbol(QChar(0x2039)).addHtml("‹").addStd("<"); + symbols["flqq"]=UnicodeSymbol(QChar(0x00AB)).addHtml("«").addStd(QChar(0xAB)); + //symbols["frown"]=UnicodeSymbol(QChar(0x2322)).addHtml("⌢"); + symbols["frq"]=UnicodeSymbol(QChar(0x203A)).addHtml("›").addStd(">"); + symbols["frqq"]=UnicodeSymbol(QChar(0x00BB)).addHtml("»").addStd(QChar(0xBB)); + { auto s=UnicodeSymbol(QChar(0x2137)).addHtml("ℷ"); + symbols["gimel"]=s; symbols["Gimel"]=s; } + symbols["glq"]=UnicodeSymbol(QChar(0x2018)).addHtml("‘").addStd("'"); + symbols["glqq"]=UnicodeSymbol(QChar(0x201C)).addHtml("“").addStd("\""); + symbols["grq"]=UnicodeSymbol(QChar(0x2019)).addHtml("’").addStd("'"); + symbols["grqq"]=UnicodeSymbol(QChar(0x201D)).addHtml("”").addStd("\""); + symbols["hbar"]=UprightSymbolUnicode(QChar(0x210F)).addUprightHtml("ℏ").addStd("h", ItalicOn|DrawLeftHBar).addGlobalFlags(SubscriptCorrection); + symbols["hexagon"]=UprightSymbolUnicode(QChar(0x2394)); + symbols["ii"] = SymbolFullProps(SymbolProps("i", Upright|BoldOff), "i", Upright|BoldOff); + symbols["infty"]=UprightSymbolUnicode(QChar(0x221E)).addUprightHtml("∞").addUprightWinSymbol(QChar(0xA5)).addUprightStd("8", RotateSymbol90); + symbols["langle"]=UprightSymbolUnicode(QChar(0x2329)).addWinSymbol(QChar(0xE1)); + symbols["lceil"]=UprightSymbolUnicode(QChar(0x2308)).addUprightHtml("⌈").addUprightWinSymbol(QChar(0xE9)); + symbols["lfloor"]=UprightSymbolUnicode(QChar(0x230A)).addUprightHtml("⌊").addUprightWinSymbol(QChar(0xEB)); + symbols["lightning"]=UnicodeSymbol(QChar(0x21AF)); + symbols["male"]=UnicodeSymbol(QChar(0x2642)).addHtml("♂"); + symbols["measuredangle"]=UprightSymbolUnicode(QChar(0x2221)).addUprightHtml("∡"); + symbols["micro"] = SimpleTextSymbol(QChar(0xB5), "µ"); + symbols["ohm"]=UprightSymbolUnicode(QChar(0x2126)).addUprightHtml("Ω").addUprightWinSymbol(QChar(0x57)); + symbols["partial"]=UprightSymbolUnicode(QChar(0x2202)).addUprightHtml("∂").addUprightWinSymbol(QChar(0xB6)); + { auto s=UnicodeSymbol(QChar(0x2030)).addHtml("‰"); + symbols["perthousand"]=s; symbols["permil"]=s; } + symbols["pound"]=SimpleTextSymbol(QChar(0xA3), "£"); + symbols["pound"]=UnicodeSymbol(QChar(0x00A3)); + symbols["prime"]=UnicodeSymbol(QChar(0x2032)).addHtml("′").addStd("'"); + symbols["arcminute"]=UnicodeSymbol(QChar(0x2032)).addHtml("′").addStd("'"); + symbols["arcsecond"]=UnicodeSymbol(QChar(0x2033)).addHtml("&dprime;").addStd("'"); + symbols["rangle"]=UprightSymbolUnicode(QChar(0x232A)).addUprightWinSymbol(QChar(0xF1)); + symbols["rceil"]=UprightSymbolUnicode(QChar(0x2309)).addUprightHtml("⌉").addUprightWinSymbol(QChar(0xF9)); + { auto s=SimpleTextSymbol(QChar(0xAE), "®"); + symbols["registered"]=s; symbols["textregistered"]=s; symbols["circledR"]=s; } + symbols["rfloor"]=UprightSymbolUnicode(QChar(0x230B)).addUprightHtml("⌋").addUprightWinSymbol(QChar(0xFB)); + symbols["rightangle"]=UprightSymbolUnicode(QChar(0x221F)).addUprightHtml("∟"); + //symbols["smile"]=UprightSymbolUnicode(QChar(0x2323)).addUprightHtml("⌣"); + symbols["sphericalangle"]=UprightSymbolUnicode(QChar(0x2222)).addUprightHtml("∢"); + symbols["star"]=UprightSymbolUnicode(QChar(0x22C6)); + symbols["tcohm"]=UnicodeSymbol(QChar(0x2126)); + { auto s=UnicodeSymbol(QChar(0x2014), "⹀"); + symbols["dblhyphen"]=s; symbols["textdblhyphen"]=s; symbols["textdblhyphenchar"]=s; } + { auto s=UnicodeSymbol(QChar(0x2014), "—"); + symbols["---"]=s; symbols["textemdash"]=s; symbols["emdash"]=s; } + { auto s=UnicodeSymbol(QChar(0x2013), "–"); + symbols["--"]=s; symbols["textendash"]=s; symbols["endash"]=s; } + { auto s=SimpleTextSymbol("-"); + symbols["texthyphen"]=s; symbols["hyphen"]=s; } + symbols["textbar"]=SimpleTextSymbol("|", "|"); + { auto s=SimpleTextSymbol(QChar(0xB0), "°"); + symbols["textdegree"]=s; symbols["degree"] = s; } + symbols["textgreater"]=SimpleTextSymbol(">", ">"); + symbols["textless"]=SimpleTextSymbol("<", "<"); + symbols["textquestiondown"]=SimpleTextSymbol(QChar(0xBF), "¿"); + symbols["textexclamdown"]=SimpleTextSymbol(QChar(0xA1), "¡"); + { auto s=UnicodeSymbol(QChar(0x231C)); + symbols["tlcorner"]=s; symbols["ulcorner"]=s; } + symbols["trademark"]=UnicodeSymbol(QChar(0x2122)).addHtml("™").addWinSymbol(QChar(0xD4)).addStd("(TM)"); + symbols["trapezium"]=UnicodeSymbol(QChar(0x23E2)).addHtml("⏢"); + { auto s=UprightSymbolUnicode(QChar(0x231D)); + symbols["trcorner"]=s; symbols["urcorner"]=s; } + symbols["trprime"]=UnicodeSymbol(QChar(0x2034)).addHtml("‴").addStd("'''"); + symbols["varcarriagereturn"]=UnicodeSymbol(QChar(0x23CE)).addWinSymbol(QChar(0xBF)); + symbols["varhexagonlrbonds"]=UnicodeSymbol(QChar(0x232C)); + symbols["yen"]=SimpleTextSymbol(QChar(0xA5), "¥"); + + + + + + /************************************************************************************** + * STANDARD MathOperator Strings + **************************************************************************************/ + symbols["Pr"] = NarrowMathOperatorText("Pr"); + symbols["acos"] = NarrowMathOperatorText("acos"); + symbols["arccos"] = NarrowMathOperatorText("arccos"); + symbols["arcsin"] = NarrowMathOperatorText("arcsin"); + symbols["arctan"] = NarrowMathOperatorText("arctan"); + symbols["arg"] = NarrowMathOperatorText("arg").addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["argmax"] = NarrowMathOperatorText("arg max", "arg max").addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["argmin"] = NarrowMathOperatorText("arg min", "arg min").addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["asin"] = NarrowMathOperatorText("asin"); + symbols["atan"] = NarrowMathOperatorText("atan"); + symbols["cos"] = NarrowMathOperatorText("cos"); + symbols["cosh"] = NarrowMathOperatorText("cosh"); + symbols["cot"] = NarrowMathOperatorText("cot"); + symbols["coth"] = NarrowMathOperatorText("coth"); + symbols["coth"] = NarrowMathOperatorText("coth"); + symbols["deg"] = NarrowMathOperatorText("deg"); + symbols["det"] = NarrowMathOperatorText("det"); + symbols["dim"] = NarrowMathOperatorText("dim"); + symbols["exp"] = NarrowMathOperatorText("exp"); + symbols["gcd"] = NarrowMathOperatorText("gcd"); + symbols["hom"] = NarrowMathOperatorText("hom"); + symbols["ker"] = NarrowMathOperatorText("ker"); + symbols["lb"] = NarrowMathOperatorText("lb"); + symbols["ld"] = NarrowMathOperatorText("ld"); + symbols["lim"] = NarrowMathOperatorText("lim").addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["liminf"] = NarrowMathOperatorText("lim inf", "lim inf").addGlobalFlags(SubSuperscriptBelowAboveSymbol).addGlobalFlags(SubscriptCorrection); + symbols["limsup"] = NarrowMathOperatorText("lim sup", "lim sup").addGlobalFlags(SubSuperscriptBelowAboveSymbol).addGlobalFlags(SubscriptCorrection); + symbols["ln"] = NarrowMathOperatorText("ln"); + symbols["log"] = NarrowMathOperatorText("log"); + symbols["max"] = NarrowMathOperatorText("max"); + symbols["median"] = NarrowMathOperatorText("median"); + symbols["min"] = NarrowMathOperatorText("min"); + symbols["mod"] = NarrowMathOperatorText("mod"); + symbols["sec"] = NarrowMathOperatorText("sec"); + symbols["sgn"] = NarrowMathOperatorText("sgn"); + symbols["sign"] = NarrowMathOperatorText("sign"); + symbols["sin"] = NarrowMathOperatorText("sin"); + symbols["sinh"] = NarrowMathOperatorText("sinh"); + symbols["tan"] = NarrowMathOperatorText("tan"); + symbols["tanh"] = NarrowMathOperatorText("tanh"); + + /************************************************************************************** + * STANDARD MathOperator Symbols + **************************************************************************************/ + { auto s=MathOperatorSymbolUnicode(QChar(0x2217)).addMathOperatorStd("*").addMathOperatorHtml("*"); + symbols["*"]=s; symbols["ast"]=s; symbols["asterisk"]=s; } + symbols["/"]=NarrowMathOperatorSymbolStd("/"); + symbols["+"]=MathOperatorSymbolUnicode(QChar(0x2B)).addMathOperatorHtml("+").addMathOperatorStd("+"); + symbols["-"]=MathOperatorSymbolUnicode(QChar(0x2212)).addMathOperatorHtml("-").addMathOperatorStd("-"); + symbols["<"]=MathOperatorSymbol("<", "<"); + symbols["="]=MathOperatorSymbol("="); + symbols[">"]=MathOperatorSymbol(">", ">"); + symbols["Downarrow"]=UprightSymbolUnicode(QChar(0x21D3)).addUprightHtml("⇓").addUprightWinSymbol(QChar(0xDF)); + symbols["Leftarrow"]=UprightSymbolUnicode(QChar(0x21D0)).addUprightHtml("⇐").addUprightWinSymbol(QChar(0xDC)); + symbols["Rightarrow"]=UprightSymbolUnicode(QChar(0x21D2)).addUprightHtml("⇒").addUprightWinSymbol(QChar(0xDE)); + symbols["Uparrow"]=UprightSymbolUnicode(QChar(0x21D1)).addUprightHtml("⇑").addUprightWinSymbol(QChar(0xDD)); + symbols["Updownarrow"]=UprightSymbolUnicode(QChar(0x21D5)).addUprightHtml("⇕"); + symbols["approx"]=MathOperatorSymbolUnicode(QChar(0x2248)).addMathOperatorHtml("≈").addMathOperatorWinSymbol(QChar(0xBB)); + symbols["bbC"]=UnicodeSymbol(QChar(0x2102)); + symbols["bbH"]=UnicodeSymbol(QChar(0x210D)); + symbols["bbN"]=UnicodeSymbol(QChar(0x2115)); + symbols["bbP"]=UnicodeSymbol(QChar(0x2119)); + symbols["bbQ"]=UnicodeSymbol(QChar(0x211A)); + symbols["bbR"]=UnicodeSymbol(QChar(0x211D)); + symbols["bbZ"]=UnicodeSymbol(QChar(0x2124)); + symbols["because"]=MathOperatorSymbolUnicode(QChar(0x2235)).addMathOperatorHtml("∵"); + symbols["bigcap"]=NarrowMathOperatorSymbolUnicode(QChar(0x22C2)).addMathOperatorHtml("⋂").addMathOperatorWinSymbol(QChar(0xC7), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["bigcup"]=NarrowMathOperatorSymbolUnicode(QChar(0x22C3)).addMathOperatorHtml("⋃").addMathOperatorWinSymbol(QChar(0xC8), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); + { auto s=NarrowMathOperatorSymbolUnicode(QChar(0x22C0)).addMathOperatorHtml("⋀").addMathOperatorWinSymbol(QChar(0xD9), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["bigwedge"]=s; symbols["bighat"]=s; } + symbols["bigvee"]=NarrowMathOperatorSymbolUnicode(QChar(0x22C1)).addMathOperatorHtml("⋁").addMathOperatorWinSymbol(QChar(0xDA), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["bigotimes"]=NarrowMathOperatorSymbolUnicode(QChar(0x2A02)).addMathOperatorHtml("⨂").addMathOperatorWinSymbol(QChar(0xC4), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["bigoplus"]=NarrowMathOperatorSymbolUnicode(QChar(0x2A01)).addMathOperatorHtml("⨁").addMathOperatorWinSymbol(QChar(0xC5), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["bigodot"]=NarrowMathOperatorSymbolUnicode(QChar(0x2A00)).addMathOperatorHtml("⨀").addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["biguplus"]=NarrowMathOperatorSymbolUnicode(QChar(0x2A04)).addMathOperatorHtml("⨄").addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["bigsqcup"]=NarrowMathOperatorSymbolUnicode(QChar(0x2A06)).addMathOperatorHtml("⨆").addGlobalFlags(SubSuperscriptBelowAboveSymbol); + { auto s=MathOperatorSymbolUnicode(QChar(0x22A5)).addMathOperatorHtml("⊥"); + symbols["bot"]=s; symbols["perp"]=s; } + { auto s=MathOperatorSymbolUnicode(QChar(0x2229)).addMathOperatorHtml("∩").addMathOperatorWinSymbol(QChar(0xC7)); + symbols["cap"]=s; symbols["land"]=s; } + symbols["cdot"]=MathOperatorSymbol(QChar(0xB7)).addMathOperatorHtml("·").addMathOperatorWinSymbol(QChar(0xD7)); + symbols["cong"]=MathOperatorSymbolUnicode(QChar(0x2245)).addMathOperatorHtml("≅"); + symbols["coprod"]=NarrowMathOperatorSymbolUnicode(QChar(0x2210)).addMathOperatorHtml("∐").addWinSymbol(QChar(0xD5), ItalicOff|BoldOff|FlipSymbolUpDown, 1.8, 0.1).addGlobalFlags(SubSuperscriptBelowAboveSymbol); + { auto s=MathOperatorSymbolUnicode(QChar(0x222A)).addMathOperatorHtml("∪").addMathOperatorWinSymbol(QChar(0xC8)); + symbols["cup"]=s; symbols["lor"]=s; } + symbols["ddots"]=UprightSymbolUnicode(QChar(0x22F1)).addMathOperatorHtml("⋱"); + symbols["div"]=MathOperatorSymbolUnicode(QChar(0x00F7)).addMathOperatorHtml("÷").addMathOperatorWinSymbol(QChar(0xB8)); + symbols["downarrow"]=UprightSymbolUnicode(QChar(0x2193)).addUprightHtml("↓").addUprightWinSymbol(QChar(0xAF)); + symbols["downharpoonleft"]=UprightSymbolUnicode(QChar(0x21C3)).addUprightHtml("⇃"); + symbols["downharpoonright"]=UprightSymbolUnicode(QChar(0x21C2)).addUprightHtml("⇂"); + { auto s=MathOperatorSymbolUnicode(QChar(0x2205)).addMathOperatorHtml("∅").addMathOperatorWinSymbol(QChar(0xC6)).addStd("0", BoldOff|ItalicOff|DrawSlash); + symbols["emptyset"]=s; symbols["varnothing"]=s; } + symbols["equiv"]=MathOperatorSymbolUnicode(QChar(0x2261)).addMathOperatorHtml("≡").addMathOperatorWinSymbol(QChar(0xBA)); + symbols["exists"]=NarrowMathOperatorSymbolUnicode(QChar(0x2203)).addMathOperatorHtml("∃").addMathOperatorWinSymbol(QChar(0x24)).addStd("E", ItalicOff|BoldOff|FlipSymbolLeftRight); + symbols["forall"]=NarrowMathOperatorSymbolUnicode(QChar(0x2200)).addMathOperatorHtml("∀").addMathOperatorWinSymbol(QChar(0x22)).addStd("A", ItalicOff|BoldOff|FlipSymbolUpDown).addGlobalFlags(SubscriptCorrection); + { auto s=MathOperatorSymbolUnicode(QChar(0x2265)).addMathOperatorHtml("≥").addMathOperatorWinSymbol(QChar(0xB3)); + symbols["geq"]=s; symbols["ge"]=s; } + symbols["geqq"]=MathOperatorSymbolUnicode(QChar(0x2267)).addMathOperatorHtml("≧"); + symbols["gg"]=MathOperatorSymbolUnicode(QChar(0x226B)).addMathOperatorHtml("≫").addMathOperatorStd(">>"); + symbols["iddots"]=UprightSymbolUnicode(QChar(0x22F0)).addMathOperatorHtml("⋰"); + { auto s=UprightSymbolUnicode(QChar(0x21D4)).addUprightHtml("⇔").addUprightWinSymbol(QChar(0xDB)); + symbols["iff"]=s; symbols["Leftrightarrow"]=s; } + symbols["iiint"]=NarrowMathOperatorSymbolUnicode(QChar(0x222D)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∭").addMathOperatorWinSymbol(QString(3, QChar(0xF2)), 1.8, 0.1); + symbols["iint"]=NarrowMathOperatorSymbolUnicode(QChar(0x222C)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∬").addMathOperatorWinSymbol(QString(2, QChar(0xF2)), 1.8, 0.1); + symbols["in"]=MathOperatorSymbolUnicode(QChar(0x2208)).addMathOperatorHtml("∈").addMathOperatorWinSymbol(QChar(0xCE)); + symbols["int"]=NarrowMathOperatorSymbolUnicode(QChar(0x222B)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∫").addMathOperatorWinSymbol(QChar(0xF2), 1.8, 0.1); + symbols["leftarrow"]=UprightSymbolUnicode(QChar(0x2190)).addUprightHtml("←").addUprightWinSymbol(QChar(0xAC)); + symbols["longleftarrow"]=UprightSymbolUnicode(QChar(0x27F5)).addUprightHtml("⟵"); + symbols["longrightarrow"]=UprightSymbolUnicode(QChar(0x27F6)).addUprightHtml("⟶"); + symbols["longleftrightarrow"]=UprightSymbolUnicode(QChar(0x27F7)).addUprightHtml("⟷"); + symbols["Longleftarrow"]=UprightSymbolUnicode(QChar(0x27F8)).addUprightHtml("⟸"); + symbols["Longrightarrow"]=UprightSymbolUnicode(QChar(0x27F9)).addUprightHtml("⟹"); + symbols["Longleftrightarrow"]=UprightSymbolUnicode(QChar(0x27FA)).addUprightHtml("⟺"); + symbols["leftharpoondown"]=UprightSymbolUnicode(QChar(0x21BD)).addUprightHtml("↽"); + symbols["leftharpoonup"]=UprightSymbolUnicode(QChar(0x21BC)).addUprightHtml("↼"); + symbols["leftrightarrow"]=UprightSymbolUnicode(QChar(0x2194)).addUprightHtml("↔").addUprightWinSymbol(QChar(0xAB)); + symbols["leftrightharpoon"]=UprightSymbolUnicode(QChar(0x21CB)).addUprightHtml("⇋"); + { auto s=MathOperatorSymbolUnicode(QChar(0x2264)).addMathOperatorHtml("≤").addMathOperatorWinSymbol(QChar(0xA3)); + symbols["leq"]=s; symbols["le"]=s; } + symbols["leqq"]=MathOperatorSymbolUnicode(QChar(0x2266)).addMathOperatorHtml("≦"); + symbols["ll"]=MathOperatorSymbolUnicode(QChar(0x226A)).addMathOperatorHtml("≪").addMathOperatorStd("<<"); + symbols["lnot"]=MathOperatorSymbolUnicode(QChar(0xAC)).addMathOperatorWinSymbol(QChar(0xD8)).addMathOperatorHtml("¬"); + symbols["mapimage"]=MathOperatorSymbolUnicode(QChar(0x22B7)).addMathOperatorHtml("⊷"); + symbols["maporiginal"]=MathOperatorSymbolUnicode(QChar(0x22B6)).addMathOperatorHtml("⊶"); + symbols["mapsto"]=MathOperatorSymbolUnicode(QChar(0x21A6)).addMathOperatorHtml("↦"); + symbols["mid"]=MathOperatorSymbolUnicode(QChar(0x2223)).addMathOperatorHtml("∣").addMathOperatorWinSymbol(QChar(0xBD)).addMathOperatorStd("|"); + symbols["mp"]=MathOperatorSymbolUnicode(QChar(0x2213)).addMathOperatorHtml("∓").addWinSymbol(QChar(0xB1),ItalicOff|BoldOff|FlipSymbolUpDown).addStd(QChar(0xB1),ItalicOff|BoldOff|FlipSymbolUpDown); + symbols["multimap"]=MathOperatorSymbolUnicode(QChar(0x22B8)).addMathOperatorHtml("⊸"); + symbols["nabla"]=NarrowMathOperatorSymbolUnicode(QChar(0x2207)).addMathOperatorHtml("∇").addMathOperatorWinSymbol(QChar(0xD1)).addGlobalFlags(IntLikeSymbolCorrection); + symbols["ne"]=NarrowMathOperatorSymbolUnicode(QChar(0x2260)).addMathOperatorHtml("≠").addMathOperatorWinSymbol(QChar(0xB9)); + symbols["nearrow"]=UprightSymbolUnicode(QChar(0x2197)).addUprightHtml("↗"); + { auto s=MathOperatorSymbolUnicode(QChar(0x00AC)).addMathOperatorHtml("¬").addMathOperatorWinSymbol(QChar(0xD8)); + symbols["neg"]=s; symbols["lnot"]=s; } + symbols["neq"]=MathOperatorSymbolUnicode(QChar(0x2260)).addMathOperatorHtml("≠").addMathOperatorWinSymbol(QChar(0xB9)).addStd("=", ItalicOff|BoldOff|DrawSlash); + symbols["nexists"]=NarrowMathOperatorSymbolUnicode(QChar(0x2204)).addMathOperatorHtml("∄").addStd("E", ItalicOff|BoldOff|FlipSymbolLeftRight|DrawSlash).addMathOperatorWinSymbol(QChar(0x24), ItalicOff|BoldOff|DrawSlash); + symbols["ni"]=NarrowMathOperatorSymbolUnicode(QChar(0x220B)).addMathOperatorHtml("∋").addMathOperatorWinSymbol(QChar(0xCE), ItalicOff|BoldOff|FlipSymbolLeftRight); + symbols["nmid"]=NarrowMathOperatorSymbolUnicode(QChar(0x2224)).addMathOperatorHtml("∤"); + symbols["notin"]=NarrowMathOperatorSymbolUnicode(QChar(0x2209)).addMathOperatorHtml("∉").addMathOperatorWinSymbol(QChar(0xCF)); + symbols["notni"]=NarrowMathOperatorSymbolUnicode(QChar(0x220C)).addMathOperatorHtml("∌"); + symbols["nparallel"]=MathOperatorSymbolUnicode(QChar(0x2226)).addMathOperatorHtml("∦"); + symbols["nwarrow"]=UprightSymbolUnicode(QChar(0x2196)).addUprightHtml("↖"); + symbols["odot"]=MathOperatorSymbolUnicode(QChar(0x2299)).addMathOperatorHtml("⊙"); + symbols["oiiint"]=NarrowMathOperatorSymbolUnicode(QChar(0x2230)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∰"); + symbols["oiint"]=NarrowMathOperatorSymbolUnicode(QChar(0x222F)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∯"); + symbols["oint"]=NarrowMathOperatorSymbolUnicode(QChar(0x222E)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∮"); + symbols["ominus"]=MathOperatorSymbolUnicode(QChar(0x2296)).addMathOperatorHtml("⊖"); + symbols["oplus"]=MathOperatorSymbolUnicode(QChar(0x2295)).addMathOperatorHtml("⊕").addMathOperatorWinSymbol(QChar(0xC5)); + symbols["oslash"]=MathOperatorSymbolUnicode(QChar(0x2298)).addMathOperatorHtml("⊘"); + symbols["otimes"]=MathOperatorSymbolUnicode(QChar(0x2297)).addMathOperatorHtml("⊗").addMathOperatorWinSymbol(QChar(0xC4)); + symbols["parallel"]=NarrowMathOperatorSymbolUnicode(QChar(0x2225)).addMathOperatorHtml("∥").addMathOperatorStd("||"); + symbols["pm"] = MathOperatorSymbol(QChar(0xB1), "±").addMathOperatorWinSymbol(QChar(0xB1)); + symbols["prec"]=MathOperatorSymbolUnicode(QChar(0x227A)).addMathOperatorHtml("≺"); + symbols["prod"]=NarrowMathOperatorSymbolUnicode(QChar(0x220F)).addMathOperatorWinSymbol(QChar(0xD5), 1.8, 0.1).addMathOperatorHtml("∏").addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["propto"]=MathOperatorSymbolUnicode(QChar(0x221D)).addMathOperatorWinSymbol(QChar(0xB5)).addMathOperatorHtml("∝"); + symbols["rightharpoondown"]=UprightSymbolUnicode(QChar(0x21C1)).addUprightHtml("⇁"); + symbols["rightharpoonup"]=UprightSymbolUnicode(QChar(0x21C0)).addUprightHtml("⇀"); + symbols["rightleftharpoon"]=UprightSymbolUnicode(QChar(0x21CC)).addUprightHtml("⇌"); + symbols["searrow"]=UprightSymbolUnicode(QChar(0x2198)).addUprightHtml("↘"); + symbols["setminus"]=MathOperatorSymbolUnicode(QChar(0x2216)).addMathOperatorHtml("∖"); + { auto s=MathOperatorSymbolUnicode(QChar(0x223C)).addMathOperatorHtml("˜").addMathOperatorStd("~"); + symbols["~"]=s; symbols["sim"]=s; } + symbols["simeq"]=MathOperatorSymbolUnicode(QChar(0x2243)).addMathOperatorHtml("≃"); + symbols["sqcap"]=MathOperatorSymbolUnicode(QChar(0x2293)).addMathOperatorHtml("⊓"); + symbols["sqcup"]=MathOperatorSymbolUnicode(QChar(0x2294)).addMathOperatorHtml("⊔"); + symbols["square"]=MathOperatorSymbolUnicode(QChar(0x25A1)); + symbols["subset"]=MathOperatorSymbolUnicode(QChar(0x2282)).addMathOperatorHtml("⊂").addMathOperatorWinSymbol(QChar(0xCC)); + symbols["subseteq"]=MathOperatorSymbolUnicode(QChar(0x2286)).addMathOperatorHtml("⊆").addMathOperatorWinSymbol(QChar(0xCD)); + symbols["subsetnot"]=MathOperatorSymbolUnicode(QChar(0x2284)).addMathOperatorHtml("⊄").addMathOperatorWinSymbol(QChar(0xCB)); + symbols["succ"]=MathOperatorSymbolUnicode(QChar(0x227B)).addMathOperatorHtml("≻"); + symbols["sum"]=NarrowMathOperatorSymbolUnicode(QChar(0x2211)).addMathOperatorWinSymbol(QChar(0xE5), 1.8, 0.1).addMathOperatorHtml("∑").addGlobalFlags(SubSuperscriptBelowAboveSymbol); + symbols["supset"]=MathOperatorSymbolUnicode(QChar(0x2283)).addMathOperatorHtml("⊃").addMathOperatorWinSymbol(QChar(0xC9)); + symbols["supseteq"]=MathOperatorSymbolUnicode(QChar(0x2287)).addMathOperatorHtml("⊇").addMathOperatorWinSymbol(QChar(0xCA)); + symbols["supsetnot"]=MathOperatorSymbolUnicode(QChar(0x2285)).addMathOperatorHtml("⊅"); + symbols["swarrow"]=UprightSymbolUnicode(QChar(0x2199)).addUprightHtml("↙"); + symbols["therefore"]=MathOperatorSymbolUnicode(QChar(0x2234)).addMathOperatorHtml("∴").addMathOperatorWinSymbol(QChar(0x5C)); + symbols["times"] = MathOperatorSymbol(QChar(0xD7), "×").addMathOperatorWinSymbol(QChar(0xB4)); + { auto s=UprightSymbolUnicode(QChar(0x2192)).addUprightHtml("→").addUprightWinSymbol(QChar(0xAE)); + symbols["to"]=s; symbols["rightarrow"]=s; } + symbols["top"]=MathOperatorSymbolUnicode(QChar(0x22A4)).addMathOperatorHtml("⊤").addMathOperatorWinSymbol(QChar(0x5E)).addUprightStd("T"); + symbols["triangle"]=NarrowMathOperatorSymbolUnicode(QChar(0x2206)); + symbols["uparrow"]=UprightSymbolUnicode(QChar(0x2191)).addUprightHtml("↑").addUprightWinSymbol(QChar(0xAD)); + symbols["updownarrow"]=UprightSymbolUnicode(QChar(0x2195)).addUprightHtml("↕"); + symbols["upharpoonleft"]=UprightSymbolUnicode(QChar(0x21BF)).addUprightHtml("↿"); + symbols["upharpoonright"]=UprightSymbolUnicode(QChar(0x21BE)).addUprightHtml("↾"); + symbols["vartriangleleft"]=NarrowMathOperatorSymbolUnicode(QChar(0x22B2)).addMathOperatorHtml("⊲"); + symbols["vdots"]=UprightSymbolUnicode(QChar(0x22EE)).addMathOperatorHtml("⋮"); + symbols["vee"]=MathOperatorSymbolUnicode(QChar(0x2228)).addMathOperatorHtml("∨").addMathOperatorWinSymbol(QChar(0xDA)); + symbols["vdash"]=MathOperatorSymbolUnicode(QChar(0x22A2)).addMathOperatorHtml("⊢"); + symbols["dashv"]=MathOperatorSymbolUnicode(QChar(0x22A3)).addMathOperatorHtml("⊣"); + symbols["vDash"]=MathOperatorSymbolUnicode(QChar(0x22A8)).addMathOperatorHtml("⊨"); + symbols["nvdash"]=MathOperatorSymbolUnicode(QChar(0x22AC)).addMathOperatorHtml("⊬"); + symbols["Vdash"]=MathOperatorSymbolUnicode(QChar(0x22A9)).addMathOperatorHtml("⊩"); + symbols["models"]=MathOperatorSymbolUnicode(QChar(0x22A7)).addMathOperatorHtml("⊧"); + symbols["wedge"]=MathOperatorSymbolUnicode(QChar(0x2227)).addMathOperatorHtml("∧").addMathOperatorWinSymbol(QChar(0xD9)); + + + + /************************************************************************************** + * GREEK letters + **************************************************************************************/ + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "alpha", "a", QChar(0x3B1), "α"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "beta", "b", QChar(0x3B2), "β"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "gamma", "g", QChar(0x3B3), "γ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "delta", "d", QChar(0x3B4), "δ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "epsilon", "e", QChar(0x3F5), "ϵ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "varepsilon", "e", QChar(0x3B5), "ε"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "zeta", "z", QChar(0x3B6),"ζ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "eta", "h", QChar(0x3B7),"η"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "theta", "q", QChar(0x3B8),"θ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "vartheta", "J", QChar(0x3D1),"ϑ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "iota", "i", QChar(0x3B9),"ι"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "kappa", "k", QChar(0x3BA),"κ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "lambda", "l", QChar(0x3BB),"λ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "mu", "m", QChar(0x3BC),"μ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "nu", "n", QChar(0x3BD),"ν"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "xi", "x", QChar(0x3BE),"ξ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "pi", "p", QChar(0x3C0),"π"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "varpi", "v", QChar(0x3D6),"ϖ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "rho", "r", QChar(0x3C1),"ρ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "varrho", "r", QChar(0x3F1),"ϱ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "sigma", "s", QChar(0x3C3),"σ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "varsigma", "V", QChar(0x3C2),"ς"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "tau", "t", QChar(0x3C4),"τ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "upsilon", "u", QChar(0x3C5),"υ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "phi", "f", QChar(0x3C5),"ϕ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "varphi", "j", QChar(0x3D6),"φ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "chi", "c", QChar(0x3C7),"χ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "psi", "y", QChar(0x3C8),"ψ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "omega", "w", QChar(0x3C9),"ω"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Gamma", "G", QChar(0x3A3),"Γ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Delta", "D", QChar(0x394),"Δ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Theta", "Q", QChar(0x398),"Θ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Lambda", "L", QChar(0x39B),"Λ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Omega", "W", QChar(0x3A9),"Ω"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Xi", "X", QChar(0x39E),"Ξ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Pi", "P", QChar(0x3A0),"Π"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Sigma", "S", QChar(0x3A3),"Σ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Upsilon", "U", QChar(0x3C6),"Υ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Phi", "F", QChar(0x3A6),"Φ"); + addGreekLetterVariants_WinSymbol_Unicode_Html(symbols, "Psi", "Y", QChar(0x3A8),"Ψ"); + + + /************************************************************************************** + * SYMBOLS from special fonts + **************************************************************************************/ + #if (QT_VERSION& symbols, const QString &baseInstructionName, const QString &letterWinSymbol, const QString &letterUnicode, const QString &html) { symbols[baseInstructionName]=MathGreekLetter_WinSymbol_Unicode_Html(letterWinSymbol, letterUnicode, html).addGlobalFlags(SubscriptCorrection); symbols["text"+baseInstructionName]=AsOutsiudeGreekLetter_WinSymbol_Unicode_Html(letterWinSymbol, letterUnicode, html); @@ -488,437 +915,7 @@ JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SimpleUprightTex -QHash JKQTMathTextSymbolNode::symbols=QHash(); -void JKQTMathTextSymbolNode::fillSymbolTables() -{ - static std::mutex sMutex; - std::lock_guard lock(sMutex); - if (symbols.size()>0) return; // tables have already been filled! So nothing to do here - - /************************************************************************************** - * STANDARD Symbols available in all standard fonts - **************************************************************************************/ - symbols["#"]=SimpleTextSymbol("#", "#"); - symbols["%"]=SimpleTextSymbol("%", "≫"); - symbols["&"]=SimpleTextSymbol("&", "&"); - symbols["("]=SimpleUprightTextSymbol("("); - symbols[")"]=SimpleUprightTextSymbol(")"); - symbols["["]=SimpleUprightTextSymbol("["); - symbols["]"]=SimpleUprightTextSymbol("]"); - symbols["_"]=SimpleTextSymbol("_"); - symbols["{"]=SimpleUprightTextSymbol("{"); - symbols["|"]=SimpleUprightTextSymbol("||", "‖").addUprightUnicode(QChar(0x2016)); - symbols["}"]=SimpleUprightTextSymbol("}"); - symbols["AC"]=UprightSymbolUnicode(QChar(0x223F)).addUprightHtml("∿").addUprightStd("~"); - symbols["circonflex"]=SimpleTextSymbol("^"); - symbols["aa"]=SimpleTextSymbol(QChar(0xE5)); - symbols["ae"]=SimpleTextSymbol(QChar(0xE6)); - symbols["AE"]=SimpleTextSymbol(QChar(0xC6)); - symbols["AA"]=SimpleTextSymbol(QChar(0xC5)); - symbols["oe"]=UnicodeSymbol(QChar(0x153)).addStd("oe").addHtml("œ"); - symbols["OE"]=UnicodeSymbol(QChar(0x152)).addStd("OE").addHtml("Œ"); - symbols["ss"]=SimpleTextSymbol(QChar(0xDF)).addHtml("ß"); - symbols["l"]=UnicodeSymbol(QChar(0x141)).addHtml("ł"); - symbols["L"]=UnicodeSymbol(QChar(0x142)).addHtml("Ł"); - symbols["o"]=SimpleTextSymbol(QChar(0xF8)).addHtml("ø"); - symbols["O"]=SimpleTextSymbol(QChar(0xD8)).addHtml("Ø"); - { auto s=UprightSymbolUnicode(QChar(0x212B)).addUprightStd(QChar(0xC5)); - symbols["Angstrom"]=s; symbols["angstrom"]=s; } - { auto s=UnicodeSymbol(QChar(0x2136)).addHtml("ℶ"); - symbols["Beth"]=s; symbols["Bet"]=s; symbols["beth"]=s; symbols["bet"]=s; } - symbols["Box"]=UprightSymbolUnicode(QChar(0x25A1)); - symbols["DC"]=UnicodeSymbol(QChar(0x2393)).addWinSymbol(QChar(0xBB)).addStd("="); - symbols["EUR"]=UnicodeSymbol(QChar(0x20AC)); - symbols["Im"]=UprightSymbolUnicode(QChar(0x2111)).addHtml("ℑ").addWinSymbol(QChar(0xC1)); - symbols["No"]=UnicodeSymbol(QChar(0x2116)); - { auto s=UprightSymbolUnicode(QChar(0x2126)).addUprightWinSymbol("W").addUprightHtml("Ω"); - symbols["Ohm"]=s; symbols["ohm"]=s; } - symbols["P"]=SimpleTextSymbol(QChar(0xB6)).addHtml("¶"); - symbols["Re"]=UnicodeSymbol(QChar(0x211C)).addHtml("ℜ").addWinSymbol(QChar(0xC2)); - { auto s=SimpleTextSymbol(QChar(0xA7)).addHtml("§"); - symbols["S"]=s; symbols["§"]=s;} - symbols["accurrent"]=UnicodeSymbol(QChar(0x23E6)); - { auto s=UnicodeSymbol(QChar(0x2135)).addHtml("ℵ").addWinSymbol(QChar(0xC0)); - symbols["alef"]=s; symbols["aleph"]=s; symbols["Aleph"]=s; symbols["Alef"]=s; } - symbols["angle"]=UprightSymbolUnicode(QChar(0x2220)).addHtml("∠").addWinSymbol(QChar(0xD0)); - symbols["backslash"]=SimpleTextSymbol("\\"); - symbols["benzene"]=UprightSymbolUnicode(QChar(0x232C)); - symbols["benzenr"]=UprightSymbolUnicode(QChar(0x23E3)); - symbols["blacksquare"]=UprightSymbolUnicode(QChar(0x220E)).addUprightHtml("□"); - { auto s=UprightSymbolUnicode(QChar(0x231E)); - symbols["blcorner"]=s; symbols["llcorner"]=s; } - { auto s=UprightSymbolUnicode(QChar(0x231F)); - symbols["brcorner"]=s; symbols["lrcorner"]=s; } - { auto s=UprightSymbolUnicode(QChar(0x2022)).addUprightHtml("•").addUprightWinSymbol(QChar(0xB7)); - symbols["bullet"]=s; symbols["textbullet"]=s; } - symbols["cdots"]=UprightSymbolUnicode(QChar(0x22EF)).addUprightHtml("···").addUprightStd(QString(3, QChar(0xB7))); - { auto s=UnicodeSymbol(QChar(0x2103)).addUprightStd("°C").addUprightHtml("°C"); - symbols["celsius"]=s; symbols["degC"]=s; symbols["degreeCelsius"]=s; } - symbols["ell"]=UprightSymbolUnicode(QChar(0x2113), "ℓ"); - symbols["wp"]=UprightSymbolUnicode(QChar(0x2118), "℘").addGlobalFlags(SubscriptCorrection); - symbols["mho"]=UprightSymbolUnicode(QChar(0x2127), "℧"); - symbols["lozenge"]=UprightSymbolUnicode(QChar(0x25CA), "◊"); - symbols["cent"]=SimpleTextSymbol(QChar(0xA2), "¢"); - symbols["checkmark"]=UprightSymbolStd(QChar(0x2713)).addUprightHtml("✓"); - symbols["circ"]=UprightSymbolStd(QChar(0x2218)).addUprightHtml("∘").addStd("o", ItalicOff,0.7, -0.25); - symbols["co"]=UprightSymbolUnicode(QChar(0x2105)); - { auto s=SimpleTextSymbol(QChar(0xA9), "©"); - symbols["copyright"]=s; symbols["textcopyright"]=s; symbols["circledC"]=s; } - { auto s=UprightSymbolUnicode(QChar(0x2020)).addUprightHtml("†"); - symbols["dagger"]=s; symbols["dag"]=s; symbols["textdagger"]=s; } - { auto s=UprightSymbolUnicode(QChar(0x2021)).addUprightHtml("‡"); - symbols["ddagger"]=s; symbols["ddag"]=s; symbols["textdaggerdbl"]=s; } - { auto s=UnicodeSymbol(QChar(0x2138)).addHtml("ℸ"); - symbols["dalet"]=s; symbols["Dalet"]=s; symbols["daleth"]=s; symbols["Daleth"]=s; } - symbols["dd"] = SymbolFullProps(SymbolProps("d", Upright|BoldOff), "d", Upright|BoldOff); - symbols["diamond"]=UprightSymbolUnicode(QChar(0x22C4)).addHtml("⋄").addWinSymbol(QChar(0xE0)); - symbols["dollar"]=UnicodeSymbol(QChar(0x0024)); - { auto s=SimpleTextSymbol(QChar(0x24), "$"); - symbols["dollar"]=s; symbols["$"]=s; } - symbols["dprime"]=UnicodeSymbol(QChar(0x2033)).addHtml("″").addStd("''"); - symbols["complement"] = SymbolFullProps(SymbolProps("C", Upright|BoldOff), "C", Upright|BoldOff).addUnicode(QChar(0x2201), Upright|BoldOff); - symbols["ee"] = SymbolFullProps(SymbolProps("e", Upright|BoldOff), "e", Upright|BoldOff); - { auto s=UnicodeSymbol(QChar(0x2026)).addHtml("…").addWinSymbol(QChar(0xBC)).addStd("..."); - symbols["ellipsis"]=s; symbols["dots"]=s; symbols["ldots"]=s; } - { auto s=SimpleTextSymbol(QChar(0x20AC), "€"); - symbols["euro"]=s; symbols["EUR"]=s; } - { auto s=UnicodeSymbol(QChar(0x2109)); - symbols["fahrenheit"]=s; symbols["degF"]=s; } - symbols["female"]=UnicodeSymbol(QChar(0x2640)).addHtml("♀"); - symbols["flq"]=UnicodeSymbol(QChar(0x2039)).addHtml("‹").addStd("<"); - symbols["flqq"]=UnicodeSymbol(QChar(0x00AB)).addHtml("«").addStd(QChar(0xAB)); - //symbols["frown"]=UnicodeSymbol(QChar(0x2322)).addHtml("⌢"); - symbols["frq"]=UnicodeSymbol(QChar(0x203A)).addHtml("›").addStd(">"); - symbols["frqq"]=UnicodeSymbol(QChar(0x00BB)).addHtml("»").addStd(QChar(0xBB)); - { auto s=UnicodeSymbol(QChar(0x2137)).addHtml("ℷ"); - symbols["gimel"]=s; symbols["Gimel"]=s; } - symbols["glq"]=UnicodeSymbol(QChar(0x2018)).addHtml("‘").addStd("'"); - symbols["glqq"]=UnicodeSymbol(QChar(0x201C)).addHtml("“").addStd("\""); - symbols["grq"]=UnicodeSymbol(QChar(0x2019)).addHtml("’").addStd("'"); - symbols["grqq"]=UnicodeSymbol(QChar(0x201D)).addHtml("”").addStd("\""); - symbols["hbar"]=UprightSymbolUnicode(QChar(0x210F)).addUprightHtml("ℏ").addStd("h", ItalicOn|DrawLeftHBar).addGlobalFlags(SubscriptCorrection); - symbols["hexagon"]=UprightSymbolUnicode(QChar(0x2394)); - symbols["ii"] = SymbolFullProps(SymbolProps("i", Upright|BoldOff), "i", Upright|BoldOff); - symbols["infty"]=UprightSymbolUnicode(QChar(0x221E)).addUprightHtml("∞").addUprightWinSymbol(QChar(0xA5)).addUprightStd("8", RotateSymbol90); - symbols["langle"]=UprightSymbolUnicode(QChar(0x2329)).addWinSymbol(QChar(0xE1)); - symbols["lceil"]=UprightSymbolUnicode(QChar(0x2308)).addUprightHtml("⌈").addUprightWinSymbol(QChar(0xE9)); - symbols["lfloor"]=UprightSymbolUnicode(QChar(0x230A)).addUprightHtml("⌊").addUprightWinSymbol(QChar(0xEB)); - symbols["lightning"]=UnicodeSymbol(QChar(0x21AF)); - symbols["male"]=UnicodeSymbol(QChar(0x2642)).addHtml("♂"); - symbols["measuredangle"]=UprightSymbolUnicode(QChar(0x2221)).addUprightHtml("∡"); - symbols["micro"] = SimpleTextSymbol(QChar(0xB5), "µ"); - symbols["ohm"]=UprightSymbolUnicode(QChar(0x2126)).addUprightHtml("Ω").addUprightWinSymbol(QChar(0x57)); - symbols["partial"]=UprightSymbolUnicode(QChar(0x2202)).addUprightHtml("∂").addUprightWinSymbol(QChar(0xB6)); - { auto s=UnicodeSymbol(QChar(0x2030)).addHtml("‰"); - symbols["perthousand"]=s; symbols["permil"]=s; } - symbols["pound"]=SimpleTextSymbol(QChar(0xA3), "£"); - symbols["pound"]=UnicodeSymbol(QChar(0x00A3)); - symbols["prime"]=UnicodeSymbol(QChar(0x2032)).addHtml("′").addStd("'"); - symbols["arcminute"]=UnicodeSymbol(QChar(0x2032)).addHtml("′").addStd("'"); - symbols["arcsecond"]=UnicodeSymbol(QChar(0x2033)).addHtml("&dprime;").addStd("'"); - symbols["rangle"]=UprightSymbolUnicode(QChar(0x232A)).addUprightWinSymbol(QChar(0xF1)); - symbols["rceil"]=UprightSymbolUnicode(QChar(0x2309)).addUprightHtml("⌉").addUprightWinSymbol(QChar(0xF9)); - { auto s=SimpleTextSymbol(QChar(0xAE), "®"); - symbols["registered"]=s; symbols["textregistered"]=s; symbols["circledR"]=s; } - symbols["rfloor"]=UprightSymbolUnicode(QChar(0x230B)).addUprightHtml("⌋").addUprightWinSymbol(QChar(0xFB)); - symbols["rightangle"]=UprightSymbolUnicode(QChar(0x221F)).addUprightHtml("∟"); - //symbols["smile"]=UprightSymbolUnicode(QChar(0x2323)).addUprightHtml("⌣"); - symbols["sphericalangle"]=UprightSymbolUnicode(QChar(0x2222)).addUprightHtml("∢"); - symbols["star"]=UprightSymbolUnicode(QChar(0x22C6)); - symbols["tcohm"]=UnicodeSymbol(QChar(0x2126)); - { auto s=UnicodeSymbol(QChar(0x2014), "⹀"); - symbols["dblhyphen"]=s; symbols["textdblhyphen"]=s; symbols["textdblhyphenchar"]=s; } - { auto s=UnicodeSymbol(QChar(0x2014), "—"); - symbols["---"]=s; symbols["textemdash"]=s; symbols["emdash"]=s; } - { auto s=UnicodeSymbol(QChar(0x2013), "–"); - symbols["--"]=s; symbols["textendash"]=s; symbols["endash"]=s; } - { auto s=SimpleTextSymbol("-"); - symbols["texthyphen"]=s; symbols["hyphen"]=s; } - symbols["textbar"]=SimpleTextSymbol("|", "|"); - { auto s=SimpleTextSymbol(QChar(0xB0), "°"); - symbols["textdegree"]=s; symbols["degree"] = s; } - symbols["textgreater"]=SimpleTextSymbol(">", ">"); - symbols["textless"]=SimpleTextSymbol("<", "<"); - symbols["textquestiondown"]=SimpleTextSymbol(QChar(0xBF), "¿"); - symbols["textexclamdown"]=SimpleTextSymbol(QChar(0xA1), "¡"); - { auto s=UnicodeSymbol(QChar(0x231C)); - symbols["tlcorner"]=s; symbols["ulcorner"]=s; } - symbols["trademark"]=UnicodeSymbol(QChar(0x2122)).addHtml("™").addWinSymbol(QChar(0xD4)).addStd("(TM)"); - symbols["trapezium"]=UnicodeSymbol(QChar(0x23E2)).addHtml("⏢"); - { auto s=UprightSymbolUnicode(QChar(0x231D)); - symbols["trcorner"]=s; symbols["urcorner"]=s; } - symbols["trprime"]=UnicodeSymbol(QChar(0x2034)).addHtml("‴").addStd("'''"); - symbols["varcarriagereturn"]=UnicodeSymbol(QChar(0x23CE)).addWinSymbol(QChar(0xBF)); - symbols["varhexagonlrbonds"]=UnicodeSymbol(QChar(0x232C)); - symbols["yen"]=SimpleTextSymbol(QChar(0xA5), "¥"); - - - - - - /************************************************************************************** - * STANDARD MathOperator Strings - **************************************************************************************/ - symbols["Pr"] = NarrowMathOperatorText("Pr"); - symbols["acos"] = NarrowMathOperatorText("acos"); - symbols["arccos"] = NarrowMathOperatorText("arccos"); - symbols["arcsin"] = NarrowMathOperatorText("arcsin"); - symbols["arctan"] = NarrowMathOperatorText("arctan"); - symbols["arg"] = NarrowMathOperatorText("arg").addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["argmax"] = NarrowMathOperatorText("arg max", "arg max").addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["argmin"] = NarrowMathOperatorText("arg min", "arg min").addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["asin"] = NarrowMathOperatorText("asin"); - symbols["atan"] = NarrowMathOperatorText("atan"); - symbols["cos"] = NarrowMathOperatorText("cos"); - symbols["cosh"] = NarrowMathOperatorText("cosh"); - symbols["cot"] = NarrowMathOperatorText("cot"); - symbols["coth"] = NarrowMathOperatorText("coth"); - symbols["coth"] = NarrowMathOperatorText("coth"); - symbols["deg"] = NarrowMathOperatorText("deg"); - symbols["det"] = NarrowMathOperatorText("det"); - symbols["dim"] = NarrowMathOperatorText("dim"); - symbols["exp"] = NarrowMathOperatorText("exp"); - symbols["gcd"] = NarrowMathOperatorText("gcd"); - symbols["hom"] = NarrowMathOperatorText("hom"); - symbols["ker"] = NarrowMathOperatorText("ker"); - symbols["lb"] = NarrowMathOperatorText("lb"); - symbols["ld"] = NarrowMathOperatorText("ld"); - symbols["lim"] = NarrowMathOperatorText("lim").addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["liminf"] = NarrowMathOperatorText("lim inf", "lim inf").addGlobalFlags(SubSuperscriptBelowAboveSymbol).addGlobalFlags(SubscriptCorrection); - symbols["limsup"] = NarrowMathOperatorText("lim sup", "lim sup").addGlobalFlags(SubSuperscriptBelowAboveSymbol).addGlobalFlags(SubscriptCorrection); - symbols["ln"] = NarrowMathOperatorText("ln"); - symbols["log"] = NarrowMathOperatorText("log"); - symbols["max"] = NarrowMathOperatorText("max"); - symbols["median"] = NarrowMathOperatorText("median"); - symbols["min"] = NarrowMathOperatorText("min"); - symbols["mod"] = NarrowMathOperatorText("mod"); - symbols["sec"] = NarrowMathOperatorText("sec"); - symbols["sgn"] = NarrowMathOperatorText("sgn"); - symbols["sign"] = NarrowMathOperatorText("sign"); - symbols["sin"] = NarrowMathOperatorText("sin"); - symbols["sinh"] = NarrowMathOperatorText("sinh"); - symbols["tan"] = NarrowMathOperatorText("tan"); - symbols["tanh"] = NarrowMathOperatorText("tanh"); - - /************************************************************************************** - * STANDARD MathOperator Symbols - **************************************************************************************/ - { auto s=MathOperatorSymbolUnicode(QChar(0x2217)).addMathOperatorStd("*").addMathOperatorHtml("*"); - symbols["*"]=s; symbols["ast"]=s; symbols["asterisk"]=s; } - symbols["/"]=NarrowMathOperatorSymbolStd("/"); - symbols["+"]=MathOperatorSymbolUnicode(QChar(0x2B)).addMathOperatorHtml("+").addMathOperatorStd("+"); - symbols["-"]=MathOperatorSymbolUnicode(QChar(0x2212)).addMathOperatorHtml("-").addMathOperatorStd("-"); - symbols["<"]=MathOperatorSymbol("<", "<"); - symbols["="]=MathOperatorSymbol("="); - symbols[">"]=MathOperatorSymbol(">", ">"); - symbols["Downarrow"]=UprightSymbolUnicode(QChar(0x21D3)).addUprightHtml("⇓").addUprightWinSymbol(QChar(0xDF)); - symbols["Leftarrow"]=UprightSymbolUnicode(QChar(0x21D0)).addUprightHtml("⇐").addUprightWinSymbol(QChar(0xDC)); - symbols["Rightarrow"]=UprightSymbolUnicode(QChar(0x21D2)).addUprightHtml("⇒").addUprightWinSymbol(QChar(0xDE)); - symbols["Uparrow"]=UprightSymbolUnicode(QChar(0x21D1)).addUprightHtml("⇑").addUprightWinSymbol(QChar(0xDD)); - symbols["Updownarrow"]=UprightSymbolUnicode(QChar(0x21D5)).addUprightHtml("⇕"); - symbols["approx"]=MathOperatorSymbolUnicode(QChar(0x2248)).addMathOperatorHtml("≈").addMathOperatorWinSymbol(QChar(0xBB)); - symbols["bbC"]=UnicodeSymbol(QChar(0x2102)); - symbols["bbH"]=UnicodeSymbol(QChar(0x210D)); - symbols["bbN"]=UnicodeSymbol(QChar(0x2115)); - symbols["bbP"]=UnicodeSymbol(QChar(0x2119)); - symbols["bbQ"]=UnicodeSymbol(QChar(0x211A)); - symbols["bbR"]=UnicodeSymbol(QChar(0x211D)); - symbols["bbZ"]=UnicodeSymbol(QChar(0x2124)); - symbols["because"]=MathOperatorSymbolUnicode(QChar(0x2235)).addMathOperatorHtml("∵"); - symbols["bigcap"]=NarrowMathOperatorSymbolUnicode(QChar(0x22C2)).addMathOperatorHtml("⋂").addMathOperatorWinSymbol(QChar(0xC7), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["bigcup"]=NarrowMathOperatorSymbolUnicode(QChar(0x22C3)).addMathOperatorHtml("⋃").addMathOperatorWinSymbol(QChar(0xC8), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); - { auto s=NarrowMathOperatorSymbolUnicode(QChar(0x22C0)).addMathOperatorHtml("⋀").addMathOperatorWinSymbol(QChar(0xD9), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["bigwedge"]=s; symbols["bighat"]=s; } - symbols["bigvee"]=NarrowMathOperatorSymbolUnicode(QChar(0x22C1)).addMathOperatorHtml("⋁").addMathOperatorWinSymbol(QChar(0xDA), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["bigotimes"]=NarrowMathOperatorSymbolUnicode(QChar(0x2A02)).addMathOperatorHtml("⨂").addMathOperatorWinSymbol(QChar(0xC4), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["bigoplus"]=NarrowMathOperatorSymbolUnicode(QChar(0x2A01)).addMathOperatorHtml("⨁").addMathOperatorWinSymbol(QChar(0xC5), 1.8).addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["bigodot"]=NarrowMathOperatorSymbolUnicode(QChar(0x2A00)).addMathOperatorHtml("⨀").addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["biguplus"]=NarrowMathOperatorSymbolUnicode(QChar(0x2A04)).addMathOperatorHtml("⨄").addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["bigsqcup"]=NarrowMathOperatorSymbolUnicode(QChar(0x2A06)).addMathOperatorHtml("⨆").addGlobalFlags(SubSuperscriptBelowAboveSymbol); - { auto s=MathOperatorSymbolUnicode(QChar(0x22A5)).addMathOperatorHtml("⊥"); - symbols["bot"]=s; symbols["perp"]=s; } - { auto s=MathOperatorSymbolUnicode(QChar(0x2229)).addMathOperatorHtml("∩").addMathOperatorWinSymbol(QChar(0xC7)); - symbols["cap"]=s; symbols["land"]=s; } - symbols["cdot"]=MathOperatorSymbol(QChar(0xB7)).addMathOperatorHtml("·").addMathOperatorWinSymbol(QChar(0xD7)); - symbols["cong"]=MathOperatorSymbolUnicode(QChar(0x2245)).addMathOperatorHtml("≅"); - symbols["coprod"]=NarrowMathOperatorSymbolUnicode(QChar(0x2210)).addMathOperatorHtml("∐").addWinSymbol(QChar(0xD5), ItalicOff|BoldOff|FlipSymbolUpDown, 1.8, 0.1).addGlobalFlags(SubSuperscriptBelowAboveSymbol); - { auto s=MathOperatorSymbolUnicode(QChar(0x222A)).addMathOperatorHtml("∪").addMathOperatorWinSymbol(QChar(0xC8)); - symbols["cup"]=s; symbols["lor"]=s; } - symbols["ddots"]=UprightSymbolUnicode(QChar(0x22F1)).addMathOperatorHtml("⋱"); - symbols["div"]=MathOperatorSymbolUnicode(QChar(0x00F7)).addMathOperatorHtml("÷").addMathOperatorWinSymbol(QChar(0xB8)); - symbols["downarrow"]=UprightSymbolUnicode(QChar(0x2193)).addUprightHtml("↓").addUprightWinSymbol(QChar(0xAF)); - symbols["downharpoonleft"]=UprightSymbolUnicode(QChar(0x21C3)).addUprightHtml("⇃"); - symbols["downharpoonright"]=UprightSymbolUnicode(QChar(0x21C2)).addUprightHtml("⇂"); - { auto s=MathOperatorSymbolUnicode(QChar(0x2205)).addMathOperatorHtml("∅").addMathOperatorWinSymbol(QChar(0xC6)).addStd("0", BoldOff|ItalicOff|DrawSlash); - symbols["emptyset"]=s; symbols["varnothing"]=s; } - symbols["equiv"]=MathOperatorSymbolUnicode(QChar(0x2261)).addMathOperatorHtml("≡").addMathOperatorWinSymbol(QChar(0xBA)); - symbols["exists"]=NarrowMathOperatorSymbolUnicode(QChar(0x2203)).addMathOperatorHtml("∃").addMathOperatorWinSymbol(QChar(0x24)).addStd("E", ItalicOff|BoldOff|FlipSymbolLeftRight); - symbols["forall"]=NarrowMathOperatorSymbolUnicode(QChar(0x2200)).addMathOperatorHtml("∀").addMathOperatorWinSymbol(QChar(0x22)).addStd("A", ItalicOff|BoldOff|FlipSymbolUpDown).addGlobalFlags(SubscriptCorrection); - { auto s=MathOperatorSymbolUnicode(QChar(0x2265)).addMathOperatorHtml("≥").addMathOperatorWinSymbol(QChar(0xB3)); - symbols["geq"]=s; symbols["ge"]=s; } - symbols["geqq"]=MathOperatorSymbolUnicode(QChar(0x2267)).addMathOperatorHtml("≧"); - symbols["gg"]=MathOperatorSymbolUnicode(QChar(0x226B)).addMathOperatorHtml("≫").addMathOperatorStd(">>"); - symbols["iddots"]=UprightSymbolUnicode(QChar(0x22F0)).addMathOperatorHtml("⋰"); - { auto s=UprightSymbolUnicode(QChar(0x21D4)).addUprightHtml("⇔").addUprightWinSymbol(QChar(0xDB)); - symbols["iff"]=s; symbols["Leftrightarrow"]=s; } - symbols["iiint"]=NarrowMathOperatorSymbolUnicode(QChar(0x222D)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∭").addMathOperatorWinSymbol(QString(3, QChar(0xF2)), 1.8, 0.1); - symbols["iint"]=NarrowMathOperatorSymbolUnicode(QChar(0x222C)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∬").addMathOperatorWinSymbol(QString(2, QChar(0xF2)), 1.8, 0.1); - symbols["in"]=MathOperatorSymbolUnicode(QChar(0x2208)).addMathOperatorHtml("∈").addMathOperatorWinSymbol(QChar(0xCE)); - symbols["int"]=NarrowMathOperatorSymbolUnicode(QChar(0x222B)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∫").addMathOperatorWinSymbol(QChar(0xF2), 1.8, 0.1); - symbols["leftarrow"]=UprightSymbolUnicode(QChar(0x2190)).addUprightHtml("←").addUprightWinSymbol(QChar(0xAC)); - symbols["longleftarrow"]=UprightSymbolUnicode(QChar(0x27F5)).addUprightHtml("⟵"); - symbols["longrightarrow"]=UprightSymbolUnicode(QChar(0x27F6)).addUprightHtml("⟶"); - symbols["longleftrightarrow"]=UprightSymbolUnicode(QChar(0x27F7)).addUprightHtml("⟷"); - symbols["Longleftarrow"]=UprightSymbolUnicode(QChar(0x27F8)).addUprightHtml("⟸"); - symbols["Longrightarrow"]=UprightSymbolUnicode(QChar(0x27F9)).addUprightHtml("⟹"); - symbols["Longleftrightarrow"]=UprightSymbolUnicode(QChar(0x27FA)).addUprightHtml("⟺"); - symbols["leftharpoondown"]=UprightSymbolUnicode(QChar(0x21BD)).addUprightHtml("↽"); - symbols["leftharpoonup"]=UprightSymbolUnicode(QChar(0x21BC)).addUprightHtml("↼"); - symbols["leftrightarrow"]=UprightSymbolUnicode(QChar(0x2194)).addUprightHtml("↔").addUprightWinSymbol(QChar(0xAB)); - symbols["leftrightharpoon"]=UprightSymbolUnicode(QChar(0x21CB)).addUprightHtml("⇋"); - { auto s=MathOperatorSymbolUnicode(QChar(0x2264)).addMathOperatorHtml("≤").addMathOperatorWinSymbol(QChar(0xA3)); - symbols["leq"]=s; symbols["le"]=s; } - symbols["leqq"]=MathOperatorSymbolUnicode(QChar(0x2266)).addMathOperatorHtml("≦"); - symbols["ll"]=MathOperatorSymbolUnicode(QChar(0x226A)).addMathOperatorHtml("≪").addMathOperatorStd("<<"); - symbols["lnot"]=MathOperatorSymbolUnicode(QChar(0xAC)).addMathOperatorWinSymbol(QChar(0xD8)).addMathOperatorHtml("¬"); - symbols["mapimage"]=MathOperatorSymbolUnicode(QChar(0x22B7)).addMathOperatorHtml("⊷"); - symbols["maporiginal"]=MathOperatorSymbolUnicode(QChar(0x22B6)).addMathOperatorHtml("⊶"); - symbols["mapsto"]=MathOperatorSymbolUnicode(QChar(0x21A6)).addMathOperatorHtml("↦"); - symbols["mid"]=MathOperatorSymbolUnicode(QChar(0x2223)).addMathOperatorHtml("∣").addMathOperatorWinSymbol(QChar(0xBD)).addMathOperatorStd("|"); - symbols["mp"]=MathOperatorSymbolUnicode(QChar(0x2213)).addMathOperatorHtml("∓").addWinSymbol(QChar(0xB1),ItalicOff|BoldOff|FlipSymbolUpDown).addStd(QChar(0xB1),ItalicOff|BoldOff|FlipSymbolUpDown); - symbols["multimap"]=MathOperatorSymbolUnicode(QChar(0x22B8)).addMathOperatorHtml("⊸"); - symbols["nabla"]=NarrowMathOperatorSymbolUnicode(QChar(0x2207)).addMathOperatorHtml("∇").addMathOperatorWinSymbol(QChar(0xD1)).addGlobalFlags(IntLikeSymbolCorrection); - symbols["ne"]=NarrowMathOperatorSymbolUnicode(QChar(0x2260)).addMathOperatorHtml("≠").addMathOperatorWinSymbol(QChar(0xB9)); - symbols["nearrow"]=UprightSymbolUnicode(QChar(0x2197)).addUprightHtml("↗"); - { auto s=MathOperatorSymbolUnicode(QChar(0x00AC)).addMathOperatorHtml("¬").addMathOperatorWinSymbol(QChar(0xD8)); - symbols["neg"]=s; symbols["lnot"]=s; } - symbols["neq"]=MathOperatorSymbolUnicode(QChar(0x2260)).addMathOperatorHtml("≠").addMathOperatorWinSymbol(QChar(0xB9)).addStd("=", ItalicOff|BoldOff|DrawSlash); - symbols["nexists"]=NarrowMathOperatorSymbolUnicode(QChar(0x2204)).addMathOperatorHtml("∄").addStd("E", ItalicOff|BoldOff|FlipSymbolLeftRight|DrawSlash).addMathOperatorWinSymbol(QChar(0x24), ItalicOff|BoldOff|DrawSlash); - symbols["ni"]=NarrowMathOperatorSymbolUnicode(QChar(0x220B)).addMathOperatorHtml("∋").addMathOperatorWinSymbol(QChar(0xCE), ItalicOff|BoldOff|FlipSymbolLeftRight); - symbols["nmid"]=NarrowMathOperatorSymbolUnicode(QChar(0x2224)).addMathOperatorHtml("∤"); - symbols["notin"]=NarrowMathOperatorSymbolUnicode(QChar(0x2209)).addMathOperatorHtml("∉").addMathOperatorWinSymbol(QChar(0xCF)); - symbols["notni"]=NarrowMathOperatorSymbolUnicode(QChar(0x220C)).addMathOperatorHtml("∌"); - symbols["nparallel"]=MathOperatorSymbolUnicode(QChar(0x2226)).addMathOperatorHtml("∦"); - symbols["nwarrow"]=UprightSymbolUnicode(QChar(0x2196)).addUprightHtml("↖"); - symbols["odot"]=MathOperatorSymbolUnicode(QChar(0x2299)).addMathOperatorHtml("⊙"); - symbols["oiiint"]=NarrowMathOperatorSymbolUnicode(QChar(0x2230)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∰"); - symbols["oiint"]=NarrowMathOperatorSymbolUnicode(QChar(0x222F)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∯"); - symbols["oint"]=NarrowMathOperatorSymbolUnicode(QChar(0x222E)).addGlobalFlags(IntLikeSymbolCorrection | SubSuperscriptBelowAboveSymbol).addMathOperatorHtml("∮"); - symbols["ominus"]=MathOperatorSymbolUnicode(QChar(0x2296)).addMathOperatorHtml("⊖"); - symbols["oplus"]=MathOperatorSymbolUnicode(QChar(0x2295)).addMathOperatorHtml("⊕").addMathOperatorWinSymbol(QChar(0xC5)); - symbols["oslash"]=MathOperatorSymbolUnicode(QChar(0x2298)).addMathOperatorHtml("⊘"); - symbols["otimes"]=MathOperatorSymbolUnicode(QChar(0x2297)).addMathOperatorHtml("⊗").addMathOperatorWinSymbol(QChar(0xC4)); - symbols["parallel"]=NarrowMathOperatorSymbolUnicode(QChar(0x2225)).addMathOperatorHtml("∥").addMathOperatorStd("||"); - symbols["pm"] = MathOperatorSymbol(QChar(0xB1), "±").addMathOperatorWinSymbol(QChar(0xB1)); - symbols["prec"]=MathOperatorSymbolUnicode(QChar(0x227A)).addMathOperatorHtml("≺"); - symbols["prod"]=NarrowMathOperatorSymbolUnicode(QChar(0x220F)).addMathOperatorWinSymbol(QChar(0xD5), 1.8, 0.1).addMathOperatorHtml("∏").addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["propto"]=MathOperatorSymbolUnicode(QChar(0x221D)).addMathOperatorWinSymbol(QChar(0xB5)).addMathOperatorHtml("∝"); - symbols["rightharpoondown"]=UprightSymbolUnicode(QChar(0x21C1)).addUprightHtml("⇁"); - symbols["rightharpoonup"]=UprightSymbolUnicode(QChar(0x21C0)).addUprightHtml("⇀"); - symbols["rightleftharpoon"]=UprightSymbolUnicode(QChar(0x21CC)).addUprightHtml("⇌"); - symbols["searrow"]=UprightSymbolUnicode(QChar(0x2198)).addUprightHtml("↘"); - symbols["setminus"]=MathOperatorSymbolUnicode(QChar(0x2216)).addMathOperatorHtml("∖"); - { auto s=MathOperatorSymbolUnicode(QChar(0x223C)).addMathOperatorHtml("˜").addMathOperatorStd("~"); - symbols["~"]=s; symbols["sim"]=s; } - symbols["simeq"]=MathOperatorSymbolUnicode(QChar(0x2243)).addMathOperatorHtml("≃"); - symbols["sqcap"]=MathOperatorSymbolUnicode(QChar(0x2293)).addMathOperatorHtml("⊓"); - symbols["sqcup"]=MathOperatorSymbolUnicode(QChar(0x2294)).addMathOperatorHtml("⊔"); - symbols["square"]=MathOperatorSymbolUnicode(QChar(0x25A1)); - symbols["subset"]=MathOperatorSymbolUnicode(QChar(0x2282)).addMathOperatorHtml("⊂").addMathOperatorWinSymbol(QChar(0xCC)); - symbols["subseteq"]=MathOperatorSymbolUnicode(QChar(0x2286)).addMathOperatorHtml("⊆").addMathOperatorWinSymbol(QChar(0xCD)); - symbols["subsetnot"]=MathOperatorSymbolUnicode(QChar(0x2284)).addMathOperatorHtml("⊄").addMathOperatorWinSymbol(QChar(0xCB)); - symbols["succ"]=MathOperatorSymbolUnicode(QChar(0x227B)).addMathOperatorHtml("≻"); - symbols["sum"]=NarrowMathOperatorSymbolUnicode(QChar(0x2211)).addMathOperatorWinSymbol(QChar(0xE5), 1.8, 0.1).addMathOperatorHtml("∑").addGlobalFlags(SubSuperscriptBelowAboveSymbol); - symbols["supset"]=MathOperatorSymbolUnicode(QChar(0x2283)).addMathOperatorHtml("⊃").addMathOperatorWinSymbol(QChar(0xC9)); - symbols["supseteq"]=MathOperatorSymbolUnicode(QChar(0x2287)).addMathOperatorHtml("⊇").addMathOperatorWinSymbol(QChar(0xCA)); - symbols["supsetnot"]=MathOperatorSymbolUnicode(QChar(0x2285)).addMathOperatorHtml("⊅"); - symbols["swarrow"]=UprightSymbolUnicode(QChar(0x2199)).addUprightHtml("↙"); - symbols["therefore"]=MathOperatorSymbolUnicode(QChar(0x2234)).addMathOperatorHtml("∴").addMathOperatorWinSymbol(QChar(0x5C)); - symbols["times"] = MathOperatorSymbol(QChar(0xD7), "×").addMathOperatorWinSymbol(QChar(0xB4)); - { auto s=UprightSymbolUnicode(QChar(0x2192)).addUprightHtml("→").addUprightWinSymbol(QChar(0xAE)); - symbols["to"]=s; symbols["rightarrow"]=s; } - symbols["top"]=MathOperatorSymbolUnicode(QChar(0x22A4)).addMathOperatorHtml("⊤").addMathOperatorWinSymbol(QChar(0x5E)).addUprightStd("T"); - symbols["triangle"]=NarrowMathOperatorSymbolUnicode(QChar(0x2206)); - symbols["uparrow"]=UprightSymbolUnicode(QChar(0x2191)).addUprightHtml("↑").addUprightWinSymbol(QChar(0xAD)); - symbols["updownarrow"]=UprightSymbolUnicode(QChar(0x2195)).addUprightHtml("↕"); - symbols["upharpoonleft"]=UprightSymbolUnicode(QChar(0x21BF)).addUprightHtml("↿"); - symbols["upharpoonright"]=UprightSymbolUnicode(QChar(0x21BE)).addUprightHtml("↾"); - symbols["vartriangleleft"]=NarrowMathOperatorSymbolUnicode(QChar(0x22B2)).addMathOperatorHtml("⊲"); - symbols["vdots"]=UprightSymbolUnicode(QChar(0x22EE)).addMathOperatorHtml("⋮"); - symbols["vee"]=MathOperatorSymbolUnicode(QChar(0x2228)).addMathOperatorHtml("∨").addMathOperatorWinSymbol(QChar(0xDA)); - symbols["vdash"]=MathOperatorSymbolUnicode(QChar(0x22A2)).addMathOperatorHtml("⊢"); - symbols["dashv"]=MathOperatorSymbolUnicode(QChar(0x22A3)).addMathOperatorHtml("⊣"); - symbols["vDash"]=MathOperatorSymbolUnicode(QChar(0x22A8)).addMathOperatorHtml("⊨"); - symbols["nvdash"]=MathOperatorSymbolUnicode(QChar(0x22AC)).addMathOperatorHtml("⊬"); - symbols["Vdash"]=MathOperatorSymbolUnicode(QChar(0x22A9)).addMathOperatorHtml("⊩"); - symbols["models"]=MathOperatorSymbolUnicode(QChar(0x22A7)).addMathOperatorHtml("⊧"); - symbols["wedge"]=MathOperatorSymbolUnicode(QChar(0x2227)).addMathOperatorHtml("∧").addMathOperatorWinSymbol(QChar(0xD9)); - - - - /************************************************************************************** - * GREEK letters - **************************************************************************************/ - addGreekLetterVariants_WinSymbol_Unicode_Html("alpha", "a", QChar(0x3B1), "α"); - addGreekLetterVariants_WinSymbol_Unicode_Html("beta", "b", QChar(0x3B2), "β"); - addGreekLetterVariants_WinSymbol_Unicode_Html("gamma", "g", QChar(0x3B3), "γ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("delta", "d", QChar(0x3B4), "δ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("epsilon", "e", QChar(0x3F5), "ϵ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("varepsilon", "e", QChar(0x3B5), "ε"); - addGreekLetterVariants_WinSymbol_Unicode_Html("zeta", "z", QChar(0x3B6),"ζ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("eta", "h", QChar(0x3B7),"η"); - addGreekLetterVariants_WinSymbol_Unicode_Html("theta", "q", QChar(0x3B8),"θ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("vartheta", "J", QChar(0x3D1),"ϑ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("iota", "i", QChar(0x3B9),"ι"); - addGreekLetterVariants_WinSymbol_Unicode_Html("kappa", "k", QChar(0x3BA),"κ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("lambda", "l", QChar(0x3BB),"λ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("mu", "m", QChar(0x3BC),"μ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("nu", "n", QChar(0x3BD),"ν"); - addGreekLetterVariants_WinSymbol_Unicode_Html("xi", "x", QChar(0x3BE),"ξ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("pi", "p", QChar(0x3C0),"π"); - addGreekLetterVariants_WinSymbol_Unicode_Html("varpi", "v", QChar(0x3D6),"ϖ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("rho", "r", QChar(0x3C1),"ρ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("varrho", "r", QChar(0x3F1),"ϱ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("sigma", "s", QChar(0x3C3),"σ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("varsigma", "V", QChar(0x3C2),"ς"); - addGreekLetterVariants_WinSymbol_Unicode_Html("tau", "t", QChar(0x3C4),"τ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("upsilon", "u", QChar(0x3C5),"υ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("phi", "f", QChar(0x3C5),"ϕ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("varphi", "j", QChar(0x3D6),"φ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("chi", "c", QChar(0x3C7),"χ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("psi", "y", QChar(0x3C8),"ψ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("omega", "w", QChar(0x3C9),"ω"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Gamma", "G", QChar(0x3A3),"Γ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Delta", "D", QChar(0x394),"Δ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Theta", "Q", QChar(0x398),"Θ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Lambda", "L", QChar(0x39B),"Λ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Omega", "W", QChar(0x3A9),"Ω"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Xi", "X", QChar(0x39E),"Ξ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Pi", "P", QChar(0x3A0),"Π"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Sigma", "S", QChar(0x3A3),"Σ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Upsilon", "U", QChar(0x3C6),"Υ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Phi", "F", QChar(0x3A6),"Φ"); - addGreekLetterVariants_WinSymbol_Unicode_Html("Psi", "Y", QChar(0x3A8),"Ψ"); - - - /************************************************************************************** - * SYMBOLS from special fonts - **************************************************************************************/ -#if (QT_VERSION& symbols,const QString& baseInstructionName, const QString& letterWinSymbol, const QString& letterUnicode, const QString& html); /** \brief constructs a SymbolProps for a symbol with encoding in Standard-fonts a */ static SymbolFullProps StdSymbol(const QString& symbol, const QString& html); /** \brief constructs a SymbolProps for a symbol with encoding in UnicodeFull-fonts a */ @@ -306,10 +306,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode { /** \brief symbols that can be generated in any standard-font */ - static QHash symbols; - - /** \brief fill the symbol tables standardTextSymbols, winSymbolSymbol, ... with contents */ - static void fillSymbolTables(); + static const QHash& symbols(); /** \brief retrieve the properties to render the given symbol \a symName in the current environment \a currentEv */ SymbolFullProps getSymbolProp(const QString& symName, const JKQTMathTextEnvironment& currentEv) const; diff --git a/lib/jkqtmathtext/nodes/jkqtmathtexttextnode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtexttextnode.cpp index ba2ed34d25..6a8c3c82bd 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtexttextnode.cpp +++ b/lib/jkqtmathtext/nodes/jkqtmathtexttextnode.cpp @@ -73,37 +73,39 @@ bool JKQTMathTextTextBaseNode::toHtml(QString &html, JKQTMathTextEnvironment cur -QHash JKQTMathTextTextNode::blackboardUnicodeTable=QHash(); +const QHash& JKQTMathTextTextNode::blackboardUnicodeTable(){ + static QHash table=[]() { + QHash blackboardUnicodeTable; -void JKQTMathTextTextNode::fillStaticTables() { - static std::mutex sMutex; - std::lock_guard lock(sMutex); - if (blackboardUnicodeTable.size()>0) return; + const QString ALPHA="ABDEFGIJKLMOSTUVWXYZ"; + for (const QChar ch: ALPHA) { + blackboardUnicodeTable[ch]=0x1D538+(ch.unicode()-QChar('A').unicode()); + } + const QString alpha="abcdefghijklmnopqrstuvwxyz"; + for (const QChar ch: alpha) { + blackboardUnicodeTable[ch]=0x1D552+(ch.unicode()-QChar('a').unicode()); + } + const QString nums="0123456789"; + for (const QChar ch: nums) { + blackboardUnicodeTable[ch]=0x1D7D8+(ch.unicode()-QChar('0').unicode()); + } + blackboardUnicodeTable['C']=0x2102; + blackboardUnicodeTable['H']=0x210D; + blackboardUnicodeTable['N']=0x2115; + blackboardUnicodeTable['P']=0x2119; + blackboardUnicodeTable['Q']=0x211A; + blackboardUnicodeTable['R']=0x211D; + blackboardUnicodeTable['Z']=0x2124; - for (const QChar ch: QString("ABDEFGIJKLMOSTUVWXYZ")) { - blackboardUnicodeTable[ch]=0x1D538+(ch.unicode()-QChar('A').unicode()); - } - for (const QChar ch: QString("abcdefghijklmnopqrstuvwxyz")) { - blackboardUnicodeTable[ch]=0x1D552+(ch.unicode()-QChar('a').unicode()); - } - for (const QChar ch: QString("0123456789")) { - blackboardUnicodeTable[ch]=0x1D7D8+(ch.unicode()-QChar('0').unicode()); - } - - blackboardUnicodeTable['C']=0x2102; - blackboardUnicodeTable['H']=0x210D; - blackboardUnicodeTable['N']=0x2115; - blackboardUnicodeTable['P']=0x2119; - blackboardUnicodeTable['Q']=0x211A; - blackboardUnicodeTable['R']=0x211D; - blackboardUnicodeTable['Z']=0x2124; + return blackboardUnicodeTable; + }(); + return table; } JKQTMathTextTextNode::JKQTMathTextTextNode(JKQTMathText* _parent, const QString& textIn, bool addWhitespace, bool stripInnerWhitepace): JKQTMathTextTextBaseNode(_parent, "") { - fillStaticTables(); QString textTransformed=textIn; if (stripInnerWhitepace) { @@ -240,11 +242,11 @@ void JKQTMathTextTextNode::splitTextForLayout(QPainter &painter, JKQTMathTextEnv } else if (bbMode==MTBBDMsimulate) { CFontMode=FMasDefinedOutline; } else if (bbMode==MTBBDMunicodeCharactersOrSimulate || bbMode==MTBBDMunicodeCharactersOrFontDirectly) { - if (blackboardUnicodeTable.contains(c) && fmRoman.inFontUcs4(blackboardUnicodeTable[c])) { - cs=jkqtp_UnicodeToUTF8Q(blackboardUnicodeTable[c]); + if (blackboardUnicodeTable().contains(c) && fmRoman.inFontUcs4(blackboardUnicodeTable().operator[](c))) { + cs=jkqtp_UnicodeToUTF8Q(blackboardUnicodeTable().operator[](c)); CFontMode=FMroman; - } else if (blackboardUnicodeTable.contains(c) && fmFallbackSym.inFontUcs4(blackboardUnicodeTable[c])) { - cs=jkqtp_UnicodeToUTF8Q(blackboardUnicodeTable[c]); + } else if (blackboardUnicodeTable().contains(c) && fmFallbackSym.inFontUcs4(blackboardUnicodeTable().operator[](c))) { + cs=jkqtp_UnicodeToUTF8Q(blackboardUnicodeTable().operator[](c)); CFontMode=FMfallbackSymbol; } else { if (bbMode==MTBBDMunicodeCharactersOrSimulate) { @@ -291,10 +293,10 @@ double JKQTMathTextTextNode::draw(QPainter& painter, double x, double y, JKQTMat const QFont fUpright=JKQTMathTextGetNonItalic(f); const QFont fFallbackSym=currentEv.exchangedFontFor(MTEFallbackSymbols).getFont(parentMathText); const QFont fRoman=currentEv.exchangedFontForRoman().getFont(parentMathText); - const QFontMetricsF fm(f, painter.device()); - const QFontMetricsF fmUpright(fUpright, painter.device()); - const QFontMetricsF fmFallbackSym(fFallbackSym, painter.device()); - const QFontMetricsF fmRoman(fRoman, painter.device()); + //const QFontMetricsF fm(f, painter.device()); + //const QFontMetricsF fmUpright(fUpright, painter.device()); + //const QFontMetricsF fmFallbackSym(fFallbackSym, painter.device()); + //const QFontMetricsF fmRoman(fRoman, painter.device()); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.setFont(f); diff --git a/lib/jkqtmathtext/nodes/jkqtmathtexttextnode.h b/lib/jkqtmathtext/nodes/jkqtmathtexttextnode.h index c5903ba5a6..a4e56bab2e 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtexttextnode.h +++ b/lib/jkqtmathtext/nodes/jkqtmathtexttextnode.h @@ -110,9 +110,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextTextNode: public JKQTMathTextTextBaseN */ void splitTextForLayout(QPainter &painter, JKQTMathTextEnvironment currentEv, const QString& txt, QStringList& textpart, QList& fontMode) const; /** \brief translation table for blackboard-font characters from "normal" Latin-1 encoding to unicode-encoding of blackboards */ - static QHash blackboardUnicodeTable; - /** \brief fill static data */ - static void fillStaticTables(); + static const QHash& blackboardUnicodeTable(); /** \copydoc JKQTMathTextTextBaseNode::textTransform() */ virtual QString textTransform(const QString& text, const JKQTMathTextEnvironment& currentEv) const override; }; diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextwhitespacenode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextwhitespacenode.cpp index b7a5cbd55b..905fa7bb44 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextwhitespacenode.cpp +++ b/lib/jkqtmathtext/nodes/jkqtmathtextwhitespacenode.cpp @@ -51,15 +51,13 @@ JKQTMathTextWhitespaceNode::JKQTMathTextWhitespaceNode(JKQTMathText *_parent): JKQTMathTextWhitespaceNode::JKQTMathTextWhitespaceNode(const QString &_type, JKQTMathText *parent): JKQTMathTextWhitespaceNode(parent) { - fillSupportedInstructions(); - whitespace=supportedInstructions[_type]; + whitespace=supportedInstructions()[_type]; } JKQTMathTextWhitespaceNode::JKQTMathTextWhitespaceNode(const QString &_type, size_t count, JKQTMathText *parent): JKQTMathTextWhitespaceNode(parent) { - fillSupportedInstructions(); - whitespace=supportedInstructions[_type]; + whitespace=supportedInstructions()[_type]; whitespace.count=whitespace.count*count; } @@ -67,7 +65,6 @@ JKQTMathTextWhitespaceNode::JKQTMathTextWhitespaceNode(Types type, size_t count, JKQTMathTextNode(parent), whitespace(type, count) { - fillSupportedInstructions(); } JKQTMathTextWhitespaceNode::~JKQTMathTextWhitespaceNode() { @@ -134,31 +131,30 @@ JKQTMathTextNodeSize JKQTMathTextWhitespaceNode::getSizeInternal(QPainter &paint return s; } -QHash JKQTMathTextWhitespaceNode::supportedInstructions; - -void JKQTMathTextWhitespaceNode::fillSupportedInstructions() -{ - static std::mutex sMutex; - std::lock_guard lock(sMutex); - if (supportedInstructions.size()==0) { - supportedInstructions[" "]=WhitespaceProps(WSTthicker, 1); - supportedInstructions["nbsp"]=WhitespaceProps(WSTNonbreaking, 1); - supportedInstructions["enspace"]=WhitespaceProps(WST1en, 1); - supportedInstructions["enskip"]=WhitespaceProps(WST1en, 1); - supportedInstructions["quad"]=WhitespaceProps(WSTQuad, 1); - supportedInstructions["emspace"]=WhitespaceProps(WSTQuad, 1); - supportedInstructions["qquad"]=WhitespaceProps(WSTQuad, 2); - supportedInstructions[","]=WhitespaceProps(WSTthin, 1); - supportedInstructions["thinspace"]=WhitespaceProps(WSTthin, 1); - supportedInstructions[":"]=WhitespaceProps(WSTmedium, 1); - supportedInstructions["medspace"]=WhitespaceProps(WSTmedium, 1); - supportedInstructions[";"]=WhitespaceProps(WSTthick, 1); - supportedInstructions["thickspace"]=WhitespaceProps(WSTthick, 1); - supportedInstructions["!"]=WhitespaceProps(WSTnegthin, 1); - supportedInstructions["negthinspace"]=WhitespaceProps(WSTnegthin, 1); - supportedInstructions["negmedspace"]=WhitespaceProps(WSTnegmedium, 1); - supportedInstructions["negthickspace"]=WhitespaceProps(WSTnegthick, 1); - } +const QHash& JKQTMathTextWhitespaceNode::supportedInstructions() { + static QHash table=[]() + { + QHash supportedInstructions; + supportedInstructions[" "]=WhitespaceProps(WSTthicker, 1); + supportedInstructions["nbsp"]=WhitespaceProps(WSTNonbreaking, 1); + supportedInstructions["enspace"]=WhitespaceProps(WST1en, 1); + supportedInstructions["enskip"]=WhitespaceProps(WST1en, 1); + supportedInstructions["quad"]=WhitespaceProps(WSTQuad, 1); + supportedInstructions["emspace"]=WhitespaceProps(WSTQuad, 1); + supportedInstructions["qquad"]=WhitespaceProps(WSTQuad, 2); + supportedInstructions[","]=WhitespaceProps(WSTthin, 1); + supportedInstructions["thinspace"]=WhitespaceProps(WSTthin, 1); + supportedInstructions[":"]=WhitespaceProps(WSTmedium, 1); + supportedInstructions["medspace"]=WhitespaceProps(WSTmedium, 1); + supportedInstructions[";"]=WhitespaceProps(WSTthick, 1); + supportedInstructions["thickspace"]=WhitespaceProps(WSTthick, 1); + supportedInstructions["!"]=WhitespaceProps(WSTnegthin, 1); + supportedInstructions["negthinspace"]=WhitespaceProps(WSTnegthin, 1); + supportedInstructions["negmedspace"]=WhitespaceProps(WSTnegmedium, 1); + supportedInstructions["negthickspace"]=WhitespaceProps(WSTnegthick, 1); + return supportedInstructions; + }(); + return table; } @@ -212,8 +208,7 @@ double JKQTMathTextWhitespaceNode::Type2PixelWidth(Types type, JKQTMathTextEnvir bool JKQTMathTextWhitespaceNode::supportsInstructionName(const QString &instruction) { - fillSupportedInstructions(); - return supportedInstructions.contains(instruction); + return supportedInstructions().contains(instruction); } @@ -370,13 +365,11 @@ QString JKQTMathTextPhantomNode::Mode2Instruction(Mode mode) JKQTMathTextPhantomNode::JKQTMathTextPhantomNode(JKQTMathText *parent, const QString &mode, JKQTMathTextNode *child): JKQTMathTextInstruction1Node(parent, mode, child) { - fillInstructions(); } JKQTMathTextPhantomNode::JKQTMathTextPhantomNode(JKQTMathText* _parent, Mode mode, JKQTMathTextNode* child): JKQTMathTextInstruction1Node(_parent, Mode2Instruction(mode), child) { - fillInstructions(); } JKQTMathTextPhantomNode::~JKQTMathTextPhantomNode() { @@ -389,10 +382,9 @@ QString JKQTMathTextPhantomNode::getTypeName() const } JKQTMathTextNodeSize JKQTMathTextPhantomNode::getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const { - fillInstructions(); JKQTMathTextNodeSize s=getChild()->getSize(painter, currentEv); - switch(instructions[getInstructionName()]) { + switch(instructions()[getInstructionName()]) { case FMwidth: s.overallHeight=0; s.baselineHeight=0; @@ -415,25 +407,23 @@ double JKQTMathTextPhantomNode::draw(QPainter& painter, double x, double y, JKQT bool JKQTMathTextPhantomNode::toHtml(QString &html, JKQTMathTextEnvironment currentEv, JKQTMathTextEnvironment defaultEv) const { JKQTMathTextEnvironment ev=currentEv; - fillInstructions(); return " "; } bool JKQTMathTextPhantomNode::supportsInstructionName(const QString &instructionName) { - fillInstructions(); - return instructions.contains(instructionName); + return instructions().contains(instructionName); } -QHash JKQTMathTextPhantomNode::instructions; - -void JKQTMathTextPhantomNode::fillInstructions() -{ - static std::mutex sMutex; - std::lock_guard lock(sMutex); - if (instructions.size()>0) return; - instructions["phantom"] = FMwidthAndHeight; - instructions["hphantom"] = FMwidth; - instructions["vphantom"] = FMheight; +const QHash& JKQTMathTextPhantomNode::instructions() { + static QHash table=[]() + { + QHash instructions; + instructions["phantom"] = FMwidthAndHeight; + instructions["hphantom"] = FMwidth; + instructions["vphantom"] = FMheight; + return instructions; + }(); + return table; } diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextwhitespacenode.h b/lib/jkqtmathtext/nodes/jkqtmathtextwhitespacenode.h index 83e6402a75..a5c711ee25 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextwhitespacenode.h +++ b/lib/jkqtmathtext/nodes/jkqtmathtextwhitespacenode.h @@ -100,10 +100,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextWhitespaceNode: public JKQTMathTextNod WhitespaceProps whitespace; /** \brief converts Types \a type into its HTML representation */ static QString Type2HTML(Types type); - /** \brief translation table between latex instruction and WhitespaceProps */ - static QHash supportedInstructions; - /** \brief initializes supportedInstructions */ - static void fillSupportedInstructions(); + /** \brief translation table between latex instruction and WhitespaceProps + * + * \note This is a customization point for additional whitespace instructions! + */ + static const QHash& supportedInstructions(); }; @@ -187,13 +188,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextPhantomNode: public JKQTMathTextInstru protected: /** \copydoc JKQTMathTextNode::getSizeInternal() */ virtual JKQTMathTextNodeSize getSizeInternal(QPainter& painter, JKQTMathTextEnvironment currentEv) const override; - /** \brief fills instructions + /** \brief defines all implemented instructions in this node * * \note this is the customization point for new instructions! - */ - static void fillInstructions(); - /** \brief defines all implemented instructions in this node */ - static QHash instructions; + */ + static const QHash& instructions(); }; #endif // JKQTMATHTEXTWHITESPACENODE_H diff --git a/lib/jkqtplotter/jkqtpbaseplotter.cpp b/lib/jkqtplotter/jkqtpbaseplotter.cpp index 36372850bc..cd3f71ed85 100644 --- a/lib/jkqtplotter/jkqtpbaseplotter.cpp +++ b/lib/jkqtplotter/jkqtpbaseplotter.cpp @@ -53,6 +53,7 @@ #include "jkqtmathtext/jkqtmathtext.h" #include "jkqtplotter/jkqtpkey.h" #include +#include QString JKQTBasePlotter::globalUserSettigsFilename=""; QString JKQTBasePlotter::globalUserSettigsPrefix=""; @@ -64,10 +65,11 @@ JKQTPSynchronized> JKQTBasePlotter::jkqtpSaveDataAd void initJKQTBasePlotterResources() { - static std::mutex sMutex; - std::lock_guard lock(sMutex); - Q_INIT_RESOURCE(jkqtpbaseplotter); - initJKQTMathTextResources(); + static std::once_flag flag; + std::call_once(flag, []() { + Q_INIT_RESOURCE(jkqtpbaseplotter); + initJKQTMathTextResources(); + }); } @@ -80,20 +82,20 @@ void JKQTBasePlotter::setDefaultJKQTBasePrinterUserSettings(QString userSettigsF void JKQTBasePlotter::registerPaintDeviceAdapter(JKQTPPaintDeviceAdapter *adapter) { - JKQTPSynchronized>::Locker lock(jkqtpPaintDeviceAdapters); + JKQTPSynchronized>::WriteLocker lock(jkqtpPaintDeviceAdapters); jkqtpPaintDeviceAdapters.get().append(adapter); } void JKQTBasePlotter::deregisterPaintDeviceAdapter(JKQTPPaintDeviceAdapter *adapter) { - JKQTPSynchronized>::Locker lock(jkqtpPaintDeviceAdapters); + JKQTPSynchronized>::WriteLocker lock(jkqtpPaintDeviceAdapters); if (jkqtpPaintDeviceAdapters.get().contains(adapter)) jkqtpPaintDeviceAdapters.get().removeAll(adapter); } bool JKQTBasePlotter::registerSaveDataAdapter(JKQTPSaveDataAdapter *adapter) { if (adapter){ - JKQTPSynchronized>::Locker lock(jkqtpSaveDataAdapters); + JKQTPSynchronized>::WriteLocker lock(jkqtpSaveDataAdapters); QString format=adapter->getFilter(); for (int i=0; igetFilter()==format) { @@ -108,7 +110,7 @@ bool JKQTBasePlotter::registerSaveDataAdapter(JKQTPSaveDataAdapter *adapter) bool JKQTBasePlotter::deregisterSaveDataAdapter(JKQTPSaveDataAdapter *adapter) { - JKQTPSynchronized>::Locker lock(jkqtpSaveDataAdapters); + JKQTPSynchronized>::WriteLocker lock(jkqtpSaveDataAdapters); if (jkqtpSaveDataAdapters.get().contains(adapter)) jkqtpSaveDataAdapters.get().removeAll(adapter); return true; } @@ -3285,7 +3287,7 @@ bool JKQTBasePlotter::saveData(const QString& filename, const QString &format) { QMap saveAdapterFileExtensions; { - JKQTPSynchronized>::Locker lock(jkqtpSaveDataAdapters); + JKQTPSynchronized>::ReadLocker lock(jkqtpSaveDataAdapters); for (int i=0; igetFormatID(); fileformats<getFilter(); @@ -3371,7 +3373,7 @@ bool JKQTBasePlotter::saveData(const QString& filename, const QString &format) { QString fidx=fmt; fidx=fidx.remove(0,6); int idx=fidx.toInt(); - JKQTPSynchronized>::Locker lock(jkqtpSaveDataAdapters); + JKQTPSynchronized>::ReadLocker lock(jkqtpSaveDataAdapters); if (idx>=0 && idx > dataset=datastore->getData(&columnNames); @@ -3379,7 +3381,7 @@ bool JKQTBasePlotter::saveData(const QString& filename, const QString &format) { return true; } } else { - JKQTPSynchronized>::Locker lock(jkqtpSaveDataAdapters); + JKQTPSynchronized>::ReadLocker lock(jkqtpSaveDataAdapters); for (int i=0; igetFormatID()) { QStringList columnNames; @@ -3583,7 +3585,7 @@ bool JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) { // add JKQTPPaintDeviceAdapter exporters const int filtersIndexFirstExporterPLugin=filterstrings.size(); { - JKQTPSynchronized>::Locker lock(jkqtpPaintDeviceAdapters); + JKQTPSynchronized>::ReadLocker lock(jkqtpPaintDeviceAdapters); for (int i=0; igetFilter(); filterextensions<>::Locker lock(jkqtpPaintDeviceAdapters); + JKQTPSynchronized>::ReadLocker lock(jkqtpPaintDeviceAdapters); // now we determine whether we selected a jkqtpPaintDeviceAdapters, if not adapterID will be <0 const int adapterID=[&](){ int idx=filtID-filtersIndexFirstExporterPLugin; diff --git a/screenshots/multithreaded.png b/screenshots/multithreaded.png index ed43bd89b5..11654b96b4 100644 Binary files a/screenshots/multithreaded.png and b/screenshots/multithreaded.png differ diff --git a/screenshots/multithreaded_small.png b/screenshots/multithreaded_small.png index d0e8537699..961d15b9ac 100644 Binary files a/screenshots/multithreaded_small.png and b/screenshots/multithreaded_small.png differ