From 105762f30a12ede53bf5434d08e0cedbc9ac5529 Mon Sep 17 00:00:00 2001 From: Patrick Ward Date: Fri, 7 Feb 2014 10:18:32 -0800 Subject: Fix font size CSS decimal point Changed the decimal point of the font size's CSS to always use a '.' so that the metric decimal point ',' is never used. This makes sure that GTK's CSS parser will always be able to parse the font-size CSS. [endlessm/eos-sdk#544] --- endless/eoswindow.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'endless') diff --git a/endless/eoswindow.c b/endless/eoswindow.c index 0b280a3..cdf0fc7 100644 --- a/endless/eoswindow.c +++ b/endless/eoswindow.c @@ -69,7 +69,7 @@ #define BACKGROUND_FRAME_NAME_TEMPLATE "_eos-window-background-%d" -#define FONT_SIZE_TEMPLATE "EosWindow { font-size: %fpx; }" +#define FONT_SIZE_TEMPLATE "EosWindow { font-size: %spx; }" #define TRANSPARENT_FRAME_CSS_PROPERTIES "{ background-image: none;\n" \ " background-color: transparent\n;" \ @@ -599,7 +599,15 @@ eos_window_size_allocate (GtkWidget *window, GtkAllocation *allocation) GError *error = NULL; - gchar *font_size_css = g_strdup_printf (FONT_SIZE_TEMPLATE, priv->font_scaling_calculated_font_size); + /* A float will only have one decimal point when printed as a string. + * The decimal point can be represented as a comma or period when using + * either Imperial or metric units. However, the CSS parser only recognizes + * periods as valid decimal points. Therefore, we convert the float to a + * string using a period as the decimal point. */ + gchar font_size_float_str [G_ASCII_DTOSTR_BUF_SIZE]; + g_ascii_dtostr (font_size_float_str, G_ASCII_DTOSTR_BUF_SIZE, priv->font_scaling_calculated_font_size); + + gchar *font_size_css = g_strdup_printf (FONT_SIZE_TEMPLATE, font_size_float_str); GdkScreen *screen = gdk_screen_get_default (); gtk_style_context_remove_provider_for_screen (screen, provider); -- cgit v1.2.3