lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ly:one-line-breaking


From: Paul Morris
Subject: Re: ly:one-line-breaking
Date: Mon, 11 Jan 2016 15:08:19 -0500

> On Jan 9, 2016, at 1:30 PM, Richard Shann <address@hidden> wrote:
> 
> I was wondering if it would be possible to develop a variant of "all on
> one line", namely "all on one page", where the page height would be
> automatically adjusted to fit the music, leaving the width as set.


Well, I made a couple of partially successful attempts.  See two patches 
attached.  I basically followed the examples of minimum line breaking and one 
line breaking, while trying to understand page-breaking.cc.  The challenge is 
calculating the exact page height needed to fit the music.


INITIAL ATTEMPT

Here I access the vertical extent of each system and add them together, along 
with top and bottom margins, to calculate the page height that would allow all 
systems fit on one page.  But this doesn't take into account the spacing 
between systems so the page height is underestimated.  

So next I access system-system-spacing.basic-distance, and add that in.  But 
system-system-spacing is measured from the center of the staff (see [1]), so 
the page height is overestimated.  There doesn’t seem to be any way to use 
these spacing settings to calculate the height.  (I should have seen this 
coming…)

[1] 
http://lilypond.1069038.n5.nabble.com/attachment/164161/0/vertical-spacing-paper-variables.pdf

Maybe (presumably?) somewhere in the vertical spacing code there is a reliable 
way to get an exact height value based on an actual layout of music on the page 
(without any compression), but I haven’t found it.  

(Also top level markups, titles, etc. cause a crash with this code…)


ANOTHER ATTEMPT

Here the idea was to simply take the default layout on N pages and then 
calculate a page height that would be equal to the total of all of the heights 
of those N pages – effectively merging the N pages into one page.  For some 
reason the resulting paper height often seems to be short (despite using an 
existing routine to get the default paper height), and I’m not sure what’s 
going wrong.  LilyPond does seem to fit all the systems onto one page in those 
cases, but with some compression, and ideally there shouldn’t be any need for 
compression.  

(Top level markups, titles, etc. work fine, but there are some programming 
errors reported in the log about trying to fit music... crossing fingers… etc. 
but the results seem to come out ok.)


(I also tried some code that progressively increased or decreased the page 
height, attempting new page breaking at each size, to locate the threshold 
between one and two pages, which would be the height needed.  But this didn’t 
work.  No matter the page height the number of pages stayed the same, I suspect 
because of caching of values for a given page breaking configuration.)

There's a staggeringly sophisticated system for fitting music onto pages that 
have a constant size, but keeping the music constant and changing the page size 
to fit it is another story.

Anyway, it's a start.  I’m putting this on the shelf for now, but wanted to 
share what I’d done to prevent duplication of effort if anyone else feels 
inclined to take this on.

(I’m mostly interested in how this would allow for creating SVG images where 
the size of the image is automatically cropped to fit the music (with user 
customizable margins) rather than having to do this manually with Inkscape.)

-Paul


%%% TEST SNIPPET %%%

\version "2.19.36"

\paper {
  % system-system-spacing.basic-distance = #0
  page-breaking = #ly:one-page-breaking
  % ragged-bottom = ##t
  % top-margin = 0
  % bottom-margin = 0
  % system-system-spacing.minimum-distance = #0
  % system-system-spacing.padding = #0
}

\header {
  % title = "a title"
  tagline = ""
}

% \markup \large "top level markup"

\repeat unfold 200 {
  c' d' e' f'
}

%%%%%%%%%


Attachment: 0001-initial-attempt-at-one-page-breaking.patch
Description: Binary data

Attachment: 0001-initial-attempt-at-one-page-breaking.patch
Description: Binary data



reply via email to

[Prev in Thread] Current Thread [Next in Thread]