From: Reinhold Kainhofer Date: Mon, 22 Aug 2011 10:15:12 +0000 (+0200) Subject: Fix 1816: Lilypond-book: Give images 1mm less linewidth X-Git-Tag: release/2.15.10-1~35 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=93d4e8aa80360c95696e065b9fd4744f269f4ea8;p=lilypond.git Fix 1816: Lilypond-book: Give images 1mm less linewidth 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. --- diff --git a/Documentation/usage/lilypond-book.itely b/Documentation/usage/lilypond-book.itely index 31590d91dd..2e6dfd113e 100644 --- a/Documentation/usage/lilypond-book.itely +++ b/Documentation/usage/lilypond-book.itely @@ -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 diff --git a/python/book_snippets.py b/python/book_snippets.py index 47b6834716..a67b8b129e 100644 --- a/python/book_snippets.py +++ b/python/book_snippets.py @@ -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'