2017-12-19 21:52:49 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-13 12:38:55 +01:00
|
|
|
scriptname=$(basename $0)
|
2017-12-19 21:52:49 +01:00
|
|
|
identify="identify"
|
|
|
|
|
2018-01-13 12:38:55 +01:00
|
|
|
font_name=$1
|
2017-12-19 21:52:49 +01:00
|
|
|
|
|
|
|
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 "--[[
|
|
|
|
|
2017-12-21 21:47:16 +01:00
|
|
|
$luafile generated by $scriptname $(LANG=en_US date)
|
2017-12-19 21:52:49 +01:00
|
|
|
|
|
|
|
--]]
|
|
|
|
|
2018-02-01 16:54:55 +01:00
|
|
|
font_api.register_font(
|
2017-12-19 21:52:49 +01:00
|
|
|
'$font_name',
|
|
|
|
$font_height,
|
|
|
|
{ $font_widths }
|
|
|
|
);
|
|
|
|
" > font_$font_name.lua
|
|
|
|
|
2018-02-01 16:54:55 +01:00
|
|
|
if grep -q font_api depends.txt &>/dev/null
|
2018-01-13 12:38:55 +01:00
|
|
|
then
|
2018-02-01 16:54:55 +01:00
|
|
|
echo "font_api already in depends.txt."
|
2018-01-13 12:38:55 +01:00
|
|
|
else
|
2018-02-01 16:54:55 +01:00
|
|
|
echo "adding font_api to depends.txt."
|
|
|
|
echo "font_api" >> depends.txt
|
2018-01-13 12:38:55 +01:00
|
|
|
fi
|
|
|
|
|