diff --git a/lib/jkqtmathtext/CMakeLists.txt b/lib/jkqtmathtext/CMakeLists.txt index a386fe70e5..1604240031 100644 --- a/lib/jkqtmathtext/CMakeLists.txt +++ b/lib/jkqtmathtext/CMakeLists.txt @@ -50,6 +50,9 @@ if(JKQtPlotter_BUILD_SHARED_LIBS) $ $ ) + if(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS) + target_compile_definitions(${libsh_name} PRIVATE JKQTMATHTEXT_COMPILED_WITH_XITS) + endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS) set_target_properties(${libsh_name} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS "ON") write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake VERSION ${PROJECT_VERSION} @@ -61,6 +64,9 @@ if(JKQtPlotter_BUILD_STATIC_LIBS) target_compile_features(${lib_name} PUBLIC cxx_std_11) set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") + if(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS) + target_compile_definitions(${lib_name} PRIVATE JKQTMATHTEXT_COMPILED_WITH_XITS) + endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS) target_link_libraries(${lib_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport JKQTCommonLib) target_include_directories(${lib_name} PUBLIC $ diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index c8e461241d..9510496f40 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -3257,7 +3257,7 @@ JKQTMathText::JKQTMathText(QObject* parent): QObject(parent) { //std::chrono::high_resolution_clock::time_point t0=std::chrono::high_resolution_clock::now(); - Q_INIT_RESOURCE(xits); + initJKQTMathTextResources(); //qDebug()<<"init_resoucre: "<(std::chrono::high_resolution_clock::now()-t0).count()/1000.0<<"ms"; t0=std::chrono::high_resolution_clock::now(); QFontDatabase fontdb; //qDebug()<<"init_fontDB: "<(std::chrono::high_resolution_clock::now()-t0).count()/1000.0<<"ms"; t0=std::chrono::high_resolution_clock::now(); @@ -4983,7 +4983,13 @@ QString JKQTMathText::MTplainTextNode::textTransform(const QString &_text, JKQTM void initJKQTMathTextResources() { - Q_INIT_RESOURCE(xits); + static bool initialized=false; + if (!initialized) { +#ifdef JKQTMATHTEXT_COMPILED_WITH_XITS + Q_INIT_RESOURCE(xits); +#endif + initialized=true; + } } JKQTMathText::MTnodeSize::MTnodeSize(): diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h index 44d2119c40..163a07c828 100644 --- a/lib/jkqtmathtext/jkqtmathtext.h +++ b/lib/jkqtmathtext/jkqtmathtext.h @@ -421,6 +421,11 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { * These are included by default in this library and also activated by default. * * \image html jkqtmathparser_xits.png + * + * \note The XITS fonts can be compiled into JKQTPlotter, when the CMake-option \c is set to ON (default: ON). + * Then the XITS fonts are added as Qt-Ressources to the library binary. + * If this is not the case, you have to provide the XITS fonts on the target system by other means, if you want + * to use them. */ bool useXITS(bool mathModeOnly=true);