gui: Prevent localization issues with font-size

CSS breaks when given a number with a comma as the radix
instead of a decimal. Depending on the system localization,
printf () may return numbers in this format when resizing
the font. This causes the theme to break unless font size is
set to 100.
To prevent this issue, we create the font size string manually
using integer division and mod operations.
This commit is contained in:
Alx Sa 2024-03-15 03:10:26 +00:00
parent 7e58a00a74
commit a14caafa8c

View file

@ -492,10 +492,22 @@ themes_apply_theme (Gimp *gimp,
}
if (! error && config->font_relative_size != 1.0)
g_output_stream_printf (output, NULL, NULL, &error,
"\n"
"* { font-size: %frem; }",
config->font_relative_size);
{
/* CSS does not like numbers with commas as the radix.
* To prevent, we create the string with a point used. */
gchar *font_size_string = NULL;
gint font_size;
font_size = config->font_relative_size * 100;
font_size_string = g_strdup_printf ("%d.%d", (font_size / 100),
font_size % 100);
g_output_stream_printf (output, NULL, NULL, &error,
"\n"
"* { font-size: %srem; }",
font_size_string);
g_free (font_size_string);
}
if (! error)
{