Skip to content

Commit

Permalink
Use shell quoting rather than pluses to separate font arguments in te…
Browse files Browse the repository at this point in the history
…sstrain.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"
  • Loading branch information
nickjwhite committed Oct 30, 2015
1 parent 0d61f0c commit 306610c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion training/tesstrain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# USAGE:
#
# 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.
# --lang LANG_CODE # ISO 639 code.
# --langdata_dir DATADIR # Path to tesseract/training/langdata directory.
Expand Down
22 changes: 12 additions & 10 deletions training/tesstrain_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,21 @@ parse_flags() {
case ${ARGV[$i]} in
--)
break;;
--fontlist) # Expect a plus-separated list of names
if [[ -z ${ARGV[$j]} ]] || [[ ${ARGV[$j]:0:2} == "--" ]]; then
err_exit "Invalid value passed to --fontlist"
fi
local ofs=$IFS
IFS='+'
FONTS=( ${ARGV[$j]} )
IFS=$ofs
i=$j ;;
--fontlist)
fn=0
FONTS=""
while test $j -lt ${#ARGV[@]}; do
test -z "${ARGV[$j]}" && break
test `echo ${ARGV[$j]} | cut -c -2` = "--" && break
FONTS[$fn]="${ARGV[$j]}"
fn=$((fn+1))
j=$((j+1))
done
i=$((j-1)) ;;
--exposures)
exp=""
while test $j -lt ${#ARGV[@]}; do
test -z ${ARGV[$j]} && break
test -z "${ARGV[$j]}" && break
test `echo ${ARGV[$j]} | cut -c -2` = "--" && break
exp="$exp ${ARGV[$j]}"
j=$((j+1))
Expand Down

0 comments on commit 306610c

Please sign in to comment.