Skip to content

Commit 306610c

Browse files
committed
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"
1 parent 0d61f0c commit 306610c

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

training/tesstrain.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# USAGE:
1818
#
1919
# tesstrain.sh
20-
# --fontlist FONTS_STR # A plus-separated list of fontnames to train on.
20+
# --fontlist FONTS # A list of fontnames to train on.
2121
# --fonts_dir FONTS_PATH # Path to font files.
2222
# --lang LANG_CODE # ISO 639 code.
2323
# --langdata_dir DATADIR # Path to tesseract/training/langdata directory.

training/tesstrain_utils.sh

+12-10
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,21 @@ parse_flags() {
9090
case ${ARGV[$i]} in
9191
--)
9292
break;;
93-
--fontlist) # Expect a plus-separated list of names
94-
if [[ -z ${ARGV[$j]} ]] || [[ ${ARGV[$j]:0:2} == "--" ]]; then
95-
err_exit "Invalid value passed to --fontlist"
96-
fi
97-
local ofs=$IFS
98-
IFS='+'
99-
FONTS=( ${ARGV[$j]} )
100-
IFS=$ofs
101-
i=$j ;;
93+
--fontlist)
94+
fn=0
95+
FONTS=""
96+
while test $j -lt ${#ARGV[@]}; do
97+
test -z "${ARGV[$j]}" && break
98+
test `echo ${ARGV[$j]} | cut -c -2` = "--" && break
99+
FONTS[$fn]="${ARGV[$j]}"
100+
fn=$((fn+1))
101+
j=$((j+1))
102+
done
103+
i=$((j-1)) ;;
102104
--exposures)
103105
exp=""
104106
while test $j -lt ${#ARGV[@]}; do
105-
test -z ${ARGV[$j]} && break
107+
test -z "${ARGV[$j]}" && break
106108
test `echo ${ARGV[$j]} | cut -c -2` = "--" && break
107109
exp="$exp ${ARGV[$j]}"
108110
j=$((j+1))

0 commit comments

Comments
 (0)