Skip to content

Commit

Permalink
Use system UI font when config font is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
0tkl committed Dec 5, 2024
1 parent f03bcab commit 6f7e5c4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/base_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ void BaseGrid::OnHighlightVisibleChange(agi::OptionValue const& opt) {
}

void BaseGrid::UpdateStyle() {
font = *wxNORMAL_FONT;
wxString fontname = FontFace("Subtitle/Grid");
if (fontname.empty()) fontname = "Tahoma";
font.SetFaceName(fontname);
if (!fontname.empty()) font.SetFaceName(fontname);
font.SetPointSize(OPT_GET("Subtitle/Grid/Font Size")->GetInt());
font.SetWeight(wxFONTWEIGHT_NORMAL);

Expand Down
4 changes: 2 additions & 2 deletions src/libresrc/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@
{"bool" : true}
],
"Focus Allow" : true,
"Font Face" : "Tahoma",
"Font Size" : 8,
"Font Face" : "",
"Font Size" : 10,
"Hide Overrides" : 1,
"Hide Overrides Char" : "",
"Highlight Subtitles in Frame" : true
Expand Down
6 changes: 4 additions & 2 deletions src/preferences_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ static void browse_button(wxTextCtrl *ctrl) {
}

static void font_button(Preferences *parent, wxTextCtrl *name, wxSpinCtrl *size) {
wxFont font;
font.SetFaceName(name->GetValue());
wxFont font = *wxNORMAL_FONT;
wxString fontname = name->GetValue();
if (!fontname.empty()) font.SetFaceName(fontname);
font.SetPointSize(size->GetValue());
font = wxGetFontFromUser(parent, font);
if (font.IsOk()) {
Expand Down Expand Up @@ -251,6 +252,7 @@ void OptionPage::OptionFont(wxSizer *sizer, std::string opt_prefix) {
auto font_name = new wxTextCtrl(this, -1, to_wx(face_opt->GetString()));
font_name->SetMinSize(wxSize(160, -1));
font_name->Bind(wxEVT_TEXT, StringUpdater(face_opt->GetName().c_str(), parent));
font_name->SetHint(wxNORMAL_FONT->GetFaceName());

auto font_size = new wxSpinCtrl(this, -1, std::to_wstring((int)size_opt->GetInt()), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 3, 42, size_opt->GetInt());
font_size->Bind(wxEVT_SPINCTRL, IntUpdater(size_opt->GetName().c_str(), parent));
Expand Down
2 changes: 1 addition & 1 deletion src/subs_edit_ctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void SubsTextEditCtrl::SetSyntaxStyle(int id, wxFont &font, std::string const& n
}

void SubsTextEditCtrl::SetStyles() {
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont font = *wxNORMAL_FONT;
font.SetEncoding(wxFONTENCODING_DEFAULT); // this solves problems with some fonts not working properly
wxString fontname = FontFace("Subtitle/Edit Box");
if (!fontname.empty()) font.SetFaceName(fontname);
Expand Down

0 comments on commit 6f7e5c4

Please sign in to comment.