Skip to content

Commit

Permalink
Merge pull request #1806 from stweil/training
Browse files Browse the repository at this point in the history
training: Add new flag --workspace_dir to tesstraining_utils.sh
  • Loading branch information
egorpugin committed Jul 26, 2018
2 parents fbff323 + b19e690 commit 51c1950
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/training/tesstrain_utils.sh
Expand Up @@ -18,8 +18,10 @@

if [ "$(uname)" == "Darwin" ];then
FONTS_DIR="/Library/Fonts/"
FONT_CONFIG_CACHE=$(mktemp -d -t font_tmp.XXXXXXXXXX)
else
FONTS_DIR="/usr/share/fonts/"
FONT_CONFIG_CACHE=$(mktemp -d --tmpdir font_tmp.XXXXXXXXXX)
fi
OUTPUT_DIR="/tmp/tesstrain/tessdata"
OVERWRITE=0
Expand Down Expand Up @@ -148,6 +150,13 @@ parse_flags() {
--wordlist)
parse_value "WORDLIST_FILE" ${ARGV[$j]}
i=$j ;;
--workspace_dir)
rmdir "$FONT_CONFIG_CACHE"
rmdir "$WORKSPACE_DIR"
parse_value "WORKSPACE_DIR" ${ARGV[$j]}
FONT_CONFIG_CACHE=$WORKSPACE_DIR/fc-cache
mkdir -p $FONT_CONFIG_CACHE
i=$j ;;
*)
err_exit "Unrecognized argument ${ARGV[$i]}" ;;
esac
Expand Down Expand Up @@ -192,11 +201,7 @@ parse_flags() {

# Function initializes font config with a unique font cache dir.
initialize_fontconfig() {
if [[ "$OSTYPE" == "darwin"* ]]; then
export FONT_CONFIG_CACHE=$(mktemp -d -t font_tmp.XXXXXXXXXX)
else
export FONT_CONFIG_CACHE=$(mktemp -d --tmpdir font_tmp.XXXXXXXXXX)
fi
export FONT_CONFIG_CACHE
local sample_path=${FONT_CONFIG_CACHE}/sample_text.txt
echo "Text" >${sample_path}
run_command text2image --fonts_dir=${FONTS_DIR} \
Expand Down

0 comments on commit 51c1950

Please sign in to comment.