You are not logged in.

#1 2020-08-31 18:03:26

regularuser123
Member
Registered: 2020-06-18
Posts: 6

[SOLVED] How can I preview a big set of bitmap fonts?

The context

I like using bitmap fonts. I recently found out that there is a package in the repositories that contains a bunch of bitmap fonts.

pkgfile -l extra/xorg-fonts-misc | grep '\.pcf\.gz$' | wc -l
409

The problem is that I don't know how to preview fonts in Portable Compiled Format (i.e. "pcf" files). I have previously used the "display" command from "imagemagick" to preview TrueType fonts (i.e. ".ttf" files) but it seems that the "display" command doesn't allow previewing "pcf" files.

$ display 5x7.pcf.gz
display: no decode delegate for this image format `PCF' @ error/constitute.c/ReadImage/562.

I even tried unzipping the ".pcf.gz" file but still "display" is not able to preview them.

$ gunzip 4x6.pcf.gz
$ display 4x6.pcf
display: no decode delegate for this image format `PCF' @ error/constitute.c/ReadImage/562.

So, my question is: Is there any tool or way which would allow me to preview a big set of bitmap fonts? The current solution I'm using is explained below. However, I still want to know whether there are more effective ways to accomplish this.

The current workaround

What I would do is to generate the "fonts.dir" file using "mkfontdir" and then preview a font using "urxvt"

I first generate the "fonts.dir" file

$ mkfontdir ~/.local/share/fonts
$ cat ~/.local/share/fonts/fonts.dir
2
4x6.pcf.gz -misc-fixed-medium-r-normal--6-60-75-75-c-40-iso10646-1
5x7.pcf.gz -misc-fixed-medium-r-normal--7-70-75-75-c-50-iso10646-1

then I set the font I want to preview as the default one in "urxvt".

$ urxvt -fn '-misc-fixed-medium-r-normal--6-60-75-75-c-40-iso10646-1'

Finally, I would attach the shell to a "tmux" session that contains a vim buffer with all the characters I am interested in previewing.

Last edited by regularuser123 (2020-08-31 19:38:00)

Offline

#2 2020-08-31 18:33:34

regularuser123
Member
Registered: 2020-06-18
Posts: 6

Re: [SOLVED] How can I preview a big set of bitmap fonts?

While writing this question, I came up with this solution (I think it's enough for this task). I'm posting it here just in case anyone wonders I still need help.

#!/bin/dash

tail -n +2 ~/.local/share/fonts/fonts.dir | while read -r line
do
	filename="${line%% *}"
	x_logical="${line#* }"

	echo "$filename"
	urxvt -fn "$x_logical" -e tmux attach-session -t preview
done

Some notes

  • This script assumes that your bitmap font filenames don't contain spaces.

  • In the "tmux" session with name "preview", a vim buffer containing all characters I'm interested in previewing is opened.

Last edited by regularuser123 (2020-08-31 18:47:09)

Offline

#3 2020-08-31 19:24:05

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,685

Re: [SOLVED] How can I preview a big set of bitmap fonts?

We recently had this, there's an imagemagick script inside:
https://bbs.archlinux.org/viewtopic.php?id=255387

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

#4 2020-08-31 19:29:22

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,515
Website

Re: [SOLVED] How can I preview a big set of bitmap fonts?

Seth, while the solution in that thread would work, it's drastic overkill as that had to cope with (pretty much) any font.  If this is just for bitmap fonts, "there's an app for that".

EDIT: perhaps not ... I just tried it as it's been years since I last used it.  It actually "works" with all fonts - but it looked absolutely hideous.  I figured it might just suck with ttf fonts as it was made in the bitmap font days - so I checked out some bitmap fonts in it, and it still really really sucked.  I could hope that perhaps it just needs to be configured to work better, but it wasn't immediately obvious how to get reasonable previews of the fonts.

Last edited by Trilby (2020-08-31 19:35:17)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB