2020-02-10 18:01:40 +01:00
#!/usr/bin/env sh
2022-01-06 20:17:51 +01:00
# Copyright (c) 2018 - 2022, Martin Scheidt (ISC license)
2020-02-10 18:01:40 +01:00
# Permission to use, copy, modify, and/or distribute this file for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
2022-01-17 09:34:48 +01:00
LATEX = $( which pdflatex)
PDF2SVG = $( which pdf2svg)
CONVERT = $( which convert)
2020-02-10 18:01:40 +01:00
2022-01-17 09:34:48 +01:00
mkdir -p .tex
2020-02-10 18:01:40 +01:00
2022-01-17 09:34:48 +01:00
for FILE in symbols_tikz/*.tikz; do
SYMBOL = $( basename $FILE .tikz)
echo " converting: $SYMBOL "
## -- header tex file
echo '\\documentclass[tikz,border=0]{standalone}' > tmp.tex
echo '\\usepackage[dev]{tikz-trackschematic}' >> tmp.tex
2020-02-10 18:01:40 +01:00
echo '\\begin{document}' >> tmp.tex
echo '\\begin{tikzpicture}[font=\\sffamily]' >> tmp.tex
2022-01-17 09:34:48 +01:00
## -- input symbol
echo '\\input{' $FILE '}' >> tmp.tex
## -- footer tex file
2020-02-10 18:01:40 +01:00
echo '\\end{tikzpicture}' >> tmp.tex
echo '\\end{document}' >> tmp.tex
2022-01-17 09:34:48 +01:00
# echo "---------------"
# cat tmp.tex
# echo "---------------"
## -- compile tmp.tex
# $LATEX -output-directory=.tex tmp.tex
$LATEX -output-directory= .tex -interaction= batchmode tmp.tex 2>& 1 > /dev/null
## -- copy and convert symbols
$PDF2SVG .tex/tmp.pdf symbols_svg/$SYMBOL .svg
$CONVERT -density 300 .tex/tmp.pdf symbols_png/$SYMBOL .png
mv .tex/tmp.pdf symbols_pdf/$SYMBOL .pdf
2020-02-10 18:01:40 +01:00
done
2022-01-17 09:34:48 +01:00
## -- cleanup
rm -rf .tex/
rm tmp.tex