[glom/glom-1-30] utils_ui: Properly parse the pango font name.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-30] utils_ui: Properly parse the pango font name.
- Date: Wed, 8 Jun 2016 20:56:27 +0000 (UTC)
commit 8f98ba8ba1a1f0febdca0e6d3c0a5b6a94503f65
Author: Murray Cumming <murrayc murrayc com>
Date: Mon May 16 20:46:41 2016 +0200
utils_ui: Properly parse the pango font name.
glom/utils_ui.cc | 12 ++++++++++--
glom/utils_ui.h | 6 +++++-
2 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/glom/utils_ui.cc b/glom/utils_ui.cc
index 822c86e..4658cc4 100644
--- a/glom/utils_ui.cc
+++ b/glom/utils_ui.cc
@@ -617,9 +617,17 @@ void UiUtils::container_remove_all(Gtk::Container& container)
}
}
-void UiUtils::load_font_into_css_provider(Gtk::Widget& widget, const Glib::ustring& font)
+void UiUtils::load_font_into_css_provider(Gtk::Widget& widget, const Glib::ustring& pango_font_name)
{
- const auto css = "* { font-family: " + font + "; }";
+ const Pango::FontDescription font_desc(pango_font_name);
+ const auto font_family = font_desc.get_family();
+ const auto font_size = font_desc.get_size();
+ const auto css =
+ "* {\n" +
+ (font_family.empty() ? "" : " font-family: " + font_desc.get_family() + ";\n") +
+ (font_size == 0 ? "" : " font-size: " + std::to_string(font_size / PANGO_SCALE) + "pt;\n") +
+ "}";
+
load_into_css_provider(widget, css);
}
diff --git a/glom/utils_ui.h b/glom/utils_ui.h
index cd514b4..1b383c2 100644
--- a/glom/utils_ui.h
+++ b/glom/utils_ui.h
@@ -108,7 +108,11 @@ void treeview_delete_all_columns(Gtk::TreeView* treeview);
void container_remove_all(Gtk::Container& container);
-void load_font_into_css_provider(Gtk::Widget& widget, const Glib::ustring& font);
+/**
+ * @param pango_font_name A font description in the syntax accepted by the Pango::FontDescription
constructor.
+ */
+void load_font_into_css_provider(Gtk::Widget& widget, const Glib::ustring& pango_font_name);
+
void load_color_into_css_provider(Gtk::Widget& widget, const Glib::ustring& color);
void load_background_color_into_css_provider(Gtk::Widget& widget, const Glib::ustring& color);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]