commit cfba481a26f6c878cbafc7dc4741a3638744dabe
Author: Justinas Grigas <jstn_as_AT_protonmail.com>
Date: Fri Jun 4 11:19:16 2021 +0000
[st][patch][cyclefonts] updated for 4536f46
diff --git a/st.suckless.org/patches/cyclefonts/index.md b/st.suckless.org/patches/cyclefonts/index.md
index bb01f849..b80ea0b6 100644
--- a/st.suckless.org/patches/cyclefonts/index.md
+++ b/st.suckless.org/patches/cyclefonts/index.md
_AT_@ -3,17 +3,20 @@ 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`.
+fonts. Define `fonts` in your `config.def.h` as an array instead of `font`.
+Notes
+-----
+* `currentfont` controls which font is loaded at the start, and must not exceed
+ the size of the fonts array.
Download
--------
-
* [st-cyclefonts-0.8.4.diff](st-cyclefonts-0.8.4.diff)
+* [st-cyclefonts-20210604-4536f46.diff](st-cyclefonts-20210604-4536f46.diff)
Author
------
-
-* Miles Alan - m_AT_milesalan.com
+* Miles Alan - m_AT_milesalan.com (0.8.4)
+* Justinas Grigas - <jstn_as_AT_protonmail.com> (Updated version)
diff --git a/st.suckless.org/patches/cyclefonts/st-cyclefonts-20210604-4536f46.diff b/st.suckless.org/patches/cyclefonts/st-cyclefonts-20210604-4536f46.diff
new file mode 100644
index 00000000..732ef207
--- /dev/null
+++ b/st.suckless.org/patches/cyclefonts/st-cyclefonts-20210604-4536f46.diff
_AT_@ -0,0 +1,83 @@
+From f7fb9a9597ec1f428455e9ef1cfcdac879a7af83 Mon Sep 17 00:00:00 2001
+From: Justinas Grigas <jstn_as_AT_protonmail.com>
+Date: Fri, 4 Jun 2021 10:44:24 +0000
+Subject: [PATCH] [PATCH] cycles between fonts
+
+this is an update to the original cyclefonts patch which doesn't apply
+cleanly to the git version, with some tweaks.
+
+currentfont is now of type size_t.
+cycling fonts now properly redraws the screen.
+optional font can be loaded at the start.
+---
+ config.def.h | 7 ++++++-
+ x.c | 14 +++++++++++++-
+ 2 files changed, 19 insertions(+), 2 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 6f05dce..ff9bac9 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -5,7 +5,11 @@
+ *
+ * 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",
++ "Gohu GohuFont:pixelsize=11:antialias=false:autohint=false",
++};
++static size_t currentfont = 0;
+ static int borderpx = 2;
+
+ /*
+_AT_@ -199,6 +203,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 7186040..9a658fa 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_@ -328,6 +329,17 @@ ttysend(const Arg *arg)
+ ttywrite(arg->s, strlen(arg->s), 1);
+ }
+
++void
++cyclefonts(const Arg *arg)
++{
++ currentfont++;
++ currentfont %= (sizeof fonts / sizeof fonts[0]);
++ usedfont = fonts[currentfont];
++ Arg larg;
++ larg.f = usedfontsize;
++ zoomabs(&larg);
++}
++
+ int
+ evcol(XEvent *e)
+ {
+_AT_@ -1115,7 +1127,7 @@ xinit(int cols, int rows)
+ if (!FcInit())
+ die("could not init fontconfig.
");
+
+- usedfont = (opt_font == NULL)? font : opt_font;
++ usedfont = (opt_font == NULL)? fonts[currentfont] : opt_font;
+ xloadfonts(usedfont, 0);
+
+ /* colors */
+--
+2.31.1
+
Received on Fri Jun 04 2021 - 13:22:25 CEST