You are not logged in.
Pages: 1
It is bit complicated to get the parameters right for terminal fonts, so I wrote small ruby script.
Save as font.rb, give it +x flag, execute in urxvt.
#!/usr/bin/env ruby
require 'io/console'
fontsraw = `fc-list :mono family style | sort`.split("\n")
$fonts = []
fontsraw.each do |fontraw|
font = fontraw.split(":")
family = font[0].split(",")
style = font[1].split(",")
$fonts.push([family[0],style[0]])
end
puts "-----------------------------------------------------------------------------"
puts "[Q = Quit] [Left,Right = Select Font] [Up,Down = Select Size] [Enter = Set]"
puts "-----------------------------------------------------------------------------"
$setfontindex = -1
$fontindex = 0
$setfontsize = -1
$fontsize = 12
def buildXFT()
return "xft:" + $fonts[$fontindex][0] + ":" + $fonts[$fontindex][1] + ":pixelsize=" + $fontsize.to_s
end
def showStat()
print "\e[200D"
if (($setfontindex != $fontindex) || ($setfontsize != $fontsize)) then
print "[*] "
end
print buildXFT
print "\e[K"
end
showStat
while ((ch = STDIN.getch) != "q") do
if (ch == "\e") then
ch = ch + STDIN.getch
ch = ch + STDIN.getch
end
if (ch == "\e[D") then
$fontindex = [$fontindex - 1, 0].max
end
if (ch == "\e[C") then
$fontindex = [$fontindex + 1, $fonts.size - 1].min
end
if (ch == "\e[B") then
$fontsize = [$fontsize - 1, 6].max
end
if (ch == "\e[A") then
$fontsize = [$fontsize + 1, 40].min
end
if (ch == "\r") then
$setfontindex = $fontindex
$setfontsize = $fontsize
print "\e]710;" + buildXFT + "\007"
end
showStat
end
Last edited by dpx (2017-10-18 10:38:07)
Offline
I don't know how to put it : super extra great
This is a dangerous alternative to all those gui utilities because you can fill the terminal with some text, run the script and you get an instant live preview !
Thanks !
Offline
Exactly why I had to build it, converting GUI preview to proper terminal look never works great.
Note that the way that xft string is built can be changed, for instance:
def buildXFT()
return "xft:" + $fonts[$fontindex][0] + ":" + $fonts[$fontindex][1] + ":pixelsize=" + $fontsize.to_s + ":antialias=true:autohint=true"
end
... to set antialiasing and hinting.
Last edited by dpx (2017-10-18 17:18:25)
Offline
Pages: 1