Created
February 5, 2023 12:43
-
-
Save weigert/9f5c75381b51b27768ab9df2ee2a53c4 to your computer and use it in GitHub Desktop.
Convert Font to ASCII PNG Image / Texture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# font2asciipng.sh | |
# | |
# This script uses imagemagick to generate a simple .png | |
# texture with ascii characters [32-127] from a font. | |
# | |
# Author: Nicholas McDonald | |
# Parameters | |
FONTNAME="gohufont.otb" | |
GLYPH_W=8 | |
GLYPH_H=14 | |
OUTPUT="output.png" | |
TEX_W=$((96*$GLYPH_W)) | |
# Compute the ASCII String | |
for i in {32..127} | |
do | |
ASCII="$ASCII$(printf "\\$(printf %o $i)")" | |
done | |
# Generate .PNG | |
echo $ASCII |\ | |
convert -pointsize ${GLYPH_H} -font ${FONTNAME} -page ${TEX_W}x${GLYPH_H}+${GLYPH_W}+0 \ | |
text: ${OUTPUT} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment