diff --git a/config.def.h b/config.def.h index baa22c6..681056e 100644 --- a/config.def.h +++ b/config.def.h @@ -5,7 +5,15 @@ * * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html */ -static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; +static char *fonts[] = { + "FiraCode Nerd Font:size=10", + "Monaspace Neon:size=10", + "Monaspace Argon:size=10", + "Monaspace Xenon:size=10", + "Monaspace Radon:size=10", + "Monaspace Krypton:size=10", +}; +static size_t currentfont = 0; static int borderpx = 2; @@ -254,6 +262,7 @@ static Shortcut shortcuts[] = { { ShiftMask, XK_Insert, selpaste, {.i = 0} }, { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, { MODKEY, XK_c, normalMode, {.i = 0} }, + { TERMMOD, XK_S, cyclefonts, {} }, }; /* diff --git a/x.c b/x.c index 881ec52..e3d3db3 100644 --- a/x.c +++ b/x.c @@ -61,6 +61,7 @@ static void zoom(const Arg *); static void zoomabs(const Arg *); static void zoomreset(const Arg *); static void ttysend(const Arg *); +static void cyclefonts(const Arg *); /* config.h for applying patches and the configuration. */ #include "config.h" @@ -334,11 +335,7 @@ void zoomreset(const Arg *arg) { Arg larg; - - if (defaultfontsize > 0) { - larg.f = defaultfontsize; - zoomabs(&larg); - } + zoomabs(&larg); } void @@ -363,6 +360,15 @@ evrow(XEvent *e) return y / win.ch; } +void cyclefonts(const Arg *arg) { + currentfont++; + currentfont %= (sizeof fonts / sizeof fonts[0]); + usedfont = fonts[currentfont]; + Arg larg; + larg.f = usedfontsize; + zoomabs(&larg); +} + void mousesel(XEvent *e, int done) { @@ -1189,7 +1195,7 @@ xinit(int cols, int rows) if (!FcInit()) die("could not init fontconfig.\n"); - usedfont = (opt_font == NULL)? font : opt_font; + usedfont = (opt_font == NULL) ? fonts[currentfont] : opt_font; xloadfonts(usedfont, 0); /* colors */ @@ -2194,7 +2200,7 @@ xrdb_load(void) defaultrcs = defaultbg; } - XRESOURCE_LOAD_STRING("font", font); + XRESOURCE_LOAD_STRING("font", fonts[0]); XRESOURCE_LOAD_STRING("termname", termname); XRESOURCE_LOAD_INTEGER("blinktimeout", blinktimeout); @@ -2217,7 +2223,7 @@ reload(int sig) /* colors, fonts */ xloadcols(); xunloadfonts(); - xloadfonts(font, 0); + xloadfonts(fonts[currentfont], 0); /* pretend the window just got resized */ cresize(win.w, win.h);