From 477579bde4f8c88f655e150c6530fcbe1db5ad17 Mon Sep 17 00:00:00 2001 From: wangqr Date: Sun, 4 Apr 2021 17:26:12 -0400 Subject: [PATCH] Set font of edit_ctrl_tc and secondary_editor according to options Partially fix wangqr/Aegisub#93 --- src/preferences.cpp | 7 +++++++ src/subs_edit_box.cpp | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/preferences.cpp b/src/preferences.cpp index de9cb8ceba..8178d70ed7 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -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/"); diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index 8ccbcc2a99..34f03fec47 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -52,6 +52,7 @@ #include "text_selection_controller.h" #include "timeedit_ctrl.h" #include "tooltip_manager.h" +#include "utils.h" #include "validators.h" #include @@ -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);