along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
+
+#include <float.h>
#include <limits.h>
#include <setjmp.h>
#include <fcntl.h>
FcPattern *pat;
struct xsettings oldsettings;
int changed = 0;
- char buf[256];
memset (&oldsettings, 0, sizeof (oldsettings));
- buf[0] = '\0';
pat = FcPatternCreate ();
XftDefaultSubstitute (dpyinfo->display,
XScreenNumberOfScreen (dpyinfo->screen),
++changed;
oldsettings.aa = settings->aa;
}
- sprintf (buf, "Antialias: %d", oldsettings.aa);
if ((settings->seen & SEEN_HINTING) != 0
&& oldsettings.hinting != settings->hinting)
++changed;
oldsettings.hinting = settings->hinting;
}
- if (strlen (buf) > 0) strcat (buf, ", ");
- sprintf (buf+strlen (buf), "Hinting: %d", oldsettings.hinting);
if ((settings->seen & SEEN_RGBA) != 0 && oldsettings.rgba != settings->rgba)
{
FcPatternDel (pat, FC_RGBA);
oldsettings.rgba = settings->rgba;
++changed;
}
- if (strlen (buf) > 0) strcat (buf, ", ");
- sprintf (buf+strlen (buf), "RGBA: %d", oldsettings.rgba);
/* Older fontconfig versions don't have FC_LCD_FILTER. */
if ((settings->seen & SEEN_LCDFILTER) != 0
++changed;
oldsettings.lcdfilter = settings->lcdfilter;
}
- if (strlen (buf) > 0) strcat (buf, ", ");
- sprintf (buf+strlen (buf), "LCDFilter: %d", oldsettings.lcdfilter);
# ifdef FC_HINT_STYLE
if ((settings->seen & SEEN_HINTSTYLE) != 0
oldsettings.hintstyle = settings->hintstyle;
}
# endif
- if (strlen (buf) > 0) strcat (buf, ", ");
- sprintf (buf+strlen (buf), "Hintstyle: %d", oldsettings.hintstyle);
if ((settings->seen & SEEN_DPI) != 0 && oldsettings.dpi != settings->dpi
&& settings->dpi > 0)
XFRAME (frame)->resy = XFRAME (frame)->resx = settings->dpi;
}
- if (strlen (buf) > 0) strcat (buf, ", ");
- sprintf (buf+strlen (buf), "DPI: %lf", oldsettings.dpi);
-
if (changed)
{
+ static char const format[] =
+ "Antialias: %d, Hinting: %d, RGBA: %d, LCDFilter: %d, "
+ "Hintstyle: %d, DPI: %lf";
+ enum
+ {
+ d_formats = 5,
+ d_growth = INT_BUFSIZE_BOUND (int) - sizeof "%d",
+ lf_formats = 1,
+ max_f_integer_digits = DBL_MAX_10_EXP + 1,
+ f_precision = 6,
+ lf_growth = (sizeof "-." + max_f_integer_digits + f_precision
+ - sizeof "%lf")
+ };
+ char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
+
XftDefaultSet (dpyinfo->display, pat);
if (send_event_p)
store_config_changed_event (Qfont_render,
XCAR (dpyinfo->name_list_element));
- Vxft_settings = make_string (buf, strlen (buf));
+ sprintf (buf, format, oldsettings.aa, oldsettings.hinting,
+ oldsettings.rgba, oldsettings.lcdfilter,
+ oldsettings.hintstyle, oldsettings.dpi);
+ Vxft_settings = build_string (buf);
}
else
FcPatternDestroy (pat);