Browse Source

Add fonts for Korean

Fixed places where the font family was not being defined (therefore using the default system font)
QGC4.4
Gus Grubba 6 years ago
parent
commit
c61fa31d31
  1. 2
      qgcresources.qrc
  2. BIN
      resources/fonts/NanumGothic-Bold.ttf
  3. BIN
      resources/fonts/NanumGothic-Regular.ttf
  4. 11
      src/QGCApplication.cc
  5. 1
      src/QmlControls/QGCCheckBox.qml
  6. 3
      src/QmlControls/QGCHoverButton.qml
  7. 1
      src/QmlControls/QGCLabel.qml
  8. 1
      src/QmlControls/QGCRadioButton.qml
  9. 4
      src/QmlControls/ScreenTools.qml
  10. 26
      src/QmlControls/ScreenToolsController.cc
  11. 5
      src/QmlControls/ScreenToolsController.h

2
qgcresources.qrc

@ -12,6 +12,8 @@ @@ -12,6 +12,8 @@
<qresource prefix="/fonts">
<file alias="opensans">resources/fonts/OpenSans-Regular.ttf</file>
<file alias="opensans-demibold">resources/fonts/OpenSans-Semibold.ttf</file>
<file alias="NanumGothic-Regular">resources/fonts/NanumGothic-Regular.ttf</file>
<file alias="NanumGothic-Bold">resources/fonts/NanumGothic-Bold.ttf</file>
</qresource>
<qresource prefix="/qmlimages">
<file alias="AirframeComponentIcon.png">src/AutoPilotPlugins/Common/Images/AirframeComponentIcon.png</file>

BIN
resources/fonts/NanumGothic-Bold.ttf

Binary file not shown.

BIN
resources/fonts/NanumGothic-Regular.ttf

Binary file not shown.

11
src/QGCApplication.cc

@ -477,8 +477,15 @@ bool QGCApplication::_initForNormalAppBoot() @@ -477,8 +477,15 @@ bool QGCApplication::_initForNormalAppBoot()
//-- See App.SettinsGroup.json for index
int langID = toolbox()->settingsManager()->appSettings()->language()->rawValue().toInt();
//-- Don't load custom fonts if not using standard character set
if(langID != 6 /*Korean*/ && langID != 9 /*Chinese*/) {
//-- Load font appropriate for the language
if(langID == 6 /*Korean*/) {
if(QFontDatabase::addApplicationFont(":/fonts/NanumGothic-Regular") < 0) {
qWarning() << "Could not load /fonts/NanumGothic-Regular font";
}
if(QFontDatabase::addApplicationFont(":/fonts/NanumGothic-Bold") < 0) {
qWarning() << "Could not load /fonts/NanumGothic-Bold font";
}
} else {
if(QFontDatabase::addApplicationFont(":/fonts/opensans") < 0) {
qWarning() << "Could not load /fonts/opensans font";
}

1
src/QmlControls/QGCCheckBox.qml

@ -28,6 +28,7 @@ CheckBox { @@ -28,6 +28,7 @@ CheckBox {
text: control.text
font.pointSize: textFontPointSize
font.bold: control.textBold
font.family: ScreenTools.normalFontFamily
color: control.textColor
anchors.centerIn: parent
}

3
src/QmlControls/QGCHoverButton.qml

@ -80,11 +80,10 @@ Button { @@ -80,11 +80,10 @@ Button {
Text {
id: innerText
text: button.text
color: _currentContentColor
width: parent.width
font.family: ScreenTools.normalFontFamily
font.pointSize: ScreenTools.defaultFontPointSize
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter

1
src/QmlControls/QGCLabel.qml

@ -7,7 +7,6 @@ import QGroundControl.ScreenTools 1.0 @@ -7,7 +7,6 @@ import QGroundControl.ScreenTools 1.0
Text {
QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
font.pointSize: ScreenTools.defaultFontPointSize
font.family: ScreenTools.normalFontFamily
color: __qgcPal.text

1
src/QmlControls/QGCRadioButton.qml

@ -35,6 +35,7 @@ RadioButton { @@ -35,6 +35,7 @@ RadioButton {
contentItem: Text {
text: control.text
font.family: ScreenTools.normalFontFamily
font.pointSize: textFontPointSize
font.bold: control.textBold
color: control.textColor

4
src/QmlControls/ScreenTools.qml

@ -94,8 +94,8 @@ Item { @@ -94,8 +94,8 @@ Item {
property real checkBoxIndicatorSize: Math.round(defaultFontPixelHeight * (isMobile ? 1.5 : 1.0))
property real radioButtonIndicatorSize: checkBoxIndicatorSize
readonly property string normalFontFamily: "opensans"
readonly property string demiboldFontFamily: "opensans-demibold"
readonly property string normalFontFamily: ScreenToolsController.normalFontFamily
readonly property string demiboldFontFamily: ScreenToolsController.boldFontFamily
readonly property string fixedFontFamily: ScreenToolsController.fixedFontFamily
/* This mostly works but for some reason, reflowWidths() in SetupView doesn't change size.
I've disabled (in release builds) until I figure out why. Changes require a restart for now.

26
src/QmlControls/ScreenToolsController.cc

@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
#include <QFontDatabase>
#include <QScreen>
#include "SettingsManager.h"
#if defined(__ios__)
#include <sys/utsname.h>
#endif
@ -41,3 +43,27 @@ ScreenToolsController::fixedFontFamily() const @@ -41,3 +43,27 @@ ScreenToolsController::fixedFontFamily() const
{
return QFontDatabase::systemFont(QFontDatabase::FixedFont).family();
}
QString
ScreenToolsController::normalFontFamily() const
{
//-- See App.SettinsGroup.json for index
int langID = qgcApp()->toolbox()->settingsManager()->appSettings()->language()->rawValue().toInt();
if(langID == 6 /*Korean*/) {
return QString("fonts/NanumGothic-Regular");
} else {
return QString("opensans");
}
}
QString
ScreenToolsController::boldFontFamily() const
{
//-- See App.SettinsGroup.json for index
int langID = qgcApp()->toolbox()->settingsManager()->appSettings()->language()->rawValue().toInt();
if(langID == 6 /*Korean*/) {
return QString("NanumGothic-Bold");
} else {
return QString("opensans-demibold");
}
}

5
src/QmlControls/ScreenToolsController.h

@ -39,6 +39,8 @@ public: @@ -39,6 +39,8 @@ public:
Q_PROPERTY(bool isSerialAvailable READ isSerialAvailable CONSTANT)
Q_PROPERTY(QString iOSDevice READ iOSDevice CONSTANT)
Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily CONSTANT)
Q_PROPERTY(QString normalFontFamily READ normalFontFamily CONSTANT)
Q_PROPERTY(QString boldFontFamily READ boldFontFamily CONSTANT)
// Returns current mouse position
Q_INVOKABLE int mouseX(void) { return QCursor::pos().x(); }
@ -102,7 +104,8 @@ public: @@ -102,7 +104,8 @@ public:
QString iOSDevice () const;
QString fixedFontFamily () const;
QString normalFontFamily () const;
QString boldFontFamily () const;
};
#endif

Loading…
Cancel
Save