changeset 122:295ba8275ab4

Make output larger where possible. This is done by a) reducing the page margins b) compressing the heading and removing all but Notes: fields. The latter produced vertically smaller tune PDFs that will scale wider. In the process, modify abctitle.py to extract the first of any header field, and move formatting for a single tune into a .fmt file.
author Jim Hague <jim.hague@laicatc.com>
date Sat, 21 Apr 2012 19:47:30 +0100
parents 586631d3b9be
children 0d9aeb2d0879
files abcfield.py abctitle.py dottes.tex.header makeBooke.sh makeGraphics.sh makeWeb.sh singletune.fmt
diffstat 7 files changed, 170 insertions(+), 143 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/abcfield.py	Sat Apr 21 19:47:30 2012 +0100
@@ -0,0 +1,138 @@
+#!/usr/bin/env python
+#
+# Extact a text field (title, by default) from a .abc file, and print it out
+# formatted for use in LaTeX or HTML.
+#
+
+import optparse
+import sys
+
+accentedletters = {
+    # Acute accents
+    "'A" : ("&Aacute;", "\\'{A}"),
+    "'E" : ("&Eacute;", "\\'{E}"),
+    "'I" : ("&Iacute;", "\\'{I}"),
+    "'O" : ("&Oacute;", "\\'{O}"),
+    "'U" : ("&Uacute;", "\\'{U}"),
+    "'Y" : ("&Yacute;", "\\'{Y}"),
+    "'a" : ("&aacute;", "\\'{a}"),
+    "'e" : ("&eacute;", "\\'{e}"),
+    "'i" : ("&iacute;", "\\'{i}"),
+    "'o" : ("&oacute;", "\\'{o}"),
+    "'u" : ("&uacute;", "\\'{u}"),
+    "'y" : ("&yacute;", "\\'{y}"),
+
+    # Grave accents
+    "`A" : ("&Agrave;", "\\`{A}"),
+    "`E" : ("&Egrave;", "\\`{E}"),
+    "`I" : ("&Igrave;", "\\`{I}"),
+    "`O" : ("&Ograve;", "\\`{O}"),
+    "`U" : ("&Ugrave;", "\\`{U}"),
+    "`a" : ("&agrave;", "\\`{a}"),
+    "`e" : ("&egrave;", "\\`{e}"),
+    "`i" : ("&igrave;", "\\`{i}"),
+    "`o" : ("&ograve;", "\\`{o}"),
+    "`u" : ("&ugrave;", "\\`{u}"),
+
+    # Umlauts
+    "\"A" : ("&Auml;", "\\\"{A}"),
+    "\"E" : ("&Euml;", "\\\"{E}"),
+    "\"I" : ("&Iuml;", "\\\"{I}"),
+    "\"O" : ("&Ouml;", "\\\"{O}"),
+    "\"U" : ("&Uuml;", "\\\"{U}"),
+    "\"Y" : ("&Yuml;", "\\\"{Y}"),
+    "\"a" : ("&auml;", "\\\"{a}"),
+    "\"e" : ("&euml;", "\\\"{e}"),
+    "\"i" : ("&iuml;", "\\\"{\i}"),
+    "\"o" : ("&ouml;", "\\\"{o}"),
+    "\"u" : ("&uuml;", "\\\"{u}"),
+    "\"y" : ("&yuml;", "\\\"{y}"),
+
+    # Circumflexes
+    "^A" : ("&Acirc;", "\\^{A}"),
+    "^E" : ("&Ecirc;", "\\^{E}"),
+    "^I" : ("&Icirc;", "\\^{I}"),
+    "^O" : ("&Ocirc;", "\\^{O}"),
+    "^U" : ("&Ucirc;", "\\^{U}"),
+    "^a" : ("&acirc;", "\\^{a}"),
+    "^e" : ("&ecirc;", "\\^{e}"),
+    "^i" : ("&icirc;", "\\^{\i}"),
+    "^o" : ("&ocirc;", "\\^{o}"),
+    "^u" : ("&ucirc;", "\\^{u}"),
+
+    # Tilde
+    "~A" : ("&Atilde;", "\\~{A}"),
+    "~N" : ("&Ntilde;", "\\~{N}"),
+    "~O" : ("&Otilde;", "\\~{O}"),
+    "~a" : ("&atilde;", "\\~{a}"),
+    "~n" : ("&ntilde;", "\\~{n}"),
+    "~o" : ("&otilde;", "\\~{o}"),
+
+    # Cedilla
+    ",C" : ("&Ccedil;", "\\c{C}"),
+    ",c" : ("&ccedil;", "\\c{c}"),
+
+    # Slash
+    "/O" : ("&Oslash;", "\\O"),
+    "/o" : ("&oslash;", "\\o"),
+
+    # Ring
+    "AA" : ("&Aring;", "\\r{A}"),
+    "aa" : ("&aring;", "\\r{a}"),
+
+    # Ligatures
+    "AE" : ("&AElig;", "\\AE"),
+    "ae" : ("&aelig;", "\\ae"),
+    "ss" : ("&szlig;", "\\ss"),
+}
+
+def convertTitle(t, options):
+    res = ""
+    while True:
+        p = t.partition('\\')
+        res += p[0]
+        if p[1] == "":
+            break
+        abc = p[2][0:2]
+        t = p[2][2:]
+        if (options.html or options.latex) and abc in accentedletters:
+            if options.html:
+                res += accentedletters[abc][0]
+            else:
+                res += accentedletters[abc][1]
+        else:
+            res += "\\" + abc
+    return res
+
+def process(inf, options):
+    for line in inf:
+        line = line.strip()
+        if len(line) > 2 and line[0] == options.field and line[1] == ':':
+            print(convertTitle(line[2:].strip(), options))
+            break
+
+parser = optparse.OptionParser(usage="usage: %prog [options] [filename]\n\n"
+                                     "  Extract field data from ABC file.")
+parser.add_option("-f", "--field", dest="field", default="T",
+                  help="extract the field FIELD", metavar="FIELD")
+parser.add_option("-m", "--html", dest="html",
+                  action="store_true", default=False,
+                  help="format output for HTML")
+parser.add_option("-l", "--latex", dest="latex",
+                  action="store_true", default=False,
+                  help="format ouput for LaTeX")
+(options, args) = parser.parse_args()
+
+if options.html and options.latex:
+    sys.exit("You must choose one of HTML or LaTeX output")
+
+if len(args) > 0:
+    for arg in args:
+        try:
+            inf = open(arg, "r")
+            process(inf, options)
+        finally:
+            inf.close()
+else:
+    process(sys.stdin, options)
+sys.exit(0)
--- a/abctitle.py	Fri Apr 13 16:21:14 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-#!/usr/bin/env python
-#
-# Extact the first tune title from a .abc data, and print it out
-# formatted for use in LaTeX.
-#
-
-import optparse
-import sys
-
-accentedletters = {
-    # Acute accents
-    "'A" : ("&Aacute;", "\\'{A}"),
-    "'E" : ("&Eacute;", "\\'{E}"),
-    "'I" : ("&Iacute;", "\\'{I}"),
-    "'O" : ("&Oacute;", "\\'{O}"),
-    "'U" : ("&Uacute;", "\\'{U}"),
-    "'Y" : ("&Yacute;", "\\'{Y}"),
-    "'a" : ("&aacute;", "\\'{a}"),
-    "'e" : ("&eacute;", "\\'{e}"),
-    "'i" : ("&iacute;", "\\'{i}"),
-    "'o" : ("&oacute;", "\\'{o}"),
-    "'u" : ("&uacute;", "\\'{u}"),
-    "'y" : ("&yacute;", "\\'{y}"),
-
-    # Grave accents
-    "`A" : ("&Agrave;", "\\`{A}"),
-    "`E" : ("&Egrave;", "\\`{E}"),
-    "`I" : ("&Igrave;", "\\`{I}"),
-    "`O" : ("&Ograve;", "\\`{O}"),
-    "`U" : ("&Ugrave;", "\\`{U}"),
-    "`a" : ("&agrave;", "\\`{a}"),
-    "`e" : ("&egrave;", "\\`{e}"),
-    "`i" : ("&igrave;", "\\`{i}"),
-    "`o" : ("&ograve;", "\\`{o}"),
-    "`u" : ("&ugrave;", "\\`{u}"),
-
-    # Umlauts
-    "\"A" : ("&Auml;", "\\\"{A}"),
-    "\"E" : ("&Euml;", "\\\"{E}"),
-    "\"I" : ("&Iuml;", "\\\"{I}"),
-    "\"O" : ("&Ouml;", "\\\"{O}"),
-    "\"U" : ("&Uuml;", "\\\"{U}"),
-    "\"Y" : ("&Yuml;", "\\\"{Y}"),
-    "\"a" : ("&auml;", "\\\"{a}"),
-    "\"e" : ("&euml;", "\\\"{e}"),
-    "\"i" : ("&iuml;", "\\\"{\i}"),
-    "\"o" : ("&ouml;", "\\\"{o}"),
-    "\"u" : ("&uuml;", "\\\"{u}"),
-    "\"y" : ("&yuml;", "\\\"{y}"),
-
-    # Circumflexes
-    "^A" : ("&Acirc;", "\\^{A}"),
-    "^E" : ("&Ecirc;", "\\^{E}"),
-    "^I" : ("&Icirc;", "\\^{I}"),
-    "^O" : ("&Ocirc;", "\\^{O}"),
-    "^U" : ("&Ucirc;", "\\^{U}"),
-    "^a" : ("&acirc;", "\\^{a}"),
-    "^e" : ("&ecirc;", "\\^{e}"),
-    "^i" : ("&icirc;", "\\^{\i}"),
-    "^o" : ("&ocirc;", "\\^{o}"),
-    "^u" : ("&ucirc;", "\\^{u}"),
-
-    # Tilde
-    "~A" : ("&Atilde;", "\\~{A}"),
-    "~N" : ("&Ntilde;", "\\~{N}"),
-    "~O" : ("&Otilde;", "\\~{O}"),
-    "~a" : ("&atilde;", "\\~{a}"),
-    "~n" : ("&ntilde;", "\\~{n}"),
-    "~o" : ("&otilde;", "\\~{o}"),
-
-    # Cedilla
-    ",C" : ("&Ccedil;", "\\c{C}"),
-    ",c" : ("&ccedil;", "\\c{c}"),
-
-    # Slash
-    "/O" : ("&Oslash;", "\\O"),
-    "/o" : ("&oslash;", "\\o"),
-
-    # Ring
-    "AA" : ("&Aring;", "\\r{A}"),
-    "aa" : ("&aring;", "\\r{a}"),
-
-    # Ligatures
-    "AE" : ("&AElig;", "\\AE"),
-    "ae" : ("&aelig;", "\\ae"),
-    "ss" : ("&szlig;", "\\ss"),
-}
-
-def convertTitle(t, options):
-    res = ""
-    while True:
-        p = t.partition('\\')
-        res += p[0]
-        if p[1] == "":
-            break
-        abc = p[2][0:2]
-        t = p[2][2:]
-        if (options.html or options.latex) and abc in accentedletters:
-            if options.html:
-                res += accentedletters[abc][0]
-            else:
-                res += accentedletters[abc][1]
-        else:
-            res += "\\" + abc
-    return res
-
-def process(inf, options):
-    for line in inf:
-        line = line.strip()
-        if line[0:2] == "T:":
-            print(convertTitle(line[2:].strip(), options))
-            break
-
-parser = optparse.OptionParser(usage="usage: %prog [options] [filename]\n\n"
-                                     "  Extract title from ABC file.")
-parser.add_option("-m", "--html", dest="html",
-                  action="store_true", default=False,
-                  help="format output for HTML")
-parser.add_option("-l", "--latex", dest="latex",
-                  action="store_true", default=False,
-                  help="format ouput for LaTeX")
-(options, args) = parser.parse_args()
-
-if options.html and options.latex:
-    sys.exit("You must choose one of HTML or LaTeX output")
-
-if len(args) > 0:
-    for arg in args:
-        try:
-            inf = open(arg, "r")
-            process(inf, options)
-        finally:
-            inf.close()
-else:
-    process(sys.stdin, options)
-sys.exit(0)
--- a/dottes.tex.header	Fri Apr 13 16:21:14 2012 +0100
+++ b/dottes.tex.header	Sat Apr 21 19:47:30 2012 +0100
@@ -27,13 +27,17 @@
 
 \setlength{\parindent}{0pt}
 
-% Adjust margins for A5 landscape. Increase width by 2cm and height by 4cm.
-\addtolength{\textwidth}{2cm}
-\addtolength{\hoffset}{-1cm}
+% Adjust margins for A5 landscape. Increase width by 4cm and height by 4cm.
+\addtolength{\textwidth}{4cm}
+\addtolength{\hoffset}{-2cm}
 
 \addtolength{\textheight}{4cm}
 \addtolength{\voffset}{-2cm}
 
+% Move the top margin up a further cm.
+\addtolength{\textheight}{1cm}
+\addtolength{\voffset}{-1cm}
+
 % -----
 
 \begin{document}
--- a/makeBooke.sh	Fri Apr 13 16:21:14 2012 +0100
+++ b/makeBooke.sh	Sat Apr 21 19:47:30 2012 +0100
@@ -43,8 +43,9 @@
 find $booke -name "*.abc" | sort |
     while read filename
     do
-        title=`$dir/abctitle.py --latex $filename`
+        title=`$dir/abcfield.py --field T --latex $filename`
         name=`basename $filename .abc`
+        echo -E "\newpage" >> $builddir/$output
         echo -E "\begin{center}" >> $builddir/$output
         echo -E "\phantomsection" >> $builddir/$output
         echo -E "\hypertarget{$name}{\includegraphics[width=\textwidth,height=0.9\textheight,keepaspectratio]{$graphicsdir/$name}}" >> $builddir/$output
@@ -57,7 +58,7 @@
 find $booke -name "*.abc" | sort |
     while read filename
     do
-        title=`$dir/abctitle.py --latex $filename`
+        title=`$dir/abcfield.py --field T --latex $filename`
         name=`basename $filename .abc`
         echo -E "\hyperlink{$name}{$title} & \raisebox{-.25\height}{\includegraphics[width=0.6\textwidth]{$graphicsdir/firstline-$name}} \\\\" >> $builddir/$output
     done
--- a/makeGraphics.sh	Fri Apr 13 16:21:14 2012 +0100
+++ b/makeGraphics.sh	Sat Apr 21 19:47:30 2012 +0100
@@ -23,7 +23,7 @@
         name=`basename $filename .abc`
 
         # Make the tune graphic.
-        abcm2ps -j0 +c -n -E -O $graphicsdir/$name.eps $filename
+        abcm2ps -E -F singletune -O $graphicsdir/$name.eps $filename
         # Make $name.eps so we can build with LaTeX.
         mv $graphicsdir/${name}001.eps $graphicsdir/${name}.eps
         # And make the corresponding PDF.
--- a/makeWeb.sh	Fri Apr 13 16:21:14 2012 +0100
+++ b/makeWeb.sh	Sat Apr 21 19:47:30 2012 +0100
@@ -37,7 +37,7 @@
 find $booke -name "*.abc" | sort |
     while read filename
     do
-        title=`$dir/abctitle.py --html $filename`
+        title=`$dir/abcfield.py --field T --html $filename`
         name=`basename $filename .abc`
 
         # Copy tune PDF from common graphics.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/singletune.fmt	Sat Apr 21 19:47:30 2012 +0100
@@ -0,0 +1,20 @@
+% Format for a graphic with a single tune
+mmmeasurenb 0
+botmargin 0
+leftmargin 0
+rightmarin 0
+topmargin 0
+scale 0.9
+titleformat T0 C1
+titlespace 0
+topspace 0
+% I only want to include Notes in the tune graphics. To turn off the
+% other fields, give a blank infoname for that letter.
+infoname S
+infoname R
+infoname B
+infoname D
+infoname Z
+infoname H
+infoline true
+writehistory true