annotate makeBookeTunePages.sh @ 319:cbe9c10b5a3e

Render tune title, subtitle and composer in Latex/HTML and not in the image. This way the titles remains a constant size even if the image needs to be scaled. And we have that text appearance under our control. I can't find a way of switching off the tune title in abcm2ps, and have worked around by setting the title format to Y0. Y is not a defined ABC header and is not found in any Dottes tune.
author Jim Hague <jim.hague@acm.org>
date Tue, 16 Jul 2013 16:35:07 +0100
parents 8bc92e044e0a
children 1a240d1e2032
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
1 #!/bin/bash
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
2 #
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
3 # Generate the LaTeX for the Booke tune pages (tunes.tex) and the index
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
4 # of first lines (firstlines.tex). These are generated into the build
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
5 # directory.
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
6 #
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
7 # All EPS and PDF tune graphics must be present already. Run
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
8 # makeGraphics.sh to make these.
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
9 #
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
10
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
11 # Restore titles like 'Exploding Potato, The' to the
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
12 # expected 'The Exploding Potato'.
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
13 fixtitle()
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
14 {
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
15 retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"`
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
16 }
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
17
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
18 if [ $# != 1 ]; then
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
19 echo "Usage: makeBookeTunePages.sh <book dir name>"
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
20 exit 1
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
21 fi
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
22
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
23 dir=`pwd`
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
24
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
25 booke=$dir/$1
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
26 builddir=$dir/build
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
27 graphicsdir=$dir/graphics/$1
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
28 tunesoutput=$builddir/tunes.tex
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
29 indexoutput=$builddir/firstlines.tex
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
30
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
31 mkdir -p $builddir
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
32
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
33 rm -f $tunesoutput $indexoutput
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
34
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
35 # Now, for each tune, make the tune graphic and add it, inside a
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
36 # centre section, so the document. Then add a TOC entry.
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
37 find $booke -name "*.abc" | sort |
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
38 while read filename
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
39 do
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
40 name=`basename $filename .abc`
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
41 title=`$dir/abcfield.py --field T --latex $filename`
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
42 fixtitle "$title"
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
43 title=$retval
319
cbe9c10b5a3e Render tune title, subtitle and composer in Latex/HTML and not in the image.
Jim Hague <jim.hague@acm.org>
parents: 312
diff changeset
44 subtitle=`$dir/abcfield.py --index 2 --field T --latex $filename`
cbe9c10b5a3e Render tune title, subtitle and composer in Latex/HTML and not in the image.
Jim Hague <jim.hague@acm.org>
parents: 312
diff changeset
45 composer=`$dir/abcfield.py --field C --latex $filename`
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
46
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
47 changefile=`$dir/abcfield.py --field N $filename | grep "Change:" | sed -e "s/Change: *//"`
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
48 changetitle=""
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
49 if [ -n "$changefile" ]; then
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
50 changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile`
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
51 fixtitle "$changetitle"
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
52 changetitle=$retval
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
53 fi
319
cbe9c10b5a3e Render tune title, subtitle and composer in Latex/HTML and not in the image.
Jim Hague <jim.hague@acm.org>
parents: 312
diff changeset
54 echo -E "\showtune{$title}{$subtitle}{$composer}{$graphicsdir/$name}{$changetitle}" >> $tunesoutput
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
55
312
8bc92e044e0a Move tune and first line inclusion code into macros.
Jim Hague <jim.hague@acm.org>
parents: 306
diff changeset
56 echo -E "\showfirstline{$title}{$graphicsdir/firstline-$name}" >> $indexoutput
266
06e140f48543 Revise scripts for building printed Bookes.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
57 done