Re: Enhance the -dpreview method for SVG output (issue 326960043 by pkx1...@gmail.com)
One thing I think we need is an entry in the changes.tely for this new feature. Also now that you have tracker access (and because I cannot reassign this Rietveld issue to someone), could you Etienne create a new Rietveld issue for the tracker (which is now assigned to you) when you make the edit to the changes.tely? Then we can discard this one. https://codereview.appspot.com/326960043/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Enhance the -dpreview method for SVG output (issue 326960043 by pkx1...@gmail.com)
Add '-dcrop' option to ps and svg backends This change allows the output of scores in the format provided by the '-dpreview' option but including all systems, not just the first. This would allow for easier SVG use in HTML, without the need for cropping snippets. Further, SVG is an HTML standard, and its vector nature makes its use unparalleled for the web. This change would allow SVG use in 'lilypond-book' in the future. - This patch: https://gerrit.wikimedia.org/r/#/c/370209/ will make use of this change. https://codereview.appspot.com/326960043/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Enhance the -dpreview method for SVG output (issue 326960043 by pkx1...@gmail.com)
In PS2, an implementation of the '-dcrop' argument was added to the 'ps' backend. My implementation has also been revamped to *work* and be more elegant. Letting James upload the patchset. https://codereview.appspot.com/326960043/diff/1/Documentation/usage/running.itely File Documentation/usage/running.itely (right): https://codereview.appspot.com/326960043/diff/1/Documentation/usage/running.itely#newcode683 Documentation/usage/running.itely:683: @tab Match the size of the normal output to the typeset image for SVGs. On 2017/08/01 12:22:02, Carl wrote: This should be placed in alphabetical order (about line 532) I would prefer to see the description be something like Match the size of the normal output to the typeset image (currently only implemented for svg backend). Actually, I'd even more prefer to have the crop function work on the pdf backend as well as the svg backend. Have you investigated whether your code could work on PDF as well? Also, the placement of crop in this file causes reading problems, because it's placed in the middle of preview, and the text below says "This option is supported by all backends", which applies to preview, but not to crop. Done. https://codereview.appspot.com/326960043/diff/1/scm/framework-svg.scm File scm/framework-svg.scm (right): https://codereview.appspot.com/326960043/diff/1/scm/framework-svg.scm#newcode173 scm/framework-svg.scm:173: (define (dump-page-crop paper filename page page-number page-count stensil) On 2017/08/01 12:22:02, Carl wrote: Hmm -- the argument here is spelled "stensil" Acknowledged. https://codereview.appspot.com/326960043/diff/1/scm/framework-svg.scm#newcode178 scm/framework-svg.scm:178: (x-extent (ly:stencil-extent stencil X)) On 2017/08/01 12:22:02, Carl wrote: But here it is spelled "stencil" How does this work? Perhaps the stencil argument is unnecessary and not doing anything here? I'm confused. Function removed in PS2. https://codereview.appspot.com/326960043/diff/1/scm/lily.scm File scm/lily.scm (right): https://codereview.appspot.com/326960043/diff/1/scm/lily.scm#newcode341 scm/lily.scm:341: (crop On 2017/08/01 12:22:02, Carl wrote: This should be put in the proper alphabetical order (up at line 231), rather than placed under preview Done. https://codereview.appspot.com/326960043/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Enhance the -dpreview method for SVG output (issue 326960043 by pkx1...@gmail.com)
Hit send too soon... With the fix, there's still the run-time error: /home/ubuntu/lilypond/build/out/share/lilypond/current/scm/backend-library.scm:245:18: In procedure ly:paper-book-systems in expression (ly:paper-book-systems book): /home/ubuntu/lilypond/build/out/share/lilypond/current/scm/backend-library.scm:245:18: Wrong type argument in position 1 (expecting Paper_book): (#) (staff-refpoint-extent -9.77475935531354 . -9.77475935531354) (last-in-score . #t) (page-turn-penalty) (page-break-penalty) (page-turn-permission . allow) (page-break-permission . allow) (vertical-skylines . #) (stencil . #))() > What would be the best way to approach this feature? Thank you. Étienne 2017-08-01 16:25 GMT-03:00 Étienne Beaulé: > Now that solves half of the issue. The other half is with the width, as my > patch would (should) also adjust the width to fit the music, leaving no > whitespace on any side. > > This feature is basically only available when using \includes " > lilypond-book-preamble.ly" of which only works with the eps backend. My > change would allow the use of "lilypond-book-preamble.ly" with the svg > backend (which is already available in 'eps' so I wouldn't add it there > too), but without the additional system by system output. Do you understand > well now? I'm sorry if I wasn't clear. > > A bit embarrassing to have made a typo in a patch though, but it wouldn't > work anyway. Maybe the way to go would be to implement crop-systems first > for SVG. A worry for me is that it isn't lilypond "cropping" but > GhostScript in the eps backend. Then, it would be worth continuing the plan > of adding a variant of -dpreview. > > I'll be working more on this patch > > 2017-08-01 10:02 GMT-03:00 Paul : > >> On 07/27/2017 03:21 AM, pkx1...@gmail.com wrote: >> >> This is a first attempt to merge the >>> dump-page and dump-preview methods >>> so that there is an option for >>> cropping pages that are not just >>> previews. >>> >> >> I wonder... is the desired functionality already provided by >> one-page-breaking and/or one-line-auto-height-breaking? >> >> http://lilypond.org/doc/v2.19/Documentation/notation/page-br >> eaking#one_002dpage-page-breaking >> >> http://lilypond.org/doc/v2.19/Documentation/notation/page-br >> eaking#one_002dline_002dauto_002dheight-page-breaking >> >> I haven't had time to look at the patch, and I'm still not sure exactly >> what it's trying to do. >> >> -Paul >> >> ___ >> lilypond-devel mailing list >> lilypond-devel@gnu.org >> https://lists.gnu.org/mailman/listinfo/lilypond-devel >> > > ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Enhance the -dpreview method for SVG output (issue 326960043 by pkx1...@gmail.com)
Now that solves half of the issue. The other half is with the width, as my patch would (should) also adjust the width to fit the music, leaving no whitespace on any side. This feature is basically only available when using \includes " lilypond-book-preamble.ly" of which only works with the eps backend. My change would allow the use of "lilypond-book-preamble.ly" with the svg backend (which is already available in 'eps' so I wouldn't add it there too), but without the additional system by system output. Do you understand well now? I'm sorry if I wasn't clear. A bit embarrassing to have made a typo in a patch though, but it wouldn't work anyway. Maybe the way to go would be to implement crop-systems first for SVG. A worry for me is that it isn't lilypond "cropping" but GhostScript in the eps backend. Then, it would be worth continuing the plan of adding a variant of -dpreview. I'll be working more on this patch 2017-08-01 10:02 GMT-03:00 Paul: > On 07/27/2017 03:21 AM, pkx1...@gmail.com wrote: > > This is a first attempt to merge the >> dump-page and dump-preview methods >> so that there is an option for >> cropping pages that are not just >> previews. >> > > I wonder... is the desired functionality already provided by > one-page-breaking and/or one-line-auto-height-breaking? > > http://lilypond.org/doc/v2.19/Documentation/notation/page-br > eaking#one_002dpage-page-breaking > > http://lilypond.org/doc/v2.19/Documentation/notation/page-br > eaking#one_002dline_002dauto_002dheight-page-breaking > > I haven't had time to look at the patch, and I'm still not sure exactly > what it's trying to do. > > -Paul > > ___ > lilypond-devel mailing list > lilypond-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-devel > ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Enhance the -dpreview method for SVG output (issue 326960043 by pkx1...@gmail.com)
On 07/27/2017 03:21 AM, pkx1...@gmail.com wrote: This is a first attempt to merge the dump-page and dump-preview methods so that there is an option for cropping pages that are not just previews. I wonder... is the desired functionality already provided by one-page-breaking and/or one-line-auto-height-breaking? http://lilypond.org/doc/v2.19/Documentation/notation/page-breaking#one_002dpage-page-breaking http://lilypond.org/doc/v2.19/Documentation/notation/page-breaking#one_002dline_002dauto_002dheight-page-breaking I haven't had time to look at the patch, and I'm still not sure exactly what it's trying to do. -Paul ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Enhance the -dpreview method for SVG output (issue 326960043 by pkx1...@gmail.com)
Oh, now I read the first message and see that the code doesn't work. My first attempt at getting the code to work would be to change "stensil" to "stencil" and see if that fixed things. https://codereview.appspot.com/326960043/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Enhance the -dpreview method for SVG output (issue 326960043 by pkx1...@gmail.com)
I have listed some specific changes that must be made (move to the proper alphabetical order) and raised questions about how the code works with an apparently misspelled argument. I believe both of those need to be fixed before pushing the patch. I would also like to see crop apply to at least the pdf backend in addition to svg, if it's not too much work. https://codereview.appspot.com/326960043/diff/1/Documentation/usage/running.itely File Documentation/usage/running.itely (right): https://codereview.appspot.com/326960043/diff/1/Documentation/usage/running.itely#newcode683 Documentation/usage/running.itely:683: @tab Match the size of the normal output to the typeset image for SVGs. This should be placed in alphabetical order (about line 532) I would prefer to see the description be something like Match the size of the normal output to the typeset image (currently only implemented for svg backend). Actually, I'd even more prefer to have the crop function work on the pdf backend as well as the svg backend. Have you investigated whether your code could work on PDF as well? Also, the placement of crop in this file causes reading problems, because it's placed in the middle of preview, and the text below says "This option is supported by all backends", which applies to preview, but not to crop. https://codereview.appspot.com/326960043/diff/1/scm/framework-svg.scm File scm/framework-svg.scm (right): https://codereview.appspot.com/326960043/diff/1/scm/framework-svg.scm#newcode173 scm/framework-svg.scm:173: (define (dump-page-crop paper filename page page-number page-count stensil) Hmm -- the argument here is spelled "stensil" https://codereview.appspot.com/326960043/diff/1/scm/framework-svg.scm#newcode178 scm/framework-svg.scm:178: (x-extent (ly:stencil-extent stencil X)) But here it is spelled "stencil" How does this work? Perhaps the stencil argument is unnecessary and not doing anything here? I'm confused. https://codereview.appspot.com/326960043/diff/1/scm/lily.scm File scm/lily.scm (right): https://codereview.appspot.com/326960043/diff/1/scm/lily.scm#newcode341 scm/lily.scm:341: (crop This should be put in the proper alphabetical order (up at line 231), rather than placed under preview https://codereview.appspot.com/326960043/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: Enhance the -dpreview method for SVG output (issue 326960043 by pkx1...@gmail.com)
I am going to leave this on review for this countdown only that the submitter (not me) had doubts about this patch and was looking for any guidance (it does pass all the tests BTW). https://codereview.appspot.com/326960043/ ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Enhance the -dpreview method for SVG output (issue 326960043 by pkx1...@gmail.com)
Reviewers: , Message: Please note that *i* did the commit message - trying to interpret what Etienne is trying to achieve, so if this is completely non-sensical, blame me not him :) Etienne knows this is a first 'draft' and sent me an email to say so, any guidance would be appreciated: --- From: Étienne BeauléTo: James Subject: Re: [Feature Request]: More flexible SVG snippet cropping Date: Wed, 26 Jul 2017 20:24:41 -0300 I tried making a simple patch, but doesn't work. It's attached. I wouldn't know how, but if something like the "stack-stencils Y DOWN 0.0" section from the output-preview-framework could be passed from output-framework to dump-page and there's a if statement for svg-begin for the -dcrop option. Guidance? All the best Étienne Description: Enhance the -dpreview method for SVG output Issue 5165 Using SVG, the -dpreview option has a limitation of only outputting the first line. This is a first attempt to merge the dump-page and dump-preview methods so that there is an option for cropping pages that are not just previews. Please review this at https://codereview.appspot.com/326960043/ Affected files (+79, -0 lines): M Documentation/usage/running.itely M lily/paper-book.cc M scm/framework-svg.scm M scm/lily.scm Index: Documentation/usage/running.itely diff --git a/Documentation/usage/running.itely b/Documentation/usage/running.itely index 5ab8e1f37045abd4c4c4887c3b59a7a992a28a9d..b0c7ad2aa155f44877b14656505b98b2fdbb526f 100644 --- a/Documentation/usage/running.itely +++ b/Documentation/usage/running.itely @@ -677,6 +677,10 @@ See @ref{Point and click}. @item @code{preview} @tab @code{#f} @tab Create preview images in addition to normal output. + +@item @code{crop} +@tab @code{#f} +@tab Match the size of the normal output to the typeset image for SVGs. @end multitable @noindent Index: lily/paper-book.cc diff --git a/lily/paper-book.cc b/lily/paper-book.cc index c17ed576f1895c0a91febb29164ea9987dda1b0f..f1787e99550f2bb09eb001188b69384c69e5f004 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -219,6 +219,25 @@ Paper_book::output (SCM output_channel) warning (_f ("program option -dpreview not supported by backend `%s'", get_output_backend_name ())); } + + if (get_program_option ("crop")) +{ + SCM framework += ly_module_lookup (mod, ly_symbol2scm ("output-crop-framework")); + + if (scm_is_true (framework)) +{ + SCM func = scm_variable_ref (framework); + scm_call_4 (func, + output_channel, + self_scm (), + scopes, + dump_fields ()); +} + else +warning (_f ("program option -dcrop not supported by backend `%s'", + get_output_backend_name ())); +} } void Index: scm/framework-svg.scm diff --git a/scm/framework-svg.scm b/scm/framework-svg.scm index a4cf2e996055305dbeb36730dc78247b0a1016a4..729f7ad1898451731f72c0967dc784c140a67499 100644 --- a/scm/framework-svg.scm +++ b/scm/framework-svg.scm @@ -170,6 +170,37 @@ src: url('~a'); (dump (svg-end)) (ly:outputter-close outputter))) +(define (dump-page-crop paper filename page page-number page-count stensil) + (let* ((outputter (ly:make-paper-outputter (open-file filename "wb") 'svg)) + (dump (lambda (str) (display str (ly:outputter-port outputter + (lookup (lambda (x) (ly:output-def-lookup paper x))) + (unit-length (lookup 'output-scale)) + (x-extent (ly:stencil-extent stencil X)) + (y-extent (ly:stencil-extent stencil Y)) + (left-x (car x-extent)) + (top-y (cdr y-extent)) + (device-width (interval-length x-extent)) + (device-height (interval-length y-extent)) + (output-scale (* lily-unit->mm-factor unit-length)) + (svg-width (* output-scale device-width)) + (svg-height (* output-scale device-height))) + +(if (ly:get-option 'svg-woff) +(module-define! (ly:outputter-module outputter) 'paper paper)) +(dump (svg-begin svg-width svg-height + left-x (- top-y) device-width device-height)) +(if (ly:get-option 'svg-woff) +(module-remove! (ly:outputter-module outputter) 'paper)) +(if (ly:get-option 'svg-woff) +(dump (woff-header paper (dirname filename +(dump (comment (format #f "Page: ~S/~S" page-number page-count))) +(ly:outputter-output-scheme outputter +`(begin (set! lily-unit-length ,unit-length) +"")) +(ly:outputter-dump-stencil outputter page) +(dump (svg-end)) +(ly:outputter-close outputter))) + (define (output-framework basename book scopes fields) (let* ((paper (ly:paper-book-paper book)) @@ -197,3 +228,25 @@ src: url('~a'); (map