empty 2nd page for mono page.
* scm/lily.scm: remove p&c definitions.
2005-04-27 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * python/lilylib.py (make_ps_images): bugfixes; GS can produce
+ empty 2nd page for mono page.
+
+ * scm/lily.scm: remove p&c definitions.
+
* po/zh_TW.po (Module): new translation.
* lily/lily-guile.cc (ly_chain_assoc): remove.
/* Scheme code to execute before parsing, after .scm init.
This is where -e arguments are appended to. */
-String init_scheme_code_string = "(begin #t ";
+String init_scheme_code_string;
+String init_scheme_variables;
/* Generate preview of first system. */
bool make_preview = false;
all_fonts_global = new All_font_metrics (global_path.to_string ());
- init_scheme_code_string += ")";
- scm_c_eval_string ((char *) init_scheme_code_string.to_str0 ());
+
+ if (!init_scheme_variables.is_empty ()
+ || !init_scheme_code_string.is_empty ())
+ {
+ init_scheme_variables = "(ly:set-option 'command-line-settings (list "
+ + init_scheme_variables + "))";
+
+ init_scheme_code_string
+ += "(begin #t "
+ + init_scheme_variables
+ + init_scheme_code_string
+ + ")";
+
+ char const *str0 = init_scheme_code_string.to_str0 ();
+
+ if (be_verbose_global)
+ {
+ progress_indication (_f("Evaluating %s", str0));
+ }
+ scm_c_eval_string ((char *) str0);
+ }
+
/* We accept multiple independent music files on the command line to
reduce compile time when processing lots of small files.
Starting the GUILE engine is very time consuming. */
break;
case 'd':
-
+ {
+ String arg (option_parser->optional_argument_str0_);
+ int eq = arg.index ('=');
+
+ String key = arg;
+ String val = "#t";
+
+ if (eq >= 0)
+ {
+ key = arg.left_string (eq);
+ val = arg.right_string (arg.length () - eq - 1);
+ }
+
+ init_scheme_variables
+ += "(cons \'" + key + " " + val + ")\n";
+ }
break;
case 'v':
(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "scm-option.hh"
-
#include <cstdio>
+#include "scm-option.hh"
+#include "protected-scm.hh"
#include "parse-scm.hh"
#include "warn.hh"
#include "main.hh"
/* Write midi as formatted ascii stream? */
bool midi_debug_global_b;
-int preview_resolution_global = 90;
-
/* General purpose testing flag */
int testing_level_global;
*/
bool do_internal_type_checking_global;
+Protected_scm command_line_settings = SCM_EOL;
+
/*
What is this function for ?
*/
"Relative for simultaneous music functions similar to chord syntax\n"
"@item new-relative\n"
"Relative for simultaneous music functions similar to sequential music\n"
+ "@item command-line-settings\n"
+ "An alist of generic key/value pairs\n"
"@end table\n"
"\n"
"This function is useful to call from the command line: @code{lilypond -e\n"
/* Needs to be reset for each file that uses this option. */
lily_1_8_compatibility_used = false;
}
- else if (var == ly_symbol2scm ("resolution"))
- preview_resolution_global = robust_scm2int (val, 90);
else if (var == ly_symbol2scm ("new-relative"))
lily_1_8_relative = false;
+ else if (var == ly_symbol2scm ("command-line-settings"))
+ {
+ SCM_ASSERT_TYPE(scm_list_p (val) == SCM_BOOL_T,
+ val, SCM_ARG2, __FUNCTION__, "alist");
+ command_line_settings = scm_append (scm_list_2 (val, command_line_settings));
+ }
else
{
if (scm_is_symbol (var))
"Report whether old-relative compatibility mode is used\n"
"@item verbose\n"
"Report whether we are running in verbose mode\n"
- "@item resolution\n"
- "Resolution for the PNG output."
+ "@item command-line-settings\n"
+
"@end table\n"
"\n")
{
o = ly_bool2scm (lily_1_8_relative);
else if (var == ly_symbol2scm ("verbose"))
o = ly_bool2scm (be_verbose_global);
- else if (var == ly_symbol2scm ("resolution"))
- o = scm_from_int (preview_resolution_global);
+ else if (var == ly_symbol2scm ("command-line-settings"))
+ {
+ o = command_line_settings;
+ }
else
{
if (scm_is_symbol (var))
# png16m is because Lily produces color nowadays.
if not multi_page:
+
+ # GS can produce empty 2nd page if pngn is used.
+ output_file = png1
cmd = r'''gs\
-dEPSCrop\
-dGraphicsAlphaBits=4\
error (_ ("%s exited with status: %d") % ('GS', status))
exit (1)
- if rename_page1_p or not multi_page:
+ if rename_page1_p and multi_page:
os.rename (pngn % 1, png1)
- files = glob.glob (png1) + glob.glob (re.sub ('%d', '*', output_file))
+ files = glob.glob (png1) + glob.glob (re.sub ('%d', '*', pngn))
return files
(display "} stop-system\n%%Trailer\n%%EOF\n" port)
(ly:outputter-close outputter)))
+
(define-public (output-preview-framework basename book scopes fields)
+
(let* ((paper (ly:paper-book-paper book))
(systems (ly:paper-book-systems book))
(scale (ly:output-def-lookup paper 'outputscale))
- (titles (take-while ly:paper-system-title? systems))
- (non-title (find (lambda (x)
- (not (ly:paper-system-title? x))) systems))
- (dump-me
- (stack-stencils Y DOWN 0.0
- (map ly:paper-system-stencil
- (append titles (list non-title))))))
- (output-scopes scopes fields basename)
- (dump-stencil-as-EPS paper dump-me
- (format "~a.preview" basename)
- #t)))
+ (to-dump-systems '())
+ )
+
+
+ ;; skip booktitles.
+ (if (and
+ (not
+ (cdr (assoc
+ 'preview-include-book-title
+ (ly:get-option 'command-line-settings)
+ )))
+ (< 1 (length systems))
+ (ly:paper-system-title? (list-ref systems 0))
+ (ly:paper-system-title? (list-ref systems 1)))
+ (set! systems (cdr systems)))
+
+ (for-each
+ (lambda (sys)
+ (if (or
+ (ly:paper-system-title? sys)
+ (and (pair? to-dump-systems)
+ (ly:paper-system-title? (car to-dump-systems))))
+ (set! to-dump-systems (cons sys to-dump-systems))))
+ systems)
+
+ (dump-stencil-as-EPS
+ paper
+ (stack-stencils Y DOWN 0.0
+ (map ly:paper-system-stencil (reverse to-dump-systems)))
+ (format "~a.preview" basename)
+ #t)
+
+ (postprocess-output book framework-ps-module
+ (format "~a.preview.eps" basename)
+ (completize-formats (cons "png" (ly:output-formats))))
+
+ ))
+(if #f
+ (define-public (output-preview-framework basename book scopes fields)
+
+ (let* ((paper (ly:paper-book-paper book))
+ (systems (ly:paper-book-systems book))
+ (scale (ly:output-def-lookup paper 'outputscale))
+ (titles (take-while ly:paper-system-title? systems))
+ (non-title (find (lambda (x)
+ (not (ly:paper-system-title? x))) systems))
+ (dump-me
+ (stack-stencils Y DOWN 0.0
+ (map ly:paper-system-stencil
+ (append titles (list non-title))))))
+ (output-scopes scopes fields basename)
+ (dump-stencil-as-EPS paper dump-me
+ (format "~a.preview" basename)
+ #t)
+
+ (postprocess-output book framework-ps-module
+ (format "~a.preview.eps" basename)
+ (completize-formats (ly:output-formats)))
+
+ ))
+ )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-public (convert-to-pdf book name)
(define-public (convert-to-png book name)
(let* ((defs (ly:paper-book-paper book))
- (resolution (ly:output-def-lookup defs 'pngresolution))
+ (defs-resolution (ly:output-def-lookup defs 'pngresolution))
+ (resolution (if (number? defs-resolution)
+ defs-resolution
+ (cdr (assoc 'resolution
+ (ly:get-option 'command-line-settings)))))
(papersizename (ly:output-def-lookup defs 'papersizename)))
- (postscript->png (if (number? resolution) resolution
- (ly:get-option 'resolution))
- (if (string? papersizename) papersizename "a4")
+ (postscript->png resolution
+ (if (string? papersizename)
+ papersizename "a4")
+
name)))
(define-public (convert-to-dvi book name)
(resolution (ly:output-def-lookup defs 'pngresolution))
(papersizename (ly:output-def-lookup defs 'papersizename)))
(postscript->png
- (if (number? resolution) resolution (ly:get-option 'resolution))
- (if (string? papersizename) papersizename "a4")
+ (if (number? resolution)
+ resolution
+ (assoc
+ 'resolution
+ (ly:get-option 'command-line-settings)))
+
+ (if (string? papersizename)
+ papersizename
+ "a4")
+
(string-append (basename name ".tex") ".ps"))))
(define-public (convert-to-ps book name)
(debug-enable 'backtrace)
(read-enable 'positions)))
-(define-public (line-column-location file line col)
- "Print an input location, including column number ."
- (string-append (number->string line) ":"
- (number->string col) " " file))
-(define-public (line-location file line col)
- "Print an input location, without column number ."
- (string-append (number->string line) " " file))
-(define-public point-and-click #f)
+;; initialize defaults.
+(ly:set-option 'command-line-settings
+ '((resolution . 90)
+ (preview-include-book-title . #t)
+ ))
(define-public tex-backend?
(member (ly:output-backend) '("texstr" "tex")))
;; no-origin not yet supported by Xdvi
(define (no-origin) "")
+
+
+
+(define-public (line-location file line col)
+ "Print an input location, without column number ."
+ (string-append (number->string line) " " file))
+
+(define-public point-and-click #f)
+
(define (grob-cause offset grob)
+ (define (line-column-location file line col)
+ "Print an input location, including column number ."
+ (string-append (number->string line) ":"
+ (number->string col) " " file))
+
(if (procedure? point-and-click)
(let* ((cause (ly:grob-property grob 'cause))
(music-origin (if (ly:music? cause)
(if (pair? location)
;;; \\string ?
(string-append "\\special{src:"
- (apply point-and-click location) "}")
+ (line-column-location location) "}")
""))
""))