]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 1816: Lilypond-book: Give images 1mm less linewidth
authorReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 22 Aug 2011 10:15:12 +0000 (12:15 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 30 Aug 2011 15:34:09 +0000 (17:34 +0200)
lilypond creates images that are wider than allowed (~0.5-1mm too wide), so
workaround this by removing 1mm from the linewidth.

Also remove code that makes the fragment snippet option imply
ragged-right. Since single-line snippets are now formatted
ragged-right anyway by default in lilypond, we don't need to set
this explicitly. And multi-line snippets are usually not desired
to be printed ragged-right.

Documentation/usage/lilypond-book.itely
python/book_snippets.py

index 31590d91dd101a0045ca0580aebddc4bfc9edf42..2e6dfd113e5d67cf86c683f48996d426984eab8e 100644 (file)
@@ -667,11 +667,9 @@ Set staff size to @var{ht}, which is measured in points.
 
 @item ragged-right
 Produce ragged-right lines with natural spacing, i.e.,
-@code{ragged-right = ##t} is added to the LilyPond snippet.  This is the
-default for the @code{\lilypond@{@}} command if no @code{line-width}
-option is present.  It is also the default for the @code{lilypond}
-environment if the @code{fragment} option is set, and no line width is
-explicitly specified.
+@code{ragged-right = ##t} is added to the LilyPond snippet.  Single-line
+snippets will always be typeset by default as ragged-right, unless
+@code{noragged-right} is explicitly given.
 
 @item noragged-right
 For single-line snippets, allow the staff length to be stretched to
index 47b683471657e39c1fcf3ef764bf2e8bbaf22075..a67b8b129e59f08599c243269bb8d25b659ffbe3 100644 (file)
@@ -162,6 +162,8 @@ 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"
@@ -175,7 +177,9 @@ PREAMBLE_LY = '''%%%% Generated by %(program_name)s
 
 \paper {
   %(paper_string)s
-  line-width = #(- line-width (* mm  %(padding_mm)f))
+  %% 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 {
@@ -408,22 +412,6 @@ class LilypondSnippet (Snippet):
         if has_relative and not self.option_dict.has_key (FRAGMENT):
             self.option_dict[FRAGMENT] = None
 
-        if not has_line_width:
-            if type == 'lilypond' or FRAGMENT in self.option_dict:
-                self.option_dict[RAGGED_RIGHT] = None
-
-            if type == 'lilypond':
-                if LINE_WIDTH in self.option_dict:
-                    del self.option_dict[LINE_WIDTH]
-            else:
-                if RAGGED_RIGHT in self.option_dict:
-                    if LINE_WIDTH in self.option_dict:
-                        del self.option_dict[LINE_WIDTH]
-
-            if QUOTE in self.option_dict or type == 'lilypond':
-                if LINE_WIDTH in self.option_dict:
-                    del self.option_dict[LINE_WIDTH]
-
         if not INDENT in self.option_dict:
             self.option_dict[INDENT] = '0\\mm'