Skip to content

Instantly share code, notes, and snippets.

@willeccles
Last active January 2, 2020 22:50
Show Gist options
  • Save willeccles/315ada913bc6d26626cfe1b204dd1d52 to your computer and use it in GitHub Desktop.
Save willeccles/315ada913bc6d26626cfe1b204dd1d52 to your computer and use it in GitHub Desktop.
Take screenshots of all fonts in a linux console.
#! /bin/bash -e
if ! command -v fbgrab &>/dev/null; then
echo "Please install fbgrab before running this."
exit 1
fi
fontpath="${FONTPATH:-/usr/share/consolefonts}"
cd "$fontpath"
outputpath="${1:-/shared/fontpics}"
shopt -s extglob
if [ -f "$outputpath" ]; then
echo "$outputpath already exists and is not a directory!"
exit 1
fi
if [ ! -d "$outputpath" ]; then
mkdir "$outputpath"
fi
for font in *.psf*; do
fontnoext="${font//.psf*/}"
fontname="${fontnoext/%?(+([0-9])?(x+([0-9])))}"
fontsize="${fontnoext/#"$fontname"}"
if setfont $font; then
clear
printf "$fontname: $fontsize\n\n"
showconsolefont
fbgrab "$outputpath/$fontnoext.png"
fi
done
clear
echo "Screenshots saved to $outputpath."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment