st-cyclefonts-0.8.4.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
st-cyclefonts-0.8.4.diff (2253B) | |
--- | |
1 From 9262cecf21a3a2fcf5f5c0f7dcc872fdc5435ca1 Mon Sep 17 00:00:00 2001 | |
2 From: Miles Alan <[email protected]> | |
3 Date: Mon, 7 Dec 2020 21:16:37 -0600 | |
4 Subject: [PATCH] cyclefont: Add keybinding to cycle between multiple dif… | |
5 fonts | |
6 | |
7 --- | |
8 config.def.h | 8 +++++++- | |
9 x.c | 17 +++++++++++++++-- | |
10 2 files changed, 22 insertions(+), 3 deletions(-) | |
11 | |
12 diff --git a/config.def.h b/config.def.h | |
13 index 6f05dce..5cd506c 100644 | |
14 --- a/config.def.h | |
15 +++ b/config.def.h | |
16 @@ -5,7 +5,12 @@ | |
17 * | |
18 * font: see http://freedesktop.org/software/fontconfig/fontconfig-user… | |
19 */ | |
20 -static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohi… | |
21 +static char *fonts[] = { | |
22 + "Liberation Mono:pixelsize=12:antialias=true:autohint=true", | |
23 + "tewi:pixelsize=12:antialias=true:autohint=true" | |
24 +}; | |
25 +static int fonts_current = 0; | |
26 + | |
27 static int borderpx = 2; | |
28 | |
29 /* | |
30 @@ -199,6 +204,7 @@ static Shortcut shortcuts[] = { | |
31 { TERMMOD, XK_Y, selpaste, {.i = … | |
32 { ShiftMask, XK_Insert, selpaste, {.i = … | |
33 { TERMMOD, XK_Num_Lock, numlock, {.i = … | |
34 + { TERMMOD, XK_S, cyclefonts, {} … | |
35 }; | |
36 | |
37 /* | |
38 diff --git a/x.c b/x.c | |
39 index 210f184..88cb8e7 100644 | |
40 --- a/x.c | |
41 +++ b/x.c | |
42 @@ -59,6 +59,7 @@ static void zoom(const Arg *); | |
43 static void zoomabs(const Arg *); | |
44 static void zoomreset(const Arg *); | |
45 static void ttysend(const Arg *); | |
46 +static void cyclefonts(const Arg *); | |
47 | |
48 /* config.h for applying patches and the configuration. */ | |
49 #include "config.h" | |
50 @@ -949,6 +950,18 @@ xloadfont(Font *f, FcPattern *pattern) | |
51 return 0; | |
52 } | |
53 | |
54 +void | |
55 +cyclefonts(const Arg *dummy) | |
56 +{ | |
57 + fonts_current++; | |
58 + if (fonts_current > (sizeof fonts / sizeof fonts[0]) - 1) { | |
59 + fonts_current = 0; | |
60 + } | |
61 + usedfont = fonts[fonts_current]; | |
62 + xloadfonts(fonts[fonts_current], 0); | |
63 + redraw(); | |
64 +} | |
65 + | |
66 void | |
67 xloadfonts(char *fontstr, double fontsize) | |
68 { | |
69 @@ -1113,8 +1126,8 @@ xinit(int cols, int rows) | |
70 if (!FcInit()) | |
71 die("could not init fontconfig.\n"); | |
72 | |
73 - usedfont = (opt_font == NULL)? font : opt_font; | |
74 - xloadfonts(usedfont, 0); | |
75 + usedfont = fonts[fonts_current]; | |
76 + xloadfonts(fonts[fonts_current], 0); | |
77 | |
78 /* colors */ | |
79 xw.cmap = XDefaultColormap(xw.dpy, xw.scr); | |
80 -- | |
81 2.26.2 | |
82 |