forked from qt-creator/qt-creator
Loading .ttf fonts from share/qtcreator/fonts
We add all .ttf fonts found in share/qtcreator/fonts to QFontDatabase. Change-Id: I133a5298bd4696b99fa2350758baf8abd8b16fd8 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
committed by
Alessandro Portale
parent
26246af9b3
commit
05b5b61673
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QFontDatabase>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
@@ -295,6 +296,14 @@ static inline QSettings *userSettings()
|
|||||||
static const char *SHARE_PATH =
|
static const char *SHARE_PATH =
|
||||||
Utils::HostOsInfo::isMacHost() ? "/../Resources" : "/../share/qtcreator";
|
Utils::HostOsInfo::isMacHost() ? "/../Resources" : "/../share/qtcreator";
|
||||||
|
|
||||||
|
void loadFonts()
|
||||||
|
{
|
||||||
|
const QDir dir(QCoreApplication::applicationDirPath() + SHARE_PATH + "/fonts/");
|
||||||
|
|
||||||
|
foreach (const QFileInfo &fileInfo, dir.entryList(QStringList("*.ttf"), QDir::Files))
|
||||||
|
QFontDatabase::addApplicationFont(fileInfo.absoluteFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
const char *highDpiEnvironmentVariable = setHighDpiEnvironmentVariable();
|
const char *highDpiEnvironmentVariable = setHighDpiEnvironmentVariable();
|
||||||
@@ -311,6 +320,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
SharedTools::QtSingleApplication app((QLatin1String(appNameC)), argc, argv);
|
SharedTools::QtSingleApplication app((QLatin1String(appNameC)), argc, argv);
|
||||||
|
|
||||||
|
loadFonts();
|
||||||
|
|
||||||
if (highDpiEnvironmentVariable)
|
if (highDpiEnvironmentVariable)
|
||||||
qunsetenv(highDpiEnvironmentVariable);
|
qunsetenv(highDpiEnvironmentVariable);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user