Preview and dynamically switch fonts in urxvt

Forum rules
General talk about software - if the program is not in the repos, please links to the developer's page or github.
User avatar
a-109-107
Riesenpenis
Posts: 30
Joined: Thu May 21, 2015 9:04 am

Preview and dynamically switch fonts in urxvt

Unread post by a-109-107 » Wed Mar 23, 2016 2:21 pm

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.
Attachments
screenshot again
screenshot again

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Preview and dynamically switch fonts in urxvt

Unread post by machinebacon » Wed Mar 23, 2016 5:55 pm

nice idea. could even be tweaked for fbterm. thanks a lot
..gnutella..

User avatar
GA-KO
Oyster-Slurper
Posts: 22
Joined: Sun Mar 20, 2016 8:13 am

Re: Preview and dynamically switch fonts in urxvt

Unread post by GA-KO » Wed Mar 23, 2016 7:11 pm

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-*-*-*-*-*-*-*
Attachments
2016-03-23-140617_363x525_scrot.png

Post Reply