From f3970f641eb60bf92492b6715084273cc1bceb74 Mon Sep 17 00:00:00 2001 From: Thomas--S Date: Thu, 1 Feb 2018 16:54:55 +0100 Subject: Seperate signs API from signs definitions Change modnames from *_lib to *_api --- font_api/tools/make_font_textures.sh | 111 +++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100755 font_api/tools/make_font_textures.sh (limited to 'font_api/tools/make_font_textures.sh') diff --git a/font_api/tools/make_font_textures.sh b/font_api/tools/make_font_textures.sh new file mode 100755 index 0000000..6f4959d --- /dev/null +++ b/font_api/tools/make_font_textures.sh @@ -0,0 +1,111 @@ +#!/bin/bash + +# This program generates a bitmap font for font_api mod for Minetest game. +# (c) Andrzej Pieńkowski +# (c) Pierre-Yves Rollo +# License: GPL + +usage() { + echo "Usage: $0 fontfile fontname fontsize" + echo "fontfile: A TTF font file to use to create textures." + echo "fontname: The font name to be used in font_api (should be simple, with no spaces)." + echo "fontsize: Font height to be rendered." +} + +if [ $# -ne 3 ] +then + usage + exit 1 +fi + +fontfile=$1 +fontname=$2 +fontsize=$3 + +if [ ! -r "$fontfile" ] +then + echo "$fontfile not readable." + exit 1 +fi + +# check imagemagick +hash convert &>/dev/null +if [ $? -eq 1 ]; then + echo -e "Error: This program requires convert from ImageMagick! Please install it by typing 'sudo apt-get install imagemagick' in terminal." + abort=1 +fi + +# check ttx +hash ttx &>/dev/null +if [ $? -eq 1 ]; then + echo -e "Error: This program requires ttx from FontTools! Please install it by typing 'sudo apt-get install fonttools' in terminal." + abort=1 +fi + +if [ $abort ] +then + exit 1 +fi + +generate() { + for i in $(seq $((0x$1)) $((0x$2))) + do + if echo "$codepoints" | grep -qi $(printf "0x%x" $i) + then + hex=$(printf "%04x" $i) + echo -e "Generating textures/font_${fontname}_$hex.png file for \"\\U$hex\" char." + if [[ "$hex" == "005c" ]] # Backslash char + then + convert -background none -fill black -font "$fontfile" -pointsize $fontsize label:"\\\\" -colorspace gray -channel alpha -threshold 50% textures/font_${fontname}_$hex.png + else + convert -background none -fill black -font "$fontfile" -pointsize $fontsize label:"$(echo -en "\\U$hex")" -colorspace gray -channel alpha -threshold 50% textures/font_${fontname}_$hex.png + fi + fi + done +} + +mkdir textures + +# Reads all available code points in the font. +codepoints=$(ttx -o - $fontfile | grep " Date: Sun, 8 Jul 2018 20:36:34 +0200 Subject: Creation of Font class and code update accordingly --- font_api/tools/make_font_textures.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'font_api/tools/make_font_textures.sh') diff --git a/font_api/tools/make_font_textures.sh b/font_api/tools/make_font_textures.sh index 6f4959d..4a3191c 100755 --- a/font_api/tools/make_font_textures.sh +++ b/font_api/tools/make_font_textures.sh @@ -67,7 +67,7 @@ generate() { mkdir textures # Reads all available code points in the font. -codepoints=$(ttx -o - $fontfile | grep "