Skip to content

Commit

Permalink
Set font of edit_ctrl_tc and secondary_editor according to options
Browse files Browse the repository at this point in the history
Partially fix #93
  • Loading branch information
wangqr committed Apr 4, 2021
1 parent ec89ce9 commit 477579b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,17 @@ void Interface(wxTreebook *book, Preferences *parent) {
auto p = new OptionPage(book, parent, _("Interface"));

auto edit_box = p->PageSizer(_("Edit Box"));
#ifdef WITH_WXSTC
p->OptionAdd(edit_box, _("Use styled edit box"), "Subtitle/Use STC");
p->OptionAdd(edit_box, _("Enable call tips"), "App/Call Tips");
#endif
p->OptionAdd(edit_box, _("Overwrite in time boxes"), "Subtitle/Time Edit/Insert Mode");
#ifdef WITH_WXSTC
p->OptionAdd(edit_box, _("Enable syntax highlighting"), "Subtitle/Highlight/Syntax");
#else
// Pad number of options to even
p->CellSkip(edit_box);
#endif
p->OptionBrowse(edit_box, _("Dictionaries path"), "Path/Dictionary");
p->OptionFont(edit_box, "Subtitle/Edit Box/");

Expand Down
18 changes: 18 additions & 0 deletions src/subs_edit_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "text_selection_controller.h"
#include "timeedit_ctrl.h"
#include "tooltip_manager.h"
#include "utils.h"
#include "validators.h"

#include <libaegisub/character_count.h>
Expand Down Expand Up @@ -304,6 +305,23 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
}
#endif

// Set the font of edit boxes. See also SubsTextEditCtrl::SetStyles
// TODO: This only sets the font once. We should use OPT_SUB("Subtitle/Edit Box/Font Face") OPT_SUB("Subtitle/Edit Box/Font Size") instead
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_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);
font.SetPointSize(OPT_GET("Subtitle/Edit Box/Font Size")->GetInt());
secondary_editor->SetFont(font);
#ifdef WITH_WXSTC
if (!use_stc) {
#endif
edit_ctrl_tc->SetFont(font);
#ifdef WITH_WXSTC
}
#endif


bool show_original = OPT_GET("Subtitle/Show Original")->GetBool();
if (show_original) {
split_box->SetValue(true);
Expand Down

0 comments on commit 477579b

Please sign in to comment.