Parse floats in C locale, hopefully
#endif
static enum overlay_param_position
-
parse_position(const char *str)
{
if (!str || !strcmp(str, "top-left"))
@@ -60,21 +59,13 @@ parse_control(const char *str)
}
static float
-parse_font_size(const char *str)
-{
- return strtof(str, NULL);
-}
-
-static float
-parse_background_alpha(const char *str)
-{
- return strtof(str, NULL);
-}
-
-static float
-parse_alpha(const char *str)
+parse_float(const char *str)
{
- return strtof(str, NULL);
+ float val = 0;
+ std::stringstream ss(str);
+ ss.imbue(std::locale("C"));
+ ss >> val;
+ return val;
}
#ifdef HAVE_X11
@@ -217,10 +208,13 @@ parse_media_player_order(const char *str)
#define parse_io_write(s) parse_unsigned(s)
#define parse_pci_dev(s) parse_str(s)
#define parse_media_player_name(s) parse_str(s)
-#define parse_font_scale_media_player(s) parse_font_size(s)
+#define parse_font_scale_media_player(s) parse_float(s)
#define parse_cpu_text(s) parse_str(s)
#define parse_gpu_text(s) parse_str(s)
#define parse_log_interval(s) parse_unsigned(s)
+#define parse_font_size(s) parse_float(s)
+#define parse_background_alpha(s) parse_float(s)
+#define parse_alpha(s) parse_float(s)
#define parse_cpu_color(s) parse_color(s)
#define parse_gpu_color(s) parse_color(s)
@@ -439,6 +433,9 @@ parse_overlay_config(struct overlay_params *params,
if (env && read_cfg)
parse_overlay_env(params, env);
+ if (params->font_scale_media_player <= 0.f)
+ params->font_scale_media_player = 0.55f;
+
// Convert from 0xRRGGBB to ImGui's format
std::array<unsigned *, 10> colors = {
&params->cpu_color,
