aboutsummaryrefslogtreecommitdiff
path: root/font_api/tools
diff options
context:
space:
mode:
authorPierre-Yves Rollo <dev@pyrollo.com>2019-12-31 17:06:15 +0100
committerPierre-Yves Rollo <dev@pyrollo.com>2019-12-31 17:06:15 +0100
commit135cae721906d312cd0084f7343a15760e3aa722 (patch)
tree2e17a8b49e86c5b99e9ff8681879f28860437d74 /font_api/tools
parentde915427ee9e4e741dc5079a57b8d129e2b7e916 (diff)
downloaddisplay_modpack_no_craft-135cae721906d312cd0084f7343a15760e3aa722.tar.gz
display_modpack_no_craft-135cae721906d312cd0084f7343a15760e3aa722.zip
Removed display_api, signs_api, and font_api to make them subtrees
Diffstat (limited to 'font_api/tools')
-rwxr-xr-xfont_api/tools/make_font_lua.sh71
-rwxr-xr-xfont_api/tools/make_font_textures.sh111
2 files changed, 0 insertions, 182 deletions
diff --git a/font_api/tools/make_font_lua.sh b/font_api/tools/make_font_lua.sh
deleted file mode 100755
index e858360..0000000
--- a/font_api/tools/make_font_lua.sh
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/bash
-
-scriptname=$(basename $0)
-identify="identify"
-
-usage() {
- echo "Usage: $0 fontname"
- echo "fontname: The name of the font. Must correspond to existing texture/font_<fontname>_????.png files"
-}
-
-if [ $# -ne 1 ]
-then
- usage
- exit 1
-fi
-
-font_name=$1
-
-for f in textures/font_${font_name}_????.png
-do
- if [[ $f =~ textures/font_${font_name}_([0-9a-fA-F]{4}).png ]]
- then
- code=$((16#${BASH_REMATCH[1]}))
- size=$(identify $f | cut -d " " -f 3)
- w=$(echo $size | cut -d "x" -f 1)
- h=$(echo $size | cut -d "x" -f 2)
-
- if [ -z "$font_height" ]
- then
- font_height=$h
- else
- if [ $font_height -ne $h ]
- then
- echo "Error : $f as height of $h pixels, previous textures have a height of $font_height pixels. All textures should have the same height."
- fi
- fi
-
- if [ -z "$font_widths" ]
- then
- font_widths="[$code]=$w"
- else
- font_widths="$font_widths, [$code]=$w"
- fi
- fi
-done
-
-echo "--[[
-
-$luafile generated by $scriptname $(LANG=en_US date)
-
---]]
-
-font_api.register_font(
- '$font_name',
- {
- height = $font_height,
- widths = {
- $font_widths
- },
- }
-);
-" > font_$font_name.lua
-
-if grep -q font_api depends.txt &>/dev/null
-then
- echo "font_api already in depends.txt."
-else
- echo "adding font_api to depends.txt."
- echo "font_api" >> depends.txt
-fi
-
diff --git a/font_api/tools/make_font_textures.sh b/font_api/tools/make_font_textures.sh
deleted file mode 100755
index 4a3191c..0000000
--- a/font_api/tools/make_font_textures.sh
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/bin/bash
-
-# This program generates a bitmap font for font_api mod for Minetest game.
-# (c) Andrzej Pieńkowski <pienkowski.andrzej@gmail.com>
-# (c) Pierre-Yves Rollo <dev@pyrollo.com>
-# 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 "<map code=" | cut -d \" -f 2)
-
-# Mandatory chars
-generate 0020 007f
-
-# generate space and null characters
-if [ ! -f "textures/font_${fontname}_0030.png" ]; then
- echo "Error: Something wrong happened! Font was not generated!"
- exit 1
-else
- size=$(identify textures/font_${fontname}_0030.png | cut -d " " -f 3)
- if ! [[ $fontHeight =~ $re ]] ; then
- echo "Error: Something wrong happened! Generated files might be broken!"
- exit 1
- else
- w=$(expr $(echo $size | cut -d x -f 1) - 1)
- h=$(expr $(echo $size | cut -d x -f 2) - 1)
- # Space char
- convert -size $size xc:transparent -colorspace gray textures/font_${fontname}_0020.png
- # Null char
- convert -size $size xc:transparent -colorspace gray -stroke black -fill transparent -strokewidth 1 -draw "rectangle 0,0 $w,$h" textures/font_${fontname}_0000.png
- fi
-fi
-
-# Optional Unicode pages (see https://en.wikipedia.org/wiki/Unicode) :
-
-# 00a0-00ff Latin-1 Supplement (full)
-generate 00a0 00ff
-# 0100-017f Latin Extended-A (full)
-generate 0100 017f
-# 0370-03ff Greek (full)
-generate 0370 03ff
-# 0400-04ff Cyrilic (full)
-generate 0400 04ff
-# 2000-206f General Punctuation (Limited to Dashes)
-generate 2010 2015
-# 2000-206f General Punctuation (Limited to Quotes)
-generate 2018 201F
-# 20a0-20cf Currency Symbols (Limited to Euro symbol)
-generate 20ac 20ac
-
-