Optionally bundle font.

This commit is contained in:
Black Hat 2018-11-26 07:53:04 +08:00
parent 49ab6684e3
commit d1186ea810
6 changed files with 25 additions and 4 deletions

View File

@ -17,7 +17,7 @@ before_build:
- git submodule update --init --recursive - git submodule update --init --recursive
build_script: build_script:
- qmake spectral.pro CONFIG+=release CONFIG+=qtquickcompiler PREFIX="%DEPLOY_DIR%" - qmake spectral.pro CONFIG+=release CONFIG+=qtquickcompiler BUNDLE_FONT=true PREFIX="%DEPLOY_DIR%"
- nmake - nmake
after_build: after_build:

BIN
assets/font/roboto.ttf Normal file

Binary file not shown.

BIN
assets/font/twemoji.ttf Normal file

Binary file not shown.

6
font.qrc Normal file
View File

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file>assets/font/roboto.ttf</file>
<file>assets/font/twemoji.ttf</file>
</qresource>
</RCC>

View File

@ -20,6 +20,9 @@ isEmpty(USE_SYSTEM_SORTFILTERPROXYMODEL) {
isEmpty(USE_SYSTEM_QMATRIXCLIENT) { isEmpty(USE_SYSTEM_QMATRIXCLIENT) {
USE_SYSTEM_QMATRIXCLIENT = false USE_SYSTEM_QMATRIXCLIENT = false
} }
isEmpty(BUNDLE_FONT) {
BUNDLE_FONT = false
}
$$USE_SYSTEM_QMATRIXCLIENT { $$USE_SYSTEM_QMATRIXCLIENT {
PKGCONFIG += QMatrixClient PKGCONFIG += QMatrixClient
@ -45,8 +48,14 @@ DEFINES += QT_DEPRECATED_WARNINGS
# You can also select to disable deprecated APIs only up to a certain version of Qt. # You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
RESOURCES += \ RESOURCES += res.qrc
res.qrc $$BUNDLE_FONT {
message("Bundling fonts.")
DEFINES += BUNDLE_FONT
RESOURCES += font.qrc
} else {
message("Using fonts from operating system.")
}
# Additional import path used to resolve QML modules in Qt Creator's code model # Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH += imports/ QML_IMPORT_PATH += imports/

View File

@ -1,3 +1,4 @@
#include <QFontDatabase>
#include <QGuiApplication> #include <QGuiApplication>
#include <QNetworkProxy> #include <QNetworkProxy>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
@ -61,6 +62,11 @@ int main(int argc, char *argv[]) {
qRegisterMetaType<SpectralRoom *>("SpectralRoom*"); qRegisterMetaType<SpectralRoom *>("SpectralRoom*");
qRegisterMetaType<SpectralUser *>("SpectralUser*"); qRegisterMetaType<SpectralUser *>("SpectralUser*");
#if defined(BUNDLE_FONT)
QFontDatabase::addApplicationFont(":/assets/font/roboto.ttf");
QFontDatabase::addApplicationFont(":/assets/font/twemoji.ttf");
#endif
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
engine.addImportPath("qrc:/imports"); engine.addImportPath("qrc:/imports");