[gtkmm-documentation] calendar: Don't use deprecated font: CSS syntax.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] calendar: Don't use deprecated font: CSS syntax.
- Date: Mon, 16 May 2016 18:13:17 +0000 (UTC)
commit c9426bee069e3b722f53592b2f4f51aa48c4a022
Author: Murray Cumming <murrayc murrayc com>
Date: Mon May 16 20:13:09 2016 +0200
calendar: Don't use deprecated font: CSS syntax.
examples/others/calendar/calendar.cc | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/examples/others/calendar/calendar.cc b/examples/others/calendar/calendar.cc
index 4e95114..318b97d 100644
--- a/examples/others/calendar/calendar.cc
+++ b/examples/others/calendar/calendar.cc
@@ -118,13 +118,19 @@ void CalendarExample::toggle_flag(Gtk::CheckButton *toggle)
void CalendarExample::on_font_button_font_set()
{
+ const auto font_name = font_button_->get_font_name();
+ Pango::FontDescription font_desc(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") +
+ "}";
+
try
{
- const Glib::ustring font_name = font_button_->get_font_name();
- if (!font_name.empty())
- {
- css_provider_->load_from_data("* { font: " + font_name + "; }");
- }
+ css_provider_->load_from_data(css);
}
catch (const Gtk::CssProviderError& ex)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]