From: janneke <janneke>
Date: Sun, 11 Apr 2004 10:34:45 +0000 (+0000)
Subject: * scm/output-ps.scm (header): Papersize from paper.
X-Git-Tag: release/2.3.9^2~342
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=da8d9f30e99a25ddf17132cb709ce4f147d83fee;p=lilypond.git

* scm/output-ps.scm (header): Papersize from paper.

* scripts/lilypond.py (global_latex_preamble): Oldish behaviour
for classic output.

* tex/lilyponddefs.tex (interscoreline): Oldish behaviour if
lilypondclassic is defined.
(lilypondstart): Oldish behaviour if lilypondclassic is defined.

* input/regression/between-systems.ly: Remove.

* python/lilylib.py (get_bbox): Fix regular expression
for bounding box.

* tex/lilyponddefs.tex (lilypondpagebreak): New overridable macro.

* scm/output-tex.scm (stop-page): Use it.

* scm/output-ps.scm (define-fonts): Bugfix.
---

diff --git a/ChangeLog b/ChangeLog
index dcdddb978e..0e055fec6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2004-04-11  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+	* scm/output-ps.scm (header): Papersize from paper.
+
+	* scripts/lilypond.py (global_latex_preamble): Oldish behaviour
+	for classic output.
+
+	* tex/lilyponddefs.tex (interscoreline): Oldish behaviour if
+	lilypondclassic is defined.
+	(lilypondstart): Oldish behaviour if lilypondclassic is defined.
+
+	* input/regression/between-systems.ly: Remove.
+
+	* python/lilylib.py (get_bbox): Fix regular expression
+	for bounding box.
+
 	* tex/lilyponddefs.tex (lilypondpagebreak): New overridable macro.
 
 	* scm/output-tex.scm (stop-page): Use it.
diff --git a/input/regression/between-systems.ly b/input/regression/between-systems.ly
deleted file mode 100644
index b091328fff..0000000000
--- a/input/regression/between-systems.ly
+++ /dev/null
@@ -1,32 +0,0 @@
-
-\version "2.2.0"
-
-\header{
-texidoc="
-By inserting @TeX{} commands between systems, you can force pagebreaks.
-
-In reality, you'd use the LateX command @code{\\newpage} instead of (pagebreak)
-of course. 
-"
-}
-
-
-#(define (set-page-break grob grob-c context)
-  (let*
-   ((meta (ly:grob-property grob 'meta))
-    (name (cdr (assoc 'name meta))))
-   
-   (if (equal? 'NonMusicalPaperColumn name)
-    (ly:grob-set-property! grob 'between-system-string "(pagebreak)\n\n"))
-))
-
-\score {
-    \notes \relative c' {
-	c1
-	\context Score \applyoutput #set-page-break
-	\break
-	
-	c1
-    }
-}
-
diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh
index b90408ba47..824618db5e 100644
--- a/lily/include/paper-outputter.hh
+++ b/lily/include/paper-outputter.hh
@@ -41,7 +41,7 @@ public:
   void output_music_output_def (Music_output_def* odef);
   void output_scheme (SCM scm);
   void output_expr (SCM expr, Offset o);
-  void output_header (Paper_def*, SCM, int);
+  void output_header (Paper_def*, SCM, int, bool);
   void output_line (SCM, Offset*, bool);
 };
 
diff --git a/lily/paper-book.cc b/lily/paper-book.cc
index 7cfd6e10f6..fb4b9a76fc 100644
--- a/lily/paper-book.cc
+++ b/lily/paper-book.cc
@@ -251,7 +251,7 @@ Paper_book::output (String outname)
 
   Paper_def *paper = papers_[0];
   Paper_outputter *out = paper->get_paper_outputter (outname);
-  out->output_header (paper, scopes (0), pages->size ());
+  out->output_header (paper, scopes (0), pages->size (), false);
 
   int page_count = pages->size ();
   for (int i = 0; i < page_count; i++)
@@ -309,7 +309,7 @@ Paper_book::classic_output (String outname)
 {
   int count = scores_.size ();
   Paper_outputter *out = papers_.top ()->get_paper_outputter (outname);
-  out->output_header (papers_.top (), scopes (count - 1), 0);
+  out->output_header (papers_.top (), scopes (count - 1), 0, true);
 
   Paper_line *first = unsmob_paper_line (scm_vector_ref (scores_.top (),
 							 scm_int2num (0)));
@@ -404,10 +404,10 @@ Paper_book::pages ()
   SCM all = lines ();
   SCM proc = paper->get_scmvar ("page-breaking");
   SCM breaks = scm_apply_0 (proc, scm_list_n (all, scm_make_real (height_),
-					    scm_make_real (text_height),
-					    scm_make_real (-copy_height),
-					    scm_make_real (-tag_height),
-					    SCM_UNDEFINED));
+					      scm_make_real (text_height),
+					      scm_make_real (-copy_height),
+					      scm_make_real (-tag_height),
+					      SCM_UNDEFINED));
 
   /* Copyright on first page.  */
   if (unsmob_stencil (copyright_))
diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc
index 56d4e9b378..009eb381e1 100644
--- a/lily/paper-outputter.cc
+++ b/lily/paper-outputter.cc
@@ -126,7 +126,8 @@ Paper_outputter::output_metadata (Paper_def *paper, SCM scopes)
 }
 
 void
-Paper_outputter::output_header (Paper_def *paper, SCM scopes, int page_count)
+Paper_outputter::output_header (Paper_def *paper, SCM scopes, int page_count,
+				bool is_classic)
 {
   String creator = gnu_lilypond_version_string ();
   creator += " (http://lilypond.org)";
@@ -134,10 +135,13 @@ Paper_outputter::output_header (Paper_def *paper, SCM scopes, int page_count)
   String time_stamp = ctime (&t);
   time_stamp = time_stamp.left_string (time_stamp.length () - 1)
     + " " + *tzname;
-  output_scheme (scm_list_4 (ly_symbol2scm ("header"),
+  output_scheme (scm_list_n (ly_symbol2scm ("header"),
 			     scm_makfrom0str (creator.to_str0 ()),
 			     scm_makfrom0str (time_stamp.to_str0 ()),
-			     scm_int2num (page_count)));
+			     paper->self_scm (),
+			     scm_int2num (page_count),
+			     ly_bool2scm (is_classic),
+			     SCM_UNDEFINED));
 
   output_metadata (paper, scopes);
   output_music_output_def (paper);
diff --git a/po/nl.po b/po/nl.po
index 20d3af2319..30f42c63b1 100644
--- a/po/nl.po
+++ b/po/nl.po
@@ -12,7 +12,7 @@ msgstr ""
 "Project-Id-Version: lilypond 2.2.0\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2004-03-31 16:22+0200\n"
-"PO-Revision-Date: 2004-04-10 23:36+0200\n"
+"PO-Revision-Date: 2004-04-11 11:01+0200\n"
 "Last-Translator: Jan Nieuwenhuizen <janneke@gnu.org>\n"
 "Language-Team: Dutch <vertaling@nl.linux.org>\n"
 "MIME-Version: 1.0\n"
@@ -1584,7 +1584,7 @@ msgstr "niemand om een x-ool start haak af te drukken"
 #: time-signature.cc:95
 #, c-format
 msgid "time signature symbol `%s' not found; reverting to numbered style"
-msgstr "maatsoortsymbool `%s' niet gevondend; val terug op numerieke stijl"
+msgstr "maatsoortsymbool `%s' niet gevonden; val terug op numerieke stijl"
 
 #.
 #. Todo: should make typecheck?
diff --git a/python/lilylib.py b/python/lilylib.py
index b3dde26a20..4df1532a19 100644
--- a/python/lilylib.py
+++ b/python/lilylib.py
@@ -433,6 +433,7 @@ def print_environment ():
 	for (k,v) in os.environ.items ():
 		sys.stderr.write ("%s=\"%s\"\n" % (k, v)) 
 
+BOUNDING_BOX_RE = '^%%BoundingBox: (-?[0-9]+) (-?[0-9]+) (-?[0-9]+) (-?[0-9]+)'
 def get_bbox (filename):
 	bbox = filename + '.bbox'
 	## -sOutputFile does not work with bbox?
@@ -440,8 +441,7 @@ def get_bbox (filename):
 	      (filename, bbox)
 	system (cmd, progress_p = 1)
 	box = open (bbox).read ()
-	m = re.match ('^%%BoundingBox: ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)',
-		      box)
+	m = re.match (BOUNDING_BOX_RE, box)
 	gr = []
 	if m:
 		gr = map (string.atoi, m.groups ())
diff --git a/scm/output-ps.scm b/scm/output-ps.scm
index 7a1d8e03af..3635daf6b0 100644
--- a/scm/output-ps.scm
+++ b/scm/output-ps.scm
@@ -267,7 +267,7 @@
   (string-append (ly:numbers->string (list breapth width depth height))
 		 " draw_box"))
 
-(define (header creator time-stamp page-count-)
+(define (header creator time-stamp paper page-count- classic?)
   (set! page-count page-count-)
   (set! page-number 0)
   (string-append
@@ -275,8 +275,7 @@
    "%%Creator: " creator " " time-stamp "\n"
    "%%Pages: " (number->string page-count) "\n"
    "%%PageOrder: Ascend\n"
-   ;; FIXME: TODO get from paper
-   ;; "%%DocumentPaperSizes: a6\n"
+   "%%DocumentPaperSizes: " (ly:paper-lookup paper 'papersize) "\n"
    ;;(string-append "GNU LilyPond (" (lilypond-version) "), ")
    ;;	   (strftime "%c" (localtime (current-time))))
    ;; FIXME: duplicated in every backend
diff --git a/scm/output-tex.scm b/scm/output-tex.scm
index a74d8e883b..0bfed37745 100644
--- a/scm/output-tex.scm
+++ b/scm/output-tex.scm
@@ -245,10 +245,13 @@
    "\\lilypondspecial\n"
    "\\lilypondpostscript\n"))
 
-(define (header creator time-stamp page-count)
+(define (header creator time-stamp paper page-count classic?)
   (string-append
    "% Generated by " creator "\n"
    "% at " time-stamp "\n"
+   (if classic?
+       (tex-string-def "lilypond" 'classic "1")
+       "")
    ;; FIXME: duplicated in every backend
    "\\def\\lilypondtagline{Engraved by LilyPond (version "
    (lilypond-version)")}\n"))
diff --git a/scripts/lilypond.py b/scripts/lilypond.py
index 7511467cd8..dae512954f 100644
--- a/scripts/lilypond.py
+++ b/scripts/lilypond.py
@@ -84,6 +84,8 @@ global re;re = ly.re
 # lilylib globals
 program_name = 'lilypond'
 program_version = '@TOPLEVEL_VERSION@'
+# input without \book, use classic latex definitions
+classic_p = 0
 verbose_p = 0
 pseudo_filter_p = 0
 original_dir = os.getcwd ()
@@ -161,6 +163,7 @@ extra_init = {
 	'latexheaders' : [],
 	'latexoptions' : [],
 	'latexpackages' :  [],
+	'linewidth' : [],
 	'orientation' : [],
 	'papersize' : [],
 	'unit' : ['pt'],
@@ -274,9 +277,14 @@ def analyse_lilypond_output (filename, extra):
 	# search only the first 10k
 	s = s[:10240]
 	for x in header_fields:
-		m = re.search (r'\\def\\lilypondpaper%s{([^}]*)}'%x, s)
+		m = re.search (r'\\def\\lilypondpaper%s{([^}]*)}' % x, s)
 		if m:
 			set_setting (extra, x, m.group (1))
+
+	global classic_p
+	if s.find ('\\def\\lilypondclassic{1}') >= 0:
+		classic_p = 1
+	
 	ly.progress ('\n')
 
 def find_tex_files_for_base (base, extra):
@@ -330,10 +338,38 @@ def one_latex_definition (defn, first):
 			s += r'''\let\lilypond%s\relax''' % k
 		s += '\n'
 
+	if classic_p and not first:
+		s += '\interscoreline'
+
 	s += '%%PREVIEW%%\n'
 	s += '\\input %s\n' % defn[0]
 	return s
 
+		
+## FIXME: copied from tex/lilyponddefs.tex
+LATEX_PREAMBLE = '''
+%% Nullify [La]TeX page layout settings, page layout by LilyPond.
+\\topmargin-1in
+\\headheight0pt\\headsep0pt
+\\oddsidemargin-1in
+\\evensidemargin\oddsidemargin
+\\parindent 0pt'''
+
+CLASSIC_LATEX_PREAMBLE = '''
+%% FIXME: cannot do this, dimens in header part of lilypond output
+%% Center staves horizontally on page
+\\ifdim\\lypylinewidth\\lypyunit > 0pt
+\\hsize\\lypylinewidth\\lypyunit
+\\newdimen\\lypytempdim
+\\lypytempdim\\paperwidth
+\\advance\\lypytempdim-\\the\\hsize
+\\lypytempdim0.5\\lypytempdim
+\\advance\\lypytempdim -1in
+\\oddsidemargin\\lypytempdim
+\\evensidemargin\\lypytempdim
+\\fi
+\\parindent 0pt'''
+
 def global_latex_preamble (extra):
 	'''construct preamble from EXTRA,'''
 	
@@ -350,9 +386,16 @@ def global_latex_preamble (extra):
 	if safe_mode_p:
 		s += '\\nofiles\n'
 
+	if classic_p:
+		if extra['linewidth']:
+			s += '\\def\\lypylinewidth{%s}\n' \
+			     % extra['linewidth'][-1]
+		else:
+			s += '\\let\\lypylinewidth\\texwidth\n'
+		s += '\\def\\lypyunit{%s}\n' % extra['unit'][-1]
+
 	if extra['language']:
-		s += r'\usepackage[%s]{babel}' \
-		    % extra['language'][-1] + '\n'
+		s += '\\usepackage[%s]{babel}' % extra['language'][-1] + '\n'
 
 	s += '\\usepackage{%s}\n' \
 		% string.join (extra['latexpackages'], ',')
@@ -367,15 +410,12 @@ def global_latex_preamble (extra):
 	s += r'''
 \usepackage[latin1]{inputenc}
 \pagestyle{empty}
-%%PREVIEW%%
-%% Nullify [La]TeX page layout settings, page layout by LilyPond.
-\pagestyle{empty}
-\topmargin-1in
-\headheight0pt\headsep0pt
-\oddsidemargin-1in
-\evensidemargin\oddsidemargin
-\parindent 0pt
-'''
+%%PREVIEW%%'''
+	
+	if classic_p:
+		s += CLASSIC_LATEX_PREAMBLE
+	else:
+		s += LATEX_PREAMBLE
 	return s
 
 	
diff --git a/tex/lilyponddefs.tex b/tex/lilyponddefs.tex
index a26ea6877c..5869d13626 100644
--- a/tex/lilyponddefs.tex
+++ b/tex/lilyponddefs.tex
@@ -25,6 +25,7 @@
 %%   <font setup and note output>
 %%   \lilypondend
 
+\newdimen\lytempdim
 \newdimen\outputscale
 
 %% Handy macros from the LaTeX manual.
@@ -55,12 +56,27 @@
         \documentclass[a4paper]{article}
         %% safe-mode
         \nofiles
-        %% Nullify [La]TeX page layout settings, page layout by LilyPond.
         \pagestyle{empty}
-        \topmargin-1in
-        \headheight0pt\headsep0pt
-        \oddsidemargin-1in
-        \evensidemargin\oddsidemargin
+        \lilypondifundefined{lilypondclassic}
+        {
+          %% Nullify [La]TeX page layout settings, page layout by LilyPond.
+          \topmargin-1in
+          \headheight0pt\headsep0pt
+          \oddsidemargin-1in
+          \evensidemargin\oddsidemargin
+        }
+        {
+          %% Center staves horizontally on page
+          \ifdim\lilypondpaperlinewidth\lilypondpaperunit > 0pt
+          \hsize\lilypondpaperlinewidth\lilypondpaperunit
+          \lytempdim \paperwidth
+          \advance\lytempdim -\the\hsize
+          \lytempdim 0.5\lytempdim
+          \advance\lytempdim -1in
+          \oddsidemargin \lytempdim
+          \evensidemargin \lytempdim
+          \fi
+        }
         \parindent 0pt
         %% TEXINFO workaround: \begin is defined as \outer, use \csname.
         \csname begin\endcsname{document}}}
@@ -122,7 +138,6 @@
 \gdef\lyitem#1#2#3{
   \topalign{\raise#2\outputscale\leftalign{\kern#1\outputscale#3}}}
 
-\newdimen\lytempdim
 \gdef\lybox#1#2#3#4#5{
   \lytempdim\baselineskip
   \advance\lytempdim-#4\outputscale
@@ -142,7 +157,14 @@
 
 %% Allow overriding of interscoreline, e.g. for lilypond.py's --preview
 \lilypondifundefined{interscoreline}
-{\gdef\interscoreline{}}{}
+{
+  \lilypondifundefined{lilypondclassic}
+  {\gdef\interscoreline{}}
+  {\gdef\interscoreline{
+      \vskip\lilypondpaperinterscoreline\lilypondpaperunit
+      plus \lilypondpaperinterscorelinefill fill}}
+}
+{}
 
 %% Include postscript definitions unless using PDFTeX,
 %% in that case use pdf definitions.