From ef6803abd1caf97f38505a48614e80f94c720dae Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 7 Nov 2022 11:55:16 +0100 Subject: [PATCH] Add API to force ArdourSans font (for UTF8 symbols) --- gtk2_ardour/ui_config.h | 1 + gtk2_ardour/utils.cc | 16 ++++++++++++++++ gtk2_ardour/utils.h | 1 + 3 files changed, 18 insertions(+) diff --git a/gtk2_ardour/ui_config.h b/gtk2_ardour/ui_config.h index bb526986a4..7e37352123 100644 --- a/gtk2_ardour/ui_config.h +++ b/gtk2_ardour/ui_config.h @@ -115,6 +115,7 @@ public: #undef UI_CONFIG_VARIABLE #define CANVAS_FONT_VARIABLE(var,name) \ Pango::FontDescription get_##var () const { return ARDOUR_UI_UTILS::sanitized_font (var.get()); } \ + Pango::FontDescription get_Ardour##var () const { return ARDOUR_UI_UTILS::ardour_font (var.get()); } \ bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; } #include "canvas_vars.h" #undef CANVAS_FONT_VARIABLE diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 33434c0f70..3f07bd3b39 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -284,6 +284,22 @@ ARDOUR_UI_UTILS::sanitized_font (std::string const& name) return fd; } +Pango::FontDescription +ARDOUR_UI_UTILS::ardour_font (std::string const& name) +{ + Pango::FontDescription fd (name); + if (!fd.get_family().empty() && fd.get_family().find ("Mon") != std::string::npos) { + /* matches "ArdourMono", "Monaco" */ + fd.set_family ("ArdourMono"); + } else { + fd.set_family ("ArdourSans"); + } + + return fd; +} + + + Pango::FontDescription ARDOUR_UI_UTILS::get_font_for_style (string widgetname) { diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h index 6026bd622a..49d6eb6845 100644 --- a/gtk2_ardour/utils.h +++ b/gtk2_ardour/utils.h @@ -75,6 +75,7 @@ unsigned char* xpm2rgba (const char** xpm, uint32_t& w, uint32_t& h); ArdourCanvas::Points* get_canvas_points (std::string who, uint32_t npoints); Pango::FontDescription sanitized_font (std::string const&); +Pango::FontDescription ardour_font (std::string const&); Pango::FontDescription get_font_for_style (std::string widgetname); void decorate (Gtk::Window& w, Gdk::WMDecoration d);