[wiki] [sites] [st][patch] cyclefonts: Add patch, allows you to cycle multiple fonts || Miles Alan

From: <git_AT_suckless.org>
Date: Tue, 08 Dec 2020 04:32:30 +0100

commit 8c16ed676772040ca0b9114a6c044b861be948de
Author: Miles Alan <m_AT_milesalan.com>
Date: Mon Dec 7 21:31:05 2020 -0600

    [st][patch] cyclefonts: Add patch, allows you to cycle multiple fonts

diff --git a/st.suckless.org/patches/cyclefonts/index.md b/st.suckless.org/patches/cyclefonts/index.md
new file mode 100644
index 00000000..bb01f849
--- /dev/null
+++ b/st.suckless.org/patches/cyclefonts/index.md
_AT_@ -0,0 +1,19 @@
+cyclefonts
+==========
+
+Description
+-----------
+
+This patch adds a keybinding that lets you cycle between multiple different
+fonts. Define `fonts` in your config.def.h as an array instead of `font`.
+
+
+Download
+--------
+
+* [st-cyclefonts-0.8.4.diff](st-cyclefonts-0.8.4.diff)
+
+Author
+------
+
+* Miles Alan - m_AT_milesalan.com
diff --git a/st.suckless.org/patches/cyclefonts/st-cyclefonts-0.8.4.diff b/st.suckless.org/patches/cyclefonts/st-cyclefonts-0.8.4.diff
new file mode 100644
index 00000000..c62847b7
--- /dev/null
+++ b/st.suckless.org/patches/cyclefonts/st-cyclefonts-0.8.4.diff
_AT_@ -0,0 +1,82 @@
+From 9262cecf21a3a2fcf5f5c0f7dcc872fdc5435ca1 Mon Sep 17 00:00:00 2001
+From: Miles Alan <m_AT_milesalan.com>
+Date: Mon, 7 Dec 2020 21:16:37 -0600
+Subject: [PATCH] cyclefont: Add keybinding to cycle between multiple different
+ fonts
+
+---
+ config.def.h | 8 +++++++-
+ x.c | 17 +++++++++++++++--
+ 2 files changed, 22 insertions(+), 3 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 6f05dce..5cd506c 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -5,7 +5,12 @@
+ *
+ * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
+ */
+-static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
++static char *fonts[] = {
++ "Liberation Mono:pixelsize=12:antialias=true:autohint=true",
++ "tewi:pixelsize=12:antialias=true:autohint=true"
++};
++static int fonts_current = 0;
++
+ static int borderpx = 2;
+
+ /*
+_AT_@ -199,6 +204,7 @@ static Shortcut shortcuts[] = {
+ { TERMMOD, XK_Y, selpaste, {.i = 0} },
+ { ShiftMask, XK_Insert, selpaste, {.i = 0} },
+ { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
++ { TERMMOD, XK_S, cyclefonts, {} },
+ };
+
+ /*
+diff --git a/x.c b/x.c
+index 210f184..88cb8e7 100644
+--- a/x.c
++++ b/x.c
+_AT_@ -59,6 +59,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"
+_AT_@ -949,6 +950,18 @@ xloadfont(Font *f, FcPattern *pattern)
+ return 0;
+ }
+
++void
++cyclefonts(const Arg *dummy)
++{
++ fonts_current++;
++ if (fonts_current > (sizeof fonts / sizeof fonts[0]) - 1) {
++ fonts_current = 0;
++ }
++ usedfont = fonts[fonts_current];
++ xloadfonts(fonts[fonts_current], 0);
++ redraw();
++}
++
+ void
+ xloadfonts(char *fontstr, double fontsize)
+ {
+_AT_@ -1113,8 +1126,8 @@ xinit(int cols, int rows)
+ if (!FcInit())
+ die("could not init fontconfig.
");
+
+- usedfont = (opt_font == NULL)? font : opt_font;
+- xloadfonts(usedfont, 0);
++ usedfont = fonts[fonts_current];
++ xloadfonts(fonts[fonts_current], 0);
+
+ /* colors */
+ xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
+--
+2.26.2
+
Received on Tue Dec 08 2020 - 04:32:30 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 08 2020 - 04:36:45 CET