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
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
after_build:
@ -27,4 +27,4 @@ after_build:
artifacts:
- path: spectral.zip
name: portable
name: portable

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) {
USE_SYSTEM_QMATRIXCLIENT = false
}
isEmpty(BUNDLE_FONT) {
BUNDLE_FONT = false
}
$$USE_SYSTEM_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.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
RESOURCES += \
res.qrc
RESOURCES += 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
QML_IMPORT_PATH += imports/

View File

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