sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 8c16ed676772040ca0b9114a6c044b861be948de
parent f86baaa2bd4051bc11ed1ffb7e9f565b02b3f650
Author: Miles Alan <m@milesalan.com>
Date:   Mon,  7 Dec 2020 21:31:05 -0600

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

Diffstat:
Ast.suckless.org/patches/cyclefonts/index.md | 19+++++++++++++++++++
Ast.suckless.org/patches/cyclefonts/st-cyclefonts-0.8.4.diff | 82+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/st.suckless.org/patches/cyclefonts/index.md b/st.suckless.org/patches/cyclefonts/index.md @@ -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@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 @@ -0,0 +1,82 @@ +From 9262cecf21a3a2fcf5f5c0f7dcc872fdc5435ca1 Mon Sep 17 00:00:00 2001 +From: Miles Alan <m@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 +@@ -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; + + /* +@@ -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 +@@ -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" +@@ -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) + { +@@ -1113,8 +1126,8 @@ xinit(int cols, int rows) + if (!FcInit()) + die("could not init fontconfig.\n"); + +- 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 +