fixed issue #41: "Build error when JKQtPlotter_BUILD_INCLUDE_XITS_FONTS set to OFF", code tried to use XITS-ressources, which were not there oif option is switched off. --> solved by adding optional private preprocessor definition

(cherry picked from commit f6505e35fc)
This commit is contained in:
jkriege2 2020-06-28 09:49:20 +02:00
parent 1e47a86268
commit 0edb1becd3
3 changed files with 19 additions and 2 deletions

View File

@ -50,6 +50,9 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>

View File

@ -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::duration_cast<std::chrono::microseconds>(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::duration_cast<std::chrono::microseconds>(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():

View File

@ -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);