Use shell quoting rather than pluses to separate font arguments in tesstrain.sh

The way tesstrain.sh handled font names was really weird, using '+'
signs as a delimiter. However quoting arguments is a much more
straightforward, standard and sensible way to do things.

So whereas previously one would have used this:
  --fontlist Times New Roman + Arial Black
Now they should be specified like this:
  --fontlist "Times New Roman" "Arial Black"
This commit is contained in:
Nick White 2015-10-30 13:26:45 +00:00
parent 0d61f0c05a
commit 306610c5ec
2 changed files with 13 additions and 11 deletions

View File

@ -17,7 +17,7 @@
# USAGE: # USAGE:
# #
# tesstrain.sh # tesstrain.sh
# --fontlist FONTS_STR # A plus-separated list of fontnames to train on. # --fontlist FONTS # A list of fontnames to train on.
# --fonts_dir FONTS_PATH # Path to font files. # --fonts_dir FONTS_PATH # Path to font files.
# --lang LANG_CODE # ISO 639 code. # --lang LANG_CODE # ISO 639 code.
# --langdata_dir DATADIR # Path to tesseract/training/langdata directory. # --langdata_dir DATADIR # Path to tesseract/training/langdata directory.

View File

@ -90,19 +90,21 @@ parse_flags() {
case ${ARGV[$i]} in case ${ARGV[$i]} in
--) --)
break;; break;;
--fontlist) # Expect a plus-separated list of names --fontlist)
if [[ -z ${ARGV[$j]} ]] || [[ ${ARGV[$j]:0:2} == "--" ]]; then fn=0
err_exit "Invalid value passed to --fontlist" FONTS=""
fi while test $j -lt ${#ARGV[@]}; do
local ofs=$IFS test -z "${ARGV[$j]}" && break
IFS='+' test `echo ${ARGV[$j]} | cut -c -2` = "--" && break
FONTS=( ${ARGV[$j]} ) FONTS[$fn]="${ARGV[$j]}"
IFS=$ofs fn=$((fn+1))
i=$j ;; j=$((j+1))
done
i=$((j-1)) ;;
--exposures) --exposures)
exp="" exp=""
while test $j -lt ${#ARGV[@]}; do while test $j -lt ${#ARGV[@]}; do
test -z ${ARGV[$j]} && break test -z "${ARGV[$j]}" && break
test `echo ${ARGV[$j]} | cut -c -2` = "--" && break test `echo ${ARGV[$j]} | cut -c -2` = "--" && break
exp="$exp ${ARGV[$j]}" exp="$exp ${ARGV[$j]}"
j=$((j+1)) j=$((j+1))