Page 1 of 1

Preview and dynamically switch fonts in urxvt

Posted: Wed Mar 23, 2016 2:21 pm
by a-109-107
I wrote this monstrous one-liner two solve to problems:
- test how a new font would look like in a terminal quickly
- identify what fonts I even have

Dependencies:
- fc-match, fzf (sorry), urxvt
- urxvt-font-change

Code: Select all

fc-match -av | grep -E "family\:|file\:" | sed 's/family: //' | sed 's/file: //' | tr -d '[:blank:]' | cut -d '"' -f2  | sed 'N;s/\n/\t/' | sort | uniq | fzf --bind "space:execute:(echo {} | cut -f2 | xargs ftview 12)" --bind "enter:execute:(echo {} | cut -f1 | xargs -L1 -I '$' urxvt-font-change 'xft:$:pixelsize=12')"
Here's a short picture-story of how it works:
Image

How to use:
execute, press return to preview font, press space to apply to current terminal instance

The problem right now is that not all fonts look good at `pixelsize=12` and I'm not sure how to 'elegantly' tweak that on the fly.

Re: Preview and dynamically switch fonts in urxvt

Posted: Wed Mar 23, 2016 5:55 pm
by machinebacon
nice idea. could even be tweaked for fbterm. thanks a lot

Re: Preview and dynamically switch fonts in urxvt

Posted: Wed Mar 23, 2016 7:11 pm
by GA-KO
Very cool one liner! I was not familiar with fzf.
I've only ever just found/used xfd which comes package with x11-utils a few months ago, kinda similar:

Code: Select all

xfd -fn -*-tamsyn-medium-r-normal-*-14-*-*-*-*-*-*-*