Original font height option
This commit is contained in:
parent
3642db51d7
commit
3ecb1ac163
9 changed files with 27 additions and 4 deletions
|
|
@ -2328,6 +2328,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ktg_fonts_semibold_is_bold" = "Bold font face";
|
||||
"ktg_fonts_monospaced" = "Monospaced font";
|
||||
"ktg_fonts_use_system_font" = "Use system font";
|
||||
"ktg_fonts_use_original_metrics" = "Original font height";
|
||||
|
||||
"ktg_fonts_restart_new_fonts" = "You will need to restart app to apply new fonts.\n\nRestart now?";
|
||||
"ktg_fonts_restart_reset" = "You will need to restart app to reset fonts to default.\n\nRestart now?";
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@
|
|||
"ktg_fonts_semibold_is_bold": "Жирное начертание",
|
||||
"ktg_fonts_monospaced": "Моноширинный шрифт",
|
||||
"ktg_fonts_use_system_font": "Использовать системный шрифт",
|
||||
"ktg_fonts_use_original_metrics": "Оригинальная высота шрифта",
|
||||
"ktg_fonts_restart_new_fonts": "Для применения новых шрифтов требуется перезапуск.\n\nПерезапустить сейчас?",
|
||||
"ktg_fonts_restart_reset": "Для сброса шрифтов к стандартным требуется перезапуск.\n\nПерезапустить сейчас?",
|
||||
"ktg_settings_network": "Сеть",
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
|||
|
||||
FontsBox::FontsBox(QWidget* parent)
|
||||
: _useSystemFont(this, tr::ktg_fonts_use_system_font(tr::now), cUseSystemFont())
|
||||
, _useOriginalMetrics(this, tr::ktg_fonts_use_original_metrics(tr::now), cUseOriginalMetrics())
|
||||
, _mainFontName(this, st::defaultInputField, tr::ktg_fonts_main())
|
||||
, _semiboldFontName(this, st::defaultInputField, tr::ktg_fonts_semibold())
|
||||
, _semiboldIsBold(this, tr::ktg_fonts_semibold_is_bold(tr::now), cSemiboldFontIsBold())
|
||||
|
|
@ -51,12 +52,13 @@ void FontsBox::prepare() {
|
|||
_aboutHeight = _about.countHeight(st::boxWidth - st::boxPadding.left() * 1.5);
|
||||
|
||||
setDimensions(st::boxWidth, _useSystemFont->height()
|
||||
+ _useOriginalMetrics->height()
|
||||
+ _mainFontName->height()
|
||||
+ _semiboldFontName->height()
|
||||
+ _semiboldIsBold->height()
|
||||
+ _monospacedFontName->height()
|
||||
+ _aboutHeight
|
||||
+ st::boxLittleSkip * 2);
|
||||
+ st::boxLittleSkip * 3);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -66,11 +68,12 @@ void FontsBox::paintEvent(QPaintEvent *e) {
|
|||
Painter p(this);
|
||||
int32 w = st::boxWidth - st::boxPadding.left() * 1.5;
|
||||
int32 abouty = _useSystemFont->height()
|
||||
+ _useOriginalMetrics->height()
|
||||
+ _mainFontName->height()
|
||||
+ _semiboldFontName->height()
|
||||
+ _semiboldIsBold->height()
|
||||
+ _monospacedFontName->height()
|
||||
+ st::boxLittleSkip * 2;
|
||||
+ st::boxLittleSkip * 3;
|
||||
p.setPen(st::windowSubTextFg);
|
||||
_about.drawLeft(p, st::boxPadding.left(), abouty, w, width());
|
||||
|
||||
|
|
@ -82,8 +85,10 @@ void FontsBox::resizeEvent(QResizeEvent *e) {
|
|||
int32 w = st::boxWidth - st::boxPadding.left() - st::boxPadding.right();
|
||||
_useSystemFont->resize(w, _useSystemFont->height());
|
||||
_useSystemFont->moveToLeft(st::boxPadding.left(), 0);
|
||||
_useOriginalMetrics->resize(w, _useOriginalMetrics->height());
|
||||
_useOriginalMetrics->moveToLeft(st::boxPadding.left(), _useSystemFont->y() + _useSystemFont->height() + st::boxLittleSkip);
|
||||
_mainFontName->resize(w, _mainFontName->height());
|
||||
_mainFontName->moveToLeft(st::boxPadding.left(), _useSystemFont->y() + _useSystemFont->height() + st::boxLittleSkip);
|
||||
_mainFontName->moveToLeft(st::boxPadding.left(), _useOriginalMetrics->y() + _useOriginalMetrics->height() + st::boxLittleSkip);
|
||||
_semiboldFontName->resize(w, _semiboldFontName->height());
|
||||
_semiboldFontName->moveToLeft(st::boxPadding.left(), _mainFontName->y() + _mainFontName->height());
|
||||
_semiboldIsBold->resize(w, _semiboldIsBold->height());
|
||||
|
|
@ -98,6 +103,7 @@ void FontsBox::setInnerFocus() {
|
|||
|
||||
void FontsBox::save() {
|
||||
const auto useSystemFont = _useSystemFont->checked();
|
||||
const auto useOriginalMetrics = _useOriginalMetrics->checked();
|
||||
const auto mainFont = _mainFontName->getLastText().trimmed();
|
||||
const auto semiboldFont = _semiboldFontName->getLastText().trimmed();
|
||||
const auto semiboldIsBold = _semiboldIsBold->checked();
|
||||
|
|
@ -105,6 +111,7 @@ void FontsBox::save() {
|
|||
|
||||
const auto changeFonts = [=] {
|
||||
cSetUseSystemFont(useSystemFont);
|
||||
cSetUseOriginalMetrics(useOriginalMetrics);
|
||||
cSetMainFont(mainFont);
|
||||
cSetSemiboldFont(semiboldFont);
|
||||
cSetSemiboldFontIsBold(semiboldIsBold);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ private:
|
|||
object_ptr<Ui::InputField> _semiboldFontName = { nullptr };
|
||||
object_ptr<Ui::Checkbox> _semiboldIsBold = { nullptr };
|
||||
object_ptr<Ui::InputField> _monospacedFontName = { nullptr };
|
||||
object_ptr<Ui::Checkbox> _useOriginalMetrics = { nullptr };
|
||||
Ui::Text::String _about;
|
||||
|
||||
int _aboutHeight = 0;
|
||||
|
|
|
|||
|
|
@ -178,6 +178,9 @@ void Application::run() {
|
|||
if (cUseSystemFont()) {
|
||||
style::internal::SetUseSystemFont(cUseSystemFont());
|
||||
}
|
||||
if (cUseOriginalMetrics()) {
|
||||
style::internal::SetUseOriginalMetrics(cUseOriginalMetrics());
|
||||
}
|
||||
style::internal::StartFonts();
|
||||
|
||||
ThirdParty::start();
|
||||
|
|
|
|||
|
|
@ -150,6 +150,11 @@ bool Manager::readCustomFile() {
|
|||
if (settingsFontsUseSystemFont != settingsFonts.constEnd() && (*settingsFontsUseSystemFont).isBool()) {
|
||||
cSetUseSystemFont((*settingsFontsUseSystemFont).toBool());
|
||||
}
|
||||
|
||||
const auto settingsFontsUseOriginalMetrics = settingsFonts.constFind(qsl("use_original_metrics"));
|
||||
if (settingsFontsUseOriginalMetrics != settingsFonts.constEnd() && (*settingsFontsUseOriginalMetrics).isBool()) {
|
||||
cSetUseOriginalMetrics((*settingsFontsUseOriginalMetrics).toBool());
|
||||
}
|
||||
}
|
||||
|
||||
const auto settingsStickerHeightIt = settings.constFind(qsl("sticker_height"));
|
||||
|
|
@ -290,6 +295,7 @@ void Manager::writeDefaultFile() {
|
|||
settingsFonts.insert(qsl("semibold_is_bold"), false);
|
||||
settingsFonts.insert(qsl("monospaced"), qsl("Consolas"));
|
||||
settingsFonts.insert(qsl("use_system_font"), cUseSystemFont());
|
||||
settingsFonts.insert(qsl("use_original_metrics"), cUseOriginalMetrics());
|
||||
|
||||
settings.insert(qsl("fonts"), settingsFonts);
|
||||
|
||||
|
|
@ -349,6 +355,7 @@ void Manager::writeCurrentSettings() {
|
|||
|
||||
settingsFonts.insert(qsl("semibold_is_bold"), cSemiboldFontIsBold());
|
||||
settingsFonts.insert(qsl("use_system_font"), cUseSystemFont());
|
||||
settingsFonts.insert(qsl("use_original_metrics"), cUseOriginalMetrics());
|
||||
|
||||
settings.insert(qsl("fonts"), settingsFonts);
|
||||
|
||||
|
|
|
|||
|
|
@ -218,6 +218,8 @@ bool gUseSystemFont = true;
|
|||
bool gUseSystemFont = false;
|
||||
#endif
|
||||
|
||||
bool gUseOriginalMetrics = false;
|
||||
|
||||
rpl::variable<int> gStickerHeight = 170;
|
||||
void SetStickerHeight(int height) {
|
||||
gStickerHeight = height;
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ DeclareSetting(QString, SemiboldFont);
|
|||
DeclareSetting(bool, SemiboldFontIsBold);
|
||||
DeclareSetting(QString, MonospaceFont);
|
||||
DeclareSetting(bool, UseSystemFont);
|
||||
DeclareSetting(bool, UseOriginalMetrics);
|
||||
|
||||
void SetBigEmojiOutline(bool enabled);
|
||||
[[nodiscard]] bool BigEmojiOutline();
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 3106a3474b4185217bbb230c605565f127d2a3a1
|
||||
Subproject commit f5e3d2111399161ff9434997e855da5f35470b4b
|
||||
Loading…
Add table
Reference in a new issue