xsettings - always use decimal for format for float prints
snprintf will use locale and maybe print 10,24 instead of 10.24 ... thus use a custom routine to specially do this always by hand without mssing with locale. @fix
This commit is contained in:
parent
3150546e30
commit
71b5cb3e7c
|
@ -509,6 +509,44 @@ _e_xsettings_theme_set(void)
|
|||
_e_xsettings_string_set(_setting_theme_name, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
_dbl_to_str(char *buf, size_t buf_size, double val, int decimals)
|
||||
{
|
||||
int ival;
|
||||
size_t l = 0;
|
||||
|
||||
if (val < 0)
|
||||
{
|
||||
if (buf_size < 2) return -1;
|
||||
val = -val;
|
||||
buf[0] = '-';
|
||||
buf[1] = 0;
|
||||
l++;
|
||||
}
|
||||
ival = val;
|
||||
snprintf(buf + l, buf_size - l, "%i", ival);
|
||||
if (decimals <= 0) return 0;
|
||||
l = strlen(buf);
|
||||
if (l >= (buf_size - 2)) return -1;
|
||||
buf[l] = '.';
|
||||
buf[l + 1] = 0;
|
||||
l++;
|
||||
|
||||
while (decimals > 0)
|
||||
{
|
||||
if (l >= (buf_size - 1)) return -1;
|
||||
val *= 10.0;
|
||||
ival = val;
|
||||
val = val - ival;
|
||||
buf[l] = '0' + (ival % 10);
|
||||
buf[l + 1] = 0;
|
||||
l++;
|
||||
if (l >= (buf_size - 1)) return -1;
|
||||
decimals--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_xsettings_font_set(void)
|
||||
{
|
||||
|
@ -525,17 +563,18 @@ _e_xsettings_font_set(void)
|
|||
Eina_Strbuf *buf;
|
||||
Eina_List *l;
|
||||
int size = efd->size;
|
||||
char size_buf[12];
|
||||
char size_buf[32];
|
||||
const char *p;
|
||||
|
||||
/* TODO better way to convert evas font sizes? */
|
||||
if (!size) size = 12;
|
||||
else if (size < 0) size /= -10;
|
||||
else if (size < 5) size = 5;
|
||||
else if (size > 25) size = 25;
|
||||
if (!size) size = 10; // default if not set
|
||||
else if (size < 0) size /= -10; // in 1/10th units
|
||||
|
||||
/* Convert from pixels to point. */
|
||||
snprintf(size_buf, sizeof(size_buf), "%1.1f", (float) size * 0.75);
|
||||
// limit sizes
|
||||
if (size < 5) size = 5; // don't allow too small
|
||||
else if (size > 100) size = 100; // don't allow silly sizes
|
||||
|
||||
_dbl_to_str(size_buf, sizeof(size_buf), (double)size * 0.75, 3);
|
||||
|
||||
buf = eina_strbuf_new();
|
||||
eina_strbuf_append(buf, efp->name);
|
||||
|
|
Loading…
Reference in New Issue