diff --git a/qrenderdoc/Code/Interface/PersistantConfig.h b/qrenderdoc/Code/Interface/PersistantConfig.h index 29fdaad8d..2d9061dc1 100644 --- a/qrenderdoc/Code/Interface/PersistantConfig.h +++ b/qrenderdoc/Code/Interface/PersistantConfig.h @@ -491,6 +491,12 @@ DECLARE_REFLECTION_STRUCT(BugReport); "Defaults to ``1.0`` which means 100%."); \ CONFIG_SETTING_VAL(public, float, float, Font_GlobalScale, 1.0f) \ \ + DOCUMENT( \ + "The font family to use in the UI.\n" \ + "\n" \ + "Defaults to an empty string which means to use the system default."); \ + CONFIG_SETTING_VAL(public, QString, rdcstr, Font_Family, "") \ + \ DOCUMENT( \ "``True`` if a monospaced font should be used in all places where data is displayed, even " \ "if the data is not tabular such as names.\n" \ diff --git a/qrenderdoc/Code/QRDUtils.cpp b/qrenderdoc/Code/QRDUtils.cpp index ac420fa6e..5a917802c 100644 --- a/qrenderdoc/Code/QRDUtils.cpp +++ b/qrenderdoc/Code/QRDUtils.cpp @@ -2400,6 +2400,7 @@ QFont *Formatter::m_Font = NULL; QFont *Formatter::m_FixedFont = NULL; float Formatter::m_FontBaseSize = 10.0f; // this should always be overridden below, but just in // case let's pick a sensible value +QString Formatter::m_DefaultFontFamily; float Formatter::m_FixedFontBaseSize = 10.0f; QColor Formatter::m_DarkChecker, Formatter::m_LightChecker; @@ -2419,14 +2420,23 @@ void Formatter::setParams(const PersistantConfig &config) m_FontBaseSize = QApplication::font().pointSizeF(); m_FixedFont = new QFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); m_FixedFontBaseSize = m_FixedFont->pointSizeF(); + m_DefaultFontFamily = QApplication::font().family(); } + // this is only used for display to the user + if(m_DefaultFontFamily.isEmpty()) + m_DefaultFontFamily = lit("System font"); + *m_Font = config.Font_PreferMonospaced ? QFontDatabase::systemFont(QFontDatabase::FixedFont) : QFont(); + if(!config.Font_Family.isEmpty()) + m_Font->setFamily(config.Font_Family); m_Font->setPointSizeF(m_FontBaseSize * config.Font_GlobalScale); QFont f = QApplication::font(); f.setPointSizeF(m_FontBaseSize * config.Font_GlobalScale); + if(!config.Font_Family.isEmpty()) + f.setFamily(config.Font_Family); QApplication::setFont(f); m_FixedFont->setPointSizeF(m_FixedFontBaseSize * config.Font_GlobalScale); diff --git a/qrenderdoc/Code/QRDUtils.h b/qrenderdoc/Code/QRDUtils.h index e4c9b4199..c86352e94 100644 --- a/qrenderdoc/Code/QRDUtils.h +++ b/qrenderdoc/Code/QRDUtils.h @@ -261,11 +261,13 @@ struct Formatter static const QFont &FixedFont() { return *m_FixedFont; } static const QColor DarkCheckerColor() { return m_DarkChecker; } static const QColor LightCheckerColor() { return m_LightChecker; } + static QString DefaultFontFamily() { return m_DefaultFontFamily; } private: static int m_minFigures, m_maxFigures, m_expNegCutoff, m_expPosCutoff; static double m_expNegValue, m_expPosValue; static QFont *m_Font, *m_FixedFont; static float m_FontBaseSize, m_FixedFontBaseSize; + static QString m_DefaultFontFamily; static QColor m_DarkChecker, m_LightChecker; }; diff --git a/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp b/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp index bf4ceb91d..56db3aad6 100644 --- a/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp @@ -25,6 +25,7 @@ #include "SettingsDialog.h" #include #include +#include #include #include #include @@ -46,6 +47,9 @@ SettingsDialog::SettingsDialog(ICaptureContext &ctx, QWidget *parent) m_ReplayOptions = new ReplayOptionsSelector(m_Ctx, false, this); + QStringList fontFamilies = QFontDatabase().families(); + fontFamilies.insert(0, tr("Default (%1)").arg(Formatter::DefaultFontFamily())); + ui->replayOptionsLayout->insertWidget(0, m_ReplayOptions); QString styleChooseTooltip = ui->UIStyle->toolTip(); @@ -59,12 +63,29 @@ SettingsDialog::SettingsDialog(ICaptureContext &ctx, QWidget *parent) for(int i = 0; i < StyleData::numAvailable; i++) ui->UIStyle->addItem(StyleData::availStyles[i].styleName); + ui->Font_Family->addItems(fontFamilies); + ui->Font_GlobalScale->addItems({lit("50%"), lit("75%"), lit("100%"), lit("125%"), lit("150%"), lit("175%"), lit("200%"), lit("250%"), lit("300%"), lit("400%")}); ui->Font_GlobalScale->setCurrentText( QString::number(ceil(m_Ctx.Config().Font_GlobalScale * 100)) + lit("%")); + int curFontOption = -1; + for(int i = 0; i < ui->Font_Family->count(); i++) + { + if(ui->Font_Family->itemText(i) == m_Ctx.Config().Font_Family) + { + curFontOption = i; + break; + } + } + + if(m_Ctx.Config().Font_Family.isEmpty() || curFontOption < 0) + curFontOption = 0; + + ui->Font_Family->setCurrentIndex(curFontOption); + for(int i = 0; i < ui->Font_GlobalScale->count(); i++) { if(ui->Font_GlobalScale->currentText() == ui->Font_GlobalScale->itemText(i)) @@ -311,6 +332,21 @@ void SettingsDialog::on_okButton_accepted() accept(); } +void SettingsDialog::on_Font_Family_currentIndexChanged(int index) +{ + if(m_Init) + return; + + if(index == 0) + m_Ctx.Config().Font_Family.clear(); + else + m_Ctx.Config().Font_Family = ui->Font_Family->currentText(); + + m_Ctx.Config().SetupFormatting(); + + m_Ctx.Config().Save(); +} + void SettingsDialog::on_Font_GlobalScale_currentIndexChanged(int index) { Font_GlobalScale_returnPressed(); diff --git a/qrenderdoc/Windows/Dialogs/SettingsDialog.h b/qrenderdoc/Windows/Dialogs/SettingsDialog.h index 331ab1ad3..c0e012550 100644 --- a/qrenderdoc/Windows/Dialogs/SettingsDialog.h +++ b/qrenderdoc/Windows/Dialogs/SettingsDialog.h @@ -56,6 +56,7 @@ private slots: void on_okButton_accepted(); // general + void on_Font_Family_currentIndexChanged(int index); void on_Font_GlobalScale_currentIndexChanged(int index); void Font_GlobalScale_returnPressed(); void on_UIStyle_currentIndexChanged(int index); diff --git a/qrenderdoc/Windows/Dialogs/SettingsDialog.ui b/qrenderdoc/Windows/Dialogs/SettingsDialog.ui index 3c305f647..bb52efdb8 100644 --- a/qrenderdoc/Windows/Dialogs/SettingsDialog.ui +++ b/qrenderdoc/Windows/Dialogs/SettingsDialog.ui @@ -7,7 +7,7 @@ 0 0 564 - 530 + 554 @@ -115,6 +115,26 @@ + + + The default font family to be used for text. This will be overridden by the default monospace font if the below option for monospace override is chosen. + + + Default font family (restart required) + + + + + + + The default font family to be used for text. This will be overridden by the default monospace font if the below option for monospace override is chosen. + + + false + + + + A global scale for all fonts in the program. This will only scale text, icons and other UI elements will be scaled according to DPI settings as normal. @@ -124,7 +144,7 @@ - + A global scale for all fonts in the program. This will only scale text, icons and other UI elements will be scaled according to DPI settings as normal. @@ -134,7 +154,7 @@ - + Wherever possible a monospaced font will be used instead of the default font @@ -144,7 +164,7 @@ - + Wherever possible a monospaced font will be used instead of the default font @@ -154,14 +174,14 @@ - + Qt::Horizontal - + At least this many decimal places will be displayed on floats. @@ -172,7 +192,7 @@ e.g. a value of 2 means 0 will display as 0.00, 0.5 as 0.50. A value of 5 would - + Decimals will display at least this many digits. @@ -183,7 +203,7 @@ e.g. a value of 2 means 0 will display as 0.00, 0.5 as 0.50 - + No more decimal places than this will be displayed on floats. @@ -194,7 +214,7 @@ e.g. a value of 5 means 0.123456789 will display as 0.12345 - + No more decimal places than this will be displayed on floats. @@ -205,7 +225,7 @@ e.g. a value of 5 means 0.123456789 will display as 0.12345 and 123.123456789 wi - + Any numbers smaller than this exponent will be displayed in scientific notation. @@ -216,7 +236,7 @@ E.g. a value of 3 means 0.005 / 10 = 5E-4 - + Any numbers smaller than this exponent will be displayed in scientific notation. @@ -227,7 +247,7 @@ E.g. a value of 3 means 0.005 / 10 = 5E-4 - + Any numbers larger than this exponent will be displayed in scientific notation. @@ -238,7 +258,7 @@ e.g. 1000 * 10 = 1e4 - + Any numbers larger than this exponent will be displayed in scientific notation. @@ -252,7 +272,7 @@ e.g. 1000 * 10 = 1e4 - + Changes the directory where capture files are saved after being created, until saved manually or deleted. @@ -264,7 +284,7 @@ Defaults to %TEMP%. - + Changes the directory where capture files are saved after being created, until saved manually or deleted. @@ -273,7 +293,7 @@ Defaults to %TEMP%. - + Changes the directory where capture files are saved after being created, until saved manually or deleted. @@ -285,7 +305,7 @@ Defaults to %TEMP%. - + Changes the default directory for the save dialog when saving capture files. @@ -297,7 +317,7 @@ Defaults to blank, which follows system default behaviour. - + Changes the default directory for the save dialog when saving capture files. @@ -306,7 +326,7 @@ Defaults to blank, which follows system default behaviour. - + Changes the default directory for the save dialog when saving capture files. @@ -318,7 +338,7 @@ Defaults to blank, which follows system default behaviour. - + Enables functionality on the capture application window that will insert RenderDoc automatically @@ -333,7 +353,7 @@ Since this is a global system hook it must be used carefully and only when neces - + Enables functionality on the capture application window that will insert RenderDoc automatically @@ -348,7 +368,7 @@ Since this is a global system hook it must be used carefully and only when neces - + Enables the ability to inject into processes on windows. @@ -362,7 +382,7 @@ program should be launched through RenderDoc via the Launch Process panel. - + Enables the ability to inject into processes on windows. @@ -376,7 +396,7 @@ program should be launched through RenderDoc via the Launch Process panel. - + Allows RenderDoc to phone home to https://renderdoc.org to anonymously check for new versions. @@ -386,7 +406,7 @@ program should be launched through RenderDoc via the Launch Process panel. - + Allows RenderDoc to phone home to https://renderdoc.org to anonymously check for new versions. @@ -396,7 +416,7 @@ program should be launched through RenderDoc via the Launch Process panel. - + If a capture is marked as being created on a significantly different system (different OS or platform) @@ -409,7 +429,7 @@ This option overrides that and will always replay locally if the local context i - + If a capture is marked as being created on a significantly different system (different OS or platform) @@ -422,7 +442,7 @@ This option overrides that and will always replay locally if the local context i - + Qt::Vertical