titlepic/create_caption: try alternative fonts

Do not FTBFS if the user does not have ghostscript / gsfonts installed.
Instead try some other fonts commonly installed by Linux distributions.

The patch is written to be easily extendable with extra font names, but
to be independent of the order of "convert -list font" output. Each
listed font is searched for in turn, and the first one found is used.
This commit is contained in:
RjY 2015-12-04 17:46:03 +00:00
parent d664fe5abe
commit d3a78b5133

View file

@ -1,11 +1,25 @@
#!/bin/sh #!/bin/sh
find_font() {
local font fontlist
fontlist=$(convert -list font | awk '$1=="Font:" { print $2 }')
for font in "$@" ; do
if echo $fontlist | grep -q $font ; then
echo $font
return
fi
done
}
font=$(find_font Helvetica-Bold Liberation-Sans-Bold DejaVu-Sans-Condensed-Bold)
if [ -z "$font" ] ; then echo "Cannot find any fonts" ; exit 1 ; fi
draw_with_footer() { draw_with_footer() {
input_file=$1; input_file=$1;
output_file=$2; output_file=$2;
shift; shift shift; shift
convert $input_file -fill white -font Helvetica-Bold \ convert $input_file -fill white -font "$font" \
-pointsize 11 \ -pointsize 11 \
-gravity southwest \ -gravity southwest \
-draw "text 5,5 'https://freedoom.github.io/'" \ -draw "text 5,5 'https://freedoom.github.io/'" \