~lh2/st

fa284538a7c603377173ad3c545cc86ddb342f10 — Lukas Henkel 3 years ago 10f57fd master
Make bold font weight configurable

If a font is selected that does not provide the default font weight of 200,
st logs an error and renders bold text in yellow instead. This setting
allows the bold font weight to be changed.
3 files changed, 63 insertions(+), 59 deletions(-)

M config.def.h
M config.h
M x.c
M config.def.h => config.def.h +31 -29
@@ 6,6 6,7 @@
 * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
 */
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
static unsigned int boldweight = FC_WEIGHT_BOLD;
static int borderpx = 2;

/*


@@ 184,35 185,36 @@ static uint forcemousemod = ShiftMask;
 * Xresources preferences to load at startup
 */
ResourcePref resources[] = {
		{ "font",         STRING,  &font },
		{ "color0",       STRING,  &colorname[0] },
		{ "color1",       STRING,  &colorname[1] },
		{ "color2",       STRING,  &colorname[2] },
		{ "color3",       STRING,  &colorname[3] },
		{ "color4",       STRING,  &colorname[4] },
		{ "color5",       STRING,  &colorname[5] },
		{ "color6",       STRING,  &colorname[6] },
		{ "color7",       STRING,  &colorname[7] },
		{ "color8",       STRING,  &colorname[8] },
		{ "color9",       STRING,  &colorname[9] },
		{ "color10",      STRING,  &colorname[10] },
		{ "color11",      STRING,  &colorname[11] },
		{ "color12",      STRING,  &colorname[12] },
		{ "color13",      STRING,  &colorname[13] },
		{ "color14",      STRING,  &colorname[14] },
		{ "color15",      STRING,  &colorname[15] },
		{ "background",   STRING,  &colorname[256] },
		{ "foreground",   STRING,  &colorname[257] },
		{ "termname",     STRING,  &termname },
		{ "shell",        STRING,  &shell },
		{ "minlatency",   INTEGER, &minlatency },
		{ "maxlatency",   INTEGER, &maxlatency },
		{ "blinktimeout", INTEGER, &blinktimeout },
		{ "bellvolume",   INTEGER, &bellvolume },
		{ "tabspaces",    INTEGER, &tabspaces },
		{ "borderpx",     INTEGER, &borderpx },
		{ "cwscale",      FLOAT,   &cwscale },
		{ "chscale",      FLOAT,   &chscale },
	{ "font",            STRING,  &font },
	{ "font.boldweight", INTEGER, &boldweight },
	{ "color0",          STRING,  &colorname[0] },
	{ "color1",          STRING,  &colorname[1] },
	{ "color2",          STRING,  &colorname[2] },
	{ "color3",          STRING,  &colorname[3] },
	{ "color4",          STRING,  &colorname[4] },
	{ "color5",          STRING,  &colorname[5] },
	{ "color6",          STRING,  &colorname[6] },
	{ "color7",          STRING,  &colorname[7] },
	{ "color8",          STRING,  &colorname[8] },
	{ "color9",          STRING,  &colorname[9] },
	{ "color10",         STRING,  &colorname[10] },
	{ "color11",         STRING,  &colorname[11] },
	{ "color12",         STRING,  &colorname[12] },
	{ "color13",         STRING,  &colorname[13] },
	{ "color14",         STRING,  &colorname[14] },
	{ "color15",         STRING,  &colorname[15] },
	{ "background",      STRING,  &colorname[256] },
	{ "foreground",      STRING,  &colorname[257] },
	{ "termname",        STRING,  &termname },
	{ "shell",           STRING,  &shell },
	{ "minlatency",      INTEGER, &minlatency },
	{ "maxlatency",      INTEGER, &maxlatency },
	{ "blinktimeout",    INTEGER, &blinktimeout },
	{ "bellvolume",      INTEGER, &bellvolume },
	{ "tabspaces",       INTEGER, &tabspaces },
	{ "borderpx",        INTEGER, &borderpx },
	{ "cwscale",         FLOAT,   &cwscale },
	{ "chscale",         FLOAT,   &chscale },
};

/*

M config.h => config.h +31 -29
@@ 6,6 6,7 @@
 * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
 */
static char *font = "monospace:pixelsize=12:antialias=true:autohint=true";
static unsigned int boldweight = FC_WEIGHT_BOLD;
static int borderpx = 2;

/*


@@ 184,35 185,36 @@ static uint forcemousemod = ShiftMask;
 * Xresources preferences to load at startup
 */
ResourcePref resources[] = {
		{ "font",         STRING,  &font },
		{ "color0",       STRING,  &colorname[0] },
		{ "color1",       STRING,  &colorname[1] },
		{ "color2",       STRING,  &colorname[2] },
		{ "color3",       STRING,  &colorname[3] },
		{ "color4",       STRING,  &colorname[4] },
		{ "color5",       STRING,  &colorname[5] },
		{ "color6",       STRING,  &colorname[6] },
		{ "color7",       STRING,  &colorname[7] },
		{ "color8",       STRING,  &colorname[8] },
		{ "color9",       STRING,  &colorname[9] },
		{ "color10",      STRING,  &colorname[10] },
		{ "color11",      STRING,  &colorname[11] },
		{ "color12",      STRING,  &colorname[12] },
		{ "color13",      STRING,  &colorname[13] },
		{ "color14",      STRING,  &colorname[14] },
		{ "color15",      STRING,  &colorname[15] },
		{ "background",   STRING,  &colorname[256] },
		{ "foreground",   STRING,  &colorname[257] },
		{ "termname",     STRING,  &termname },
		{ "shell",        STRING,  &shell },
		{ "minlatency",   INTEGER, &minlatency },
		{ "maxlatency",   INTEGER, &maxlatency },
		{ "blinktimeout", INTEGER, &blinktimeout },
		{ "bellvolume",   INTEGER, &bellvolume },
		{ "tabspaces",    INTEGER, &tabspaces },
		{ "borderpx",     INTEGER, &borderpx },
		{ "cwscale",      FLOAT,   &cwscale },
		{ "chscale",      FLOAT,   &chscale },
	{ "font",            STRING,  &font },
	{ "font.boldweight", INTEGER, &boldweight },
	{ "color0",          STRING,  &colorname[0] },
	{ "color1",          STRING,  &colorname[1] },
	{ "color2",          STRING,  &colorname[2] },
	{ "color3",          STRING,  &colorname[3] },
	{ "color4",          STRING,  &colorname[4] },
	{ "color5",          STRING,  &colorname[5] },
	{ "color6",          STRING,  &colorname[6] },
	{ "color7",          STRING,  &colorname[7] },
	{ "color8",          STRING,  &colorname[8] },
	{ "color9",          STRING,  &colorname[9] },
	{ "color10",         STRING,  &colorname[10] },
	{ "color11",         STRING,  &colorname[11] },
	{ "color12",         STRING,  &colorname[12] },
	{ "color13",         STRING,  &colorname[13] },
	{ "color14",         STRING,  &colorname[14] },
	{ "color15",         STRING,  &colorname[15] },
	{ "background",      STRING,  &colorname[256] },
	{ "foreground",      STRING,  &colorname[257] },
	{ "termname",        STRING,  &termname },
	{ "shell",           STRING,  &shell },
	{ "minlatency",      INTEGER, &minlatency },
	{ "maxlatency",      INTEGER, &maxlatency },
	{ "blinktimeout",    INTEGER, &blinktimeout },
	{ "bellvolume",      INTEGER, &bellvolume },
	{ "tabspaces",       INTEGER, &tabspaces },
	{ "borderpx",        INTEGER, &borderpx },
	{ "cwscale",         FLOAT,   &cwscale },
	{ "chscale",         FLOAT,   &chscale },
};

/*

M x.c => x.c +1 -1
@@ 1022,7 1022,7 @@ xloadfonts(char *fontstr, double fontsize)
		die("can't open font %s\n", fontstr);

	FcPatternDel(pattern, FC_WEIGHT);
	FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
	FcPatternAddInteger(pattern, FC_WEIGHT, boldweight);
	if (xloadfont(&dc.ibfont, pattern))
		die("can't open font %s\n", fontstr);