Fix NaviCube default font incorrect display in pref. page
This commit is contained in:
committed by
Uwe
parent
f373a1ddd3
commit
0079352b66
@@ -187,7 +187,7 @@ void DlgSettingsNavigation::loadSettings()
|
||||
// fill up font styles
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/NaviCube");
|
||||
std::string defaultSansserifFont = NaviCube::getDefaultSansserifFont().family().toStdString();
|
||||
std::string defaultSansserifFont = NaviCube::getDefaultSansserifFont().toStdString();
|
||||
|
||||
// we purposely allow all available fonts on the system
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
@@ -197,10 +197,6 @@ void DlgSettingsNavigation::loadSettings()
|
||||
#endif
|
||||
ui->naviCubeFontName->addItems(familyNames);
|
||||
|
||||
// if the parameter has not yet been set, do so immediately
|
||||
// this assures it is set even if the user cancels the dialog
|
||||
if (hGrp->GetASCII("FontString", "").empty())
|
||||
hGrp->SetASCII("FontString", defaultSansserifFont.c_str());
|
||||
int indexFamilyNames = familyNames.indexOf(
|
||||
QString::fromStdString(hGrp->GetASCII("FontString", defaultSansserifFont.c_str())));
|
||||
if (indexFamilyNames < 0)
|
||||
|
||||
@@ -292,22 +292,20 @@ void NaviCube::setFontSize(int size)
|
||||
m_NaviCubeImplementation->m_CubeTextSize = size;
|
||||
}
|
||||
|
||||
// sets a default sansserif font
|
||||
// the Helvetica font is a good start for most OSes
|
||||
QFont NaviCube::getDefaultSansserifFont()
|
||||
QString NaviCube::getDefaultSansserifFont()
|
||||
{
|
||||
// Windows versions since 2017 have the 'Bahnschrift' font (a condensed
|
||||
// sans serif font, optimized for readability despite being condensed),
|
||||
// we first check for that.
|
||||
QFont font(QString::fromLatin1("Bahnschrift"));
|
||||
if (font.exactMatch())
|
||||
return font;
|
||||
QFont font(QStringLiteral("Bahnschrift"));
|
||||
if (!font.exactMatch())
|
||||
// On systems without 'Bahnschrift' we check for 'Helvetica' or its closest match
|
||||
// as default sans serif font. (For Windows 7 this will e.g. result in 'Arial'.)
|
||||
font = QFont(QStringLiteral("Helvetica"));
|
||||
|
||||
// On systems without 'Bahnschrift' we check for 'Helvetica' or its closest match
|
||||
// as default sans serif font. (For Windows 7 this will e.g. result in 'Arial'.)
|
||||
font = QString::fromLatin1("Helvetica");
|
||||
font.setStyleHint(QFont::SansSerif);
|
||||
return font;
|
||||
// QFontInfo is required to get the actually matched font family
|
||||
return QFontInfo(font).family();
|
||||
}
|
||||
|
||||
int NaviCube::getDefaultFontSize()
|
||||
@@ -406,7 +404,7 @@ void NaviCubeImplementation::OnChange(ParameterGrp::SubjectType& rCaller,
|
||||
}
|
||||
else if (strcmp(reason, "FontString") == 0) {
|
||||
m_CubeTextFont = (rGrp.GetASCII(
|
||||
reason, NaviCube::getDefaultSansserifFont().family().toStdString().c_str()));
|
||||
reason, NaviCube::getDefaultSansserifFont().toStdString().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
void setNaviStepByTurn(int steps);
|
||||
void setFont(std::string font);
|
||||
void setFontSize(int size);
|
||||
static QFont getDefaultSansserifFont();
|
||||
static QString getDefaultSansserifFont();
|
||||
int getDefaultFontSize();
|
||||
static void setNaviCubeCommands(const std::vector<std::string>& cmd);
|
||||
static void setNaviCubeLabels(const std::vector<std::string>& labels);
|
||||
|
||||
@@ -399,7 +399,7 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
|
||||
}
|
||||
else if (strcmp(Reason, "FontString") == 0) {
|
||||
std::string font = rGrp.GetASCII(
|
||||
"FontString", NaviCube::getDefaultSansserifFont().family().toStdString().c_str());
|
||||
"FontString", NaviCube::getDefaultSansserifFont().toStdString().c_str());
|
||||
_viewer->getNavigationCube()->setFont(font);
|
||||
}
|
||||
else if (strcmp(Reason,"UseVBO") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user