1 |
calchan 13/11/04 19:33:21 |
2 |
|
3 |
Added: cm2pdf |
4 |
Log: |
5 |
Change CM2pdf into cm2pdf. Add variable font size and a --help option. |
6 |
|
7 |
(Portage version: 2.2.7/cvs/Linux x86_64, unsigned Manifest commit) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 dev-tex/circuit_macros/files/cm2pdf |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-tex/circuit_macros/files/cm2pdf?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-tex/circuit_macros/files/cm2pdf?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: cm2pdf |
16 |
=================================================================== |
17 |
#! /bin/bash |
18 |
|
19 |
m4file="" |
20 |
fontsize=10 |
21 |
|
22 |
usage() { |
23 |
echo "Usage:" |
24 |
echo "${0##*/} --help" |
25 |
echo "${0##*/} [options] path/to/file.m4" |
26 |
echo |
27 |
echo "--help" |
28 |
echo " Show this help message." |
29 |
echo |
30 |
echo "-f, --fontsize" |
31 |
echo " Set size of base font, in points." |
32 |
echo " Supported font sizes are 8, 9, 10, 11, 12, 14, 17 and 20." |
33 |
exit |
34 |
} |
35 |
|
36 |
if [[ "$#" == 0 ]]; then usage; fi |
37 |
|
38 |
while [[ "$#" != 0 ]]; do |
39 |
case "${1}" in |
40 |
-h|--help) |
41 |
usage;; |
42 |
-f|--fontsize) |
43 |
case "${2}" in |
44 |
8) |
45 |
fontsize=8;; |
46 |
9) |
47 |
fontsize=9;; |
48 |
10) |
49 |
fontsize=10;; |
50 |
11) |
51 |
fontsize=11;; |
52 |
12) |
53 |
fontsize=12;; |
54 |
14) |
55 |
fontsize=14;; |
56 |
17) |
57 |
fontsize=17;; |
58 |
20) |
59 |
fontsize=20;; |
60 |
*) |
61 |
echo "Unsupported font size: ${2}" |
62 |
exit;; |
63 |
esac |
64 |
shift; shift;; |
65 |
*.m4) |
66 |
m4file="${1}" |
67 |
shift;; |
68 |
*) |
69 |
echo "Unknown option: ${1}" |
70 |
exit |
71 |
esac |
72 |
done |
73 |
|
74 |
if [[ "${m4file}" == "" ]]; then |
75 |
echo "No m4 input file" |
76 |
exit |
77 |
fi |
78 |
|
79 |
tempdir=$(mktemp -d) |
80 |
cp -f "${m4file}" "${tempdir}/source.m4" |
81 |
pushd "${tempdir}" > /dev/null |
82 |
|
83 |
m4 -I /usr/share/circuit_macros pgf.m4 source.m4 | dpic -g > source.tex |
84 |
pdflatex "\documentclass[preview=true]{standalone}\usepackage{tikz,boxdims}\usepackage[${fontsize}pt]{extsizes}\begin{document}\input source.tex\end{document}" |
85 |
|
86 |
popd > /dev/null |
87 |
cp "${tempdir}/standalone.pdf" "${m4file%.m4}.pdf" |
88 |
rm -rf "${tempdir}" |