enhancement: enable/disable fallback fonts
This commit is contained in:
parent
45118f5251
commit
451e201881
|
@ -5285,15 +5285,8 @@ void Editor::applySettings()
|
||||||
codeFolding().indentGuidesColor = pSettings->editor().indentLineColor();
|
codeFolding().indentGuidesColor = pSettings->editor().indentLineColor();
|
||||||
codeFolding().fillIndents = pSettings->editor().fillIndents();
|
codeFolding().fillIndents = pSettings->editor().fillIndents();
|
||||||
|
|
||||||
QStringList fontFamilies{
|
|
||||||
pSettings->editor().fontName(),
|
|
||||||
pSettings->editor().fallbackFontName(),
|
|
||||||
pSettings->editor().fallbackFontName2(),
|
|
||||||
pSettings->editor().fallbackFontName3(),
|
|
||||||
};
|
|
||||||
|
|
||||||
QFont f=QFont();
|
QFont f=QFont();
|
||||||
f.setFamilies(fontFamilies);
|
f.setFamilies(pSettings->editor().fontFamilies());
|
||||||
f.setPixelSize(pointToPixel(pSettings->editor().fontSize()));
|
f.setPixelSize(pointToPixel(pSettings->editor().fontSize()));
|
||||||
f.setStyleStrategy(QFont::PreferAntialias);
|
f.setStyleStrategy(QFont::PreferAntialias);
|
||||||
setFont(f);
|
setFont(f);
|
||||||
|
|
|
@ -697,7 +697,34 @@ void Settings::Editor::setFallbackFontName3(const QString &newFontName)
|
||||||
mFallbackFontName3 = newFontName;
|
mFallbackFontName3 = newFontName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::Editor::useFallbackFont2() const {
|
||||||
|
return mUseFallbackFont2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::Editor::setUseFallbackFont2(bool useFont) {
|
||||||
|
mUseFallbackFont2 = useFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Settings::Editor::useFallbackFont3() const {
|
||||||
|
return mUseFallbackFont3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::Editor::setUseFallbackFont3(bool useFont) {
|
||||||
|
mUseFallbackFont3 = useFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList Settings::Editor::fontFamilies() const
|
||||||
|
{
|
||||||
|
QStringList result {
|
||||||
|
mFontName,
|
||||||
|
mFallbackFontName,
|
||||||
|
};
|
||||||
|
if (mUseFallbackFont2)
|
||||||
|
result.append(mFallbackFontName2);
|
||||||
|
if (mUseFallbackFont3)
|
||||||
|
result.append(mFallbackFontName3);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int Settings::Editor::mouseSelectionScrollSpeed() const
|
int Settings::Editor::mouseSelectionScrollSpeed() const
|
||||||
{
|
{
|
||||||
|
@ -1373,6 +1400,9 @@ void Settings::Editor::doSave()
|
||||||
saveValue("fallback_font_name", mFallbackFontName);
|
saveValue("fallback_font_name", mFallbackFontName);
|
||||||
saveValue("fallback_font_name2", mFallbackFontName2);
|
saveValue("fallback_font_name2", mFallbackFontName2);
|
||||||
saveValue("fallback_font_name3", mFallbackFontName3);
|
saveValue("fallback_font_name3", mFallbackFontName3);
|
||||||
|
saveValue("use_fallback_font2", mUseFallbackFont2);
|
||||||
|
saveValue("use_fallback_font3", mUseFallbackFont3);
|
||||||
|
|
||||||
saveValue("font_size", mFontSize);
|
saveValue("font_size", mFontSize);
|
||||||
saveValue("font_only_monospaced", mFontOnlyMonospaced);
|
saveValue("font_only_monospaced", mFontOnlyMonospaced);
|
||||||
saveValue("line_spacing",mLineSpacing);
|
saveValue("line_spacing",mLineSpacing);
|
||||||
|
@ -1518,6 +1548,8 @@ void Settings::Editor::doLoad()
|
||||||
mFallbackFontName = stringValue("fallback_font_name",defaultCjkFontName);
|
mFallbackFontName = stringValue("fallback_font_name",defaultCjkFontName);
|
||||||
mFallbackFontName2 = stringValue("fallback_font_name2",DEFAULT_MONO_FONT);
|
mFallbackFontName2 = stringValue("fallback_font_name2",DEFAULT_MONO_FONT);
|
||||||
mFallbackFontName3 = stringValue("fallback_font_name3",DEFAULT_MONO_FONT);
|
mFallbackFontName3 = stringValue("fallback_font_name3",DEFAULT_MONO_FONT);
|
||||||
|
mUseFallbackFont2 = boolValue("use_fallback_font2", false);
|
||||||
|
mUseFallbackFont3 = boolValue("use_fallback_font3", false);
|
||||||
mFontSize = intValue("font_size",12);
|
mFontSize = intValue("font_size",12);
|
||||||
mFontOnlyMonospaced = boolValue("font_only_monospaced",true);
|
mFontOnlyMonospaced = boolValue("font_only_monospaced",true);
|
||||||
mLineSpacing = doubleValue("line_spacing",1.1);
|
mLineSpacing = doubleValue("line_spacing",1.1);
|
||||||
|
|
|
@ -364,6 +364,14 @@ public:
|
||||||
const QString &fallbackFontName3() const;
|
const QString &fallbackFontName3() const;
|
||||||
void setFallbackFontName3(const QString &newFontName);
|
void setFallbackFontName3(const QString &newFontName);
|
||||||
|
|
||||||
|
bool useFallbackFont2() const;
|
||||||
|
void setUseFallbackFont2(bool useFont);
|
||||||
|
|
||||||
|
bool useFallbackFont3() const;
|
||||||
|
void setUseFallbackFont3(bool useFont);
|
||||||
|
|
||||||
|
QStringList fontFamilies() const;
|
||||||
|
|
||||||
int mouseSelectionScrollSpeed() const;
|
int mouseSelectionScrollSpeed() const;
|
||||||
void setMouseSelectionScrollSpeed(int newMouseSelectionScrollSpeed);
|
void setMouseSelectionScrollSpeed(int newMouseSelectionScrollSpeed);
|
||||||
|
|
||||||
|
@ -456,6 +464,8 @@ public:
|
||||||
QString mFallbackFontName;
|
QString mFallbackFontName;
|
||||||
QString mFallbackFontName2;
|
QString mFallbackFontName2;
|
||||||
QString mFallbackFontName3;
|
QString mFallbackFontName3;
|
||||||
|
bool mUseFallbackFont2;
|
||||||
|
bool mUseFallbackFont3;
|
||||||
int mFontSize;
|
int mFontSize;
|
||||||
bool mFontOnlyMonospaced;
|
bool mFontOnlyMonospaced;
|
||||||
double mLineSpacing;
|
double mLineSpacing;
|
||||||
|
|
|
@ -24,6 +24,10 @@ EditorFontWidget::EditorFontWidget(const QString& name, const QString& group, QW
|
||||||
ui(new Ui::EditorFontWidget)
|
ui(new Ui::EditorFontWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
connect(ui->chkFallbackFont2, &QCheckBox::stateChanged,
|
||||||
|
this, &EditorFontWidget::onFallbackFontsCheckStateChanged);
|
||||||
|
connect(ui->chkFallbackFont3, &QCheckBox::stateChanged,
|
||||||
|
this, &EditorFontWidget::onFallbackFontsCheckStateChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorFontWidget::~EditorFontWidget()
|
EditorFontWidget::~EditorFontWidget()
|
||||||
|
@ -59,6 +63,9 @@ void EditorFontWidget::doLoad()
|
||||||
ui->cbFallbackFont->setCurrentFont(QFont(pSettings->editor().fallbackFontName()));
|
ui->cbFallbackFont->setCurrentFont(QFont(pSettings->editor().fallbackFontName()));
|
||||||
ui->cbFallbackFont2->setCurrentFont(QFont(pSettings->editor().fallbackFontName2()));
|
ui->cbFallbackFont2->setCurrentFont(QFont(pSettings->editor().fallbackFontName2()));
|
||||||
ui->cbFallbackFont3->setCurrentFont(QFont(pSettings->editor().fallbackFontName3()));
|
ui->cbFallbackFont3->setCurrentFont(QFont(pSettings->editor().fallbackFontName3()));
|
||||||
|
ui->chkFallbackFont2->setChecked(pSettings->editor().useFallbackFont2());
|
||||||
|
ui->chkFallbackFont3->setChecked(pSettings->editor().useFallbackFont3());
|
||||||
|
|
||||||
ui->spinFontSize->setValue(pSettings->editor().fontSize());
|
ui->spinFontSize->setValue(pSettings->editor().fontSize());
|
||||||
ui->spinLineSpacing->setValue(pSettings->editor().lineSpacing());
|
ui->spinLineSpacing->setValue(pSettings->editor().lineSpacing());
|
||||||
ui->chkLigature->setChecked(pSettings->editor().enableLigaturesSupport());
|
ui->chkLigature->setChecked(pSettings->editor().enableLigaturesSupport());
|
||||||
|
@ -89,6 +96,8 @@ void EditorFontWidget::doSave()
|
||||||
pSettings->editor().setFallbackFontName(ui->cbFallbackFont->currentFont().family());
|
pSettings->editor().setFallbackFontName(ui->cbFallbackFont->currentFont().family());
|
||||||
pSettings->editor().setFallbackFontName2(ui->cbFallbackFont2->currentFont().family());
|
pSettings->editor().setFallbackFontName2(ui->cbFallbackFont2->currentFont().family());
|
||||||
pSettings->editor().setFallbackFontName3(ui->cbFallbackFont3->currentFont().family());
|
pSettings->editor().setFallbackFontName3(ui->cbFallbackFont3->currentFont().family());
|
||||||
|
pSettings->editor().setUseFallbackFont2(ui->chkFallbackFont2->isChecked());
|
||||||
|
pSettings->editor().setUseFallbackFont3(ui->chkFallbackFont3->isChecked());
|
||||||
pSettings->editor().setFontSize(ui->spinFontSize->value());
|
pSettings->editor().setFontSize(ui->spinFontSize->value());
|
||||||
pSettings->editor().setLineSpacing(ui->spinLineSpacing->value());
|
pSettings->editor().setLineSpacing(ui->spinLineSpacing->value());
|
||||||
|
|
||||||
|
@ -114,3 +123,10 @@ void EditorFontWidget::doSave()
|
||||||
pSettings->editor().save();
|
pSettings->editor().save();
|
||||||
pMainWindow->updateEditorSettings();
|
pMainWindow->updateEditorSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorFontWidget::onFallbackFontsCheckStateChanged()
|
||||||
|
{
|
||||||
|
ui->cbFallbackFont2->setEnabled(ui->chkFallbackFont2->isChecked());
|
||||||
|
ui->cbFallbackFont3->setEnabled(ui->chkFallbackFont3->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,13 @@ class EditorFontWidget;
|
||||||
class EditorFontWidget : public SettingsWidget
|
class EditorFontWidget : public SettingsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EditorFontWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
explicit EditorFontWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
||||||
~EditorFontWidget();
|
~EditorFontWidget();
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void onFallbackFontsCheckStateChanged();
|
||||||
void on_chkOnlyMonospacedFonts_stateChanged(int arg1);
|
void on_chkOnlyMonospacedFonts_stateChanged(int arg1);
|
||||||
void on_chkGutterOnlyMonospacedFonts_stateChanged(int arg1);
|
void on_chkGutterOnlyMonospacedFonts_stateChanged(int arg1);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>876</width>
|
<width>876</width>
|
||||||
<height>713</height>
|
<height>781</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -156,13 +156,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_11">
|
|
||||||
<property name="text">
|
|
||||||
<string>Fallback Font 2:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QWidget" name="widget_9" native="true">
|
<widget class="QWidget" name="widget_9" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
@ -249,15 +242,8 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_12">
|
|
||||||
<property name="text">
|
|
||||||
<string>Fallback Font 3:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QWidget" name="widget_11" native="true">
|
<widget class="QWidget" name="panelFallbackFont2" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -272,7 +258,11 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFontComboBox" name="cbFallbackFont2"/>
|
<widget class="QFontComboBox" name="cbFallbackFont2">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_13">
|
<widget class="QLabel" name="label_13">
|
||||||
|
@ -298,7 +288,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QWidget" name="widget_12" native="true">
|
<widget class="QWidget" name="panelFallbackFont3" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -313,7 +303,11 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFontComboBox" name="cbFallbackFont3"/>
|
<widget class="QFontComboBox" name="cbFallbackFont3">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_14">
|
<widget class="QLabel" name="label_14">
|
||||||
|
@ -338,6 +332,20 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QCheckBox" name="chkFallbackFont2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fallback Font 2:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="chkFallbackFont3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fallback Font 3:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -144,13 +144,7 @@ void CPUDialog::resetEditorFont(float dpi)
|
||||||
{
|
{
|
||||||
|
|
||||||
QFont f=QFont();
|
QFont f=QFont();
|
||||||
f.setFamilies(
|
f.setFamilies(pSettings->editor().fontFamilies());
|
||||||
QStringList{
|
|
||||||
pSettings->editor().fontName(),
|
|
||||||
pSettings->editor().fallbackFontName(),
|
|
||||||
pSettings->editor().fallbackFontName2(),
|
|
||||||
pSettings->editor().fallbackFontName3(),
|
|
||||||
});
|
|
||||||
f.setPixelSize(pointToPixel(pSettings->editor().fontSize(),dpi));
|
f.setPixelSize(pointToPixel(pSettings->editor().fontSize(),dpi));
|
||||||
f.setStyleStrategy(QFont::PreferAntialias);
|
f.setStyleStrategy(QFont::PreferAntialias);
|
||||||
ui->txtCode->setFont(f);
|
ui->txtCode->setFont(f);
|
||||||
|
|
Loading…
Reference in New Issue