forked from qt-creator/qt-creator
QmlPuppet: Register fonts at scene creation
Automatically register all fonts from 'fonts' folder at scene creation. Fixes: QDS-3624 Change-Id: I38728e458952ea52c941244daaca715102a93c55 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -88,6 +88,9 @@
|
||||
#include <QUrl>
|
||||
#include <QVariant>
|
||||
#include <qqmllist.h>
|
||||
#include <QFontDatabase>
|
||||
#include <QFileInfo>
|
||||
#include <QDirIterator>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -322,6 +325,7 @@ void NodeInstanceServer::stopRenderTimer()
|
||||
|
||||
void NodeInstanceServer::createScene(const CreateSceneCommand &command)
|
||||
{
|
||||
registerFonts(command.resourceUrl);
|
||||
setTranslationLanguage(command.language);
|
||||
initializeView();
|
||||
|
||||
@@ -1502,4 +1506,13 @@ void NodeInstanceServer::setupState(qint32 stateInstanceId)
|
||||
}
|
||||
}
|
||||
|
||||
void NodeInstanceServer::registerFonts(const QUrl &resourceUrl) const
|
||||
{
|
||||
// Autoregister all fonts found inside the project
|
||||
QDirIterator it {QFileInfo(resourceUrl.toLocalFile()).absoluteFilePath(),
|
||||
{"*.ttf", "*.otf"}, QDir::Files, QDirIterator::Subdirectories};
|
||||
while (it.hasNext())
|
||||
QFontDatabase::addApplicationFont(it.next());
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Reference in New Issue
Block a user