lilypond-user
[Top][All Lists]
Advanced

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

Re: Crop only top and bottom


From: Urs Liska
Subject: Re: Crop only top and bottom
Date: Wed, 17 Jan 2018 14:41:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

I have now successfully implemented the approach outlined below. In a LuaLaTeX package I can extract the amount of space used to the left of the staff-lines and offset the image accordingly. However, I would still like to know if there's a more straightforward way directly from within LilyPond.


Am 16.01.2018 um 15:24 schrieb Urs Liska:


I have a two-system score:

%%%%%

\paper{
    left-margin = 50\pt % see below why I use \pt here
    line-width = 17\cm
    indent = 0
}

\new PianoStaff \with {
  instrumentName = "Vl."
} <<
  \new Staff {
    \tempo Allegro
    c''2 ( c'''-. )
    \break
    c'1
  }
  \new Staff {
    \clef bass
    c2 c,\sustainOn
    c1
  }
>>
%%%%%

I compile it using the EPS backend, producing the series of cropped systems:

    lilypond --pdf -dbackend=eps my-file.ly

This gives me (among others) the files my-file.eps. From this I can extract the dimensions of the two systems:

    %%BoundingBox: 27 -200 539 0

(is the third line of the file)
(Parameters are bottom left (X/Y) and top right (X/Y), in points. There are also .eps files for each system, but they differ only by the second parameter, which refers to the height.

What this tells me is that 27 points have been cropped from the left, that is: the 50 point margin defined in the \paper block has been reduced by 27 points. That means the "protrusion" of brace plus instrument name is 50 - 27 = 23 points.

And voilà: when I do

   \hspace*{-23bp}\includegraphics{my-file-1.pdf}

The alignment is correct. (bp (big points) is LaTeX's unit for "points").

...

What I basically do is read the amount of cropping from the left-margin from the intermediate my-file.eps where it looks like (e.g.)

    %%BoundingBox: 27 -200 539 0

When I look at the detailed log I see that LilyPond produces the .eps file (when using the EPS backend) and then invokes Ghostscript to crop it.
But if I'm not mistaken Ghostscript has to rely on the information in the .eps file to crop it - from which I come to the conclusion that it must be LilyPond who writes that BoundingBox statement in the .eps file.

Now the question is: is there any way from within LilyPond to retrieve the bounding box and to write it to a *separate* logfile?
The reason I'm asking is that
a) it feels awkward to have to open the .eps file and search for the necessary information
b) this approach requires me to use -dno-delete-intermediate-files because otherwise the .eps file I need would be purged too.

On a side note: if it would be possible to access the bounding box from within LilyPond, would it also be possible to *change* it?
If I could set the X of the left point to zero the resulting file should actually have the proper left-margin as defined in the paper block.

If that's not possible: is there a hook where I can execute some code *after* the eps file has been created but *before* it has been purged?

Urs


     Werner


_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user



_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user


reply via email to

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