st-cyclefonts-20210604-4536f46.diff - sites - public wiki contents of suckless.… | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
st-cyclefonts-20210604-4536f46.diff (2362B) | |
--- | |
1 From f7fb9a9597ec1f428455e9ef1cfcdac879a7af83 Mon Sep 17 00:00:00 2001 | |
2 From: Justinas Grigas <[email protected]> | |
3 Date: Fri, 4 Jun 2021 10:44:24 +0000 | |
4 Subject: [PATCH] [PATCH] cycles between fonts | |
5 | |
6 this is an update to the original cyclefonts patch which doesn't apply | |
7 cleanly to the git version, with some tweaks. | |
8 | |
9 currentfont is now of type size_t. | |
10 cycling fonts now properly redraws the screen. | |
11 optional font can be loaded at the start. | |
12 --- | |
13 config.def.h | 7 ++++++- | |
14 x.c | 14 +++++++++++++- | |
15 2 files changed, 19 insertions(+), 2 deletions(-) | |
16 | |
17 diff --git a/config.def.h b/config.def.h | |
18 index 6f05dce..ff9bac9 100644 | |
19 --- a/config.def.h | |
20 +++ b/config.def.h | |
21 @@ -5,7 +5,11 @@ | |
22 * | |
23 * font: see http://freedesktop.org/software/fontconfig/fontconfig-user… | |
24 */ | |
25 -static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohi… | |
26 +static char *fonts[] = { | |
27 + "Liberation Mono:pixelsize=12:antialias=true:autohint=true", | |
28 + "Gohu GohuFont:pixelsize=11:antialias=false:autohint=false", | |
29 +}; | |
30 +static size_t currentfont = 0; | |
31 static int borderpx = 2; | |
32 | |
33 /* | |
34 @@ -199,6 +203,7 @@ static Shortcut shortcuts[] = { | |
35 { TERMMOD, XK_Y, selpaste, {.i = … | |
36 { ShiftMask, XK_Insert, selpaste, {.i = … | |
37 { TERMMOD, XK_Num_Lock, numlock, {.i = … | |
38 + { TERMMOD, XK_S, cyclefonts, {} … | |
39 }; | |
40 | |
41 /* | |
42 diff --git a/x.c b/x.c | |
43 index 7186040..9a658fa 100644 | |
44 --- a/x.c | |
45 +++ b/x.c | |
46 @@ -59,6 +59,7 @@ static void zoom(const Arg *); | |
47 static void zoomabs(const Arg *); | |
48 static void zoomreset(const Arg *); | |
49 static void ttysend(const Arg *); | |
50 +static void cyclefonts(const Arg *); | |
51 | |
52 /* config.h for applying patches and the configuration. */ | |
53 #include "config.h" | |
54 @@ -328,6 +329,17 @@ ttysend(const Arg *arg) | |
55 ttywrite(arg->s, strlen(arg->s), 1); | |
56 } | |
57 | |
58 +void | |
59 +cyclefonts(const Arg *arg) | |
60 +{ | |
61 + currentfont++; | |
62 + currentfont %= (sizeof fonts / sizeof fonts[0]); | |
63 + usedfont = fonts[currentfont]; | |
64 + Arg larg; | |
65 + larg.f = usedfontsize; | |
66 + zoomabs(&larg); | |
67 +} | |
68 + | |
69 int | |
70 evcol(XEvent *e) | |
71 { | |
72 @@ -1115,7 +1127,7 @@ xinit(int cols, int rows) | |
73 if (!FcInit()) | |
74 die("could not init fontconfig.\n"); | |
75 | |
76 - usedfont = (opt_font == NULL)? font : opt_font; | |
77 + usedfont = (opt_font == NULL)? fonts[currentfont] : opt_font; | |
78 xloadfonts(usedfont, 0); | |
79 | |
80 /* colors */ | |
81 -- | |
82 2.31.1 | |
83 |