]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-book: Group line-width settings together (issue 2222).
authorJulien Rioux <jrioux@physics.utoronto.ca>
Wed, 18 Jan 2012 02:08:07 +0000 (21:08 -0500)
committerJulien Rioux <jrioux@physics.utoronto.ca>
Mon, 23 Jan 2012 19:42:55 +0000 (14:42 -0500)
The line-width is adjusted to add some padding. However we can only
do so if the line-width was defined. So the code for adjusting the
line-width is tied to the definition of line-width.

python/book_snippets.py

index 7e5e94686352fd413148dc7f01eabf7ca64c3f50..127453d6afa6f79c9c84db7e6792926f9001a8f0 100644 (file)
@@ -109,11 +109,19 @@ snippet_options = {
     },
 
     ##
+    # TODO: Remove the 1mm additional padding in the line-width
+    #       once lilypond creates tighter cropped images!
     PAPER: {
         PAPERSIZE: r'''#(set-paper-size "%(papersize)s")''',
         INDENT: r'''indent = %(indent)s''',
-        LINE_WIDTH: r'''line-width = %(line-width)s''',
-        QUOTE: r'''line-width = %(line-width)s - 2.0 * %(exampleindent)s''',
+        LINE_WIDTH: r'''line-width = %(line-width)s
+  %% offset the left padding, also add 1mm as lilypond creates cropped
+  %% images with a little space on the right
+  line-width = #(- line-width (* mm  %(padding_mm)f) (* mm 1))''',
+        QUOTE: r'''line-width = %(line-width)s - 2.0 * %(exampleindent)s
+  %% offset the left padding, also add 1mm as lilypond creates cropped
+  %% images with a little space on the right
+  line-width = #(- line-width (* mm  %(padding_mm)f) (* mm 1))''',
         RAGGED_RIGHT: r'''ragged-right = ##t''',
         NORAGGED_RIGHT: r'''ragged-right = ##f''',
     },
@@ -164,8 +172,6 @@ def classic_lilypond_book_compatibility (key, value):
     return (None, None)
 
 
-# TODO: Remove the 1mm additional padding in the line-width, once lilypond
-#       creates tighter cropped images!
 PREAMBLE_LY = '''%%%% Generated by %(program_name)s
 %%%% Options: [%(option_string)s]
 \\include "lilypond-book-preamble.ly"
@@ -179,9 +185,6 @@ PREAMBLE_LY = '''%%%% Generated by %(program_name)s
 
 \paper {
   %(paper_string)s
-  %% offset the left padding, also add 1mm as lilypond creates cropped
-  %% images with a little space on the right
-  line-width = #(- line-width (* mm  %(padding_mm)f) (* mm 1))
 }
 
 \layout {
@@ -500,6 +503,7 @@ class LilypondSnippet (Snippet):
         override[EXAMPLEINDENT] = r'0.4\in'
         override[LINE_WIDTH] = '5\\in'
         override.update (self.formatter.default_snippet_options)
+        override['padding_mm'] = self.global_options.padding_mm
 
         option_string = ','.join (self.get_outputrelevant_option_strings ())
         compose_dict = {}