Added a convertfontto.sh script
authorWim Stockman <wim@thinkerwim.org>
Mon, 13 Mar 2023 13:09:37 +0000 (14:09 +0100)
committerWim Stockman <wim@thinkerwim.org>
Mon, 13 Mar 2023 13:09:37 +0000 (14:09 +0100)
This script makes it easy to convert a ttf or otf font to
your choice of encoding

tools/convertfontto.sh [new file with mode: 0755]

diff --git a/tools/convertfontto.sh b/tools/convertfontto.sh
new file mode 100755 (executable)
index 0000000..c7e94c0
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+# Small bashscript to convert a font to another encoding.
+# USAGE 
+#      convertfontto fontname outputfontname encoding destination
+#      place the destination into your .enscriptrc file or enscript.cfg
+#      Defaults are :  encoding - Latin9
+#                      outputfontname: fontname-encoding.afm
+#                      destination: $HOME/.config/enscript/afm
+#
+set -eu
+font=${1?Please give a font};
+encoding=${3:-iso8859-15};
+outputfile=${2:-"${font%.*}-$encoding"}
+destination=${4:-~/.config/enscript/afm};
+fontforge -lang=ff -c "Open(\"$font\");Reencode(\"$encoding\");Generate(\"$outputfile.pfa\")";
+mkdir -p $destination
+cp "$outputfile.pfa" "$destination/"
+cp "$outputfile.afm" "$destination/"
+cd $destination
+mkafmmap *.afm