Re: Lilypond SVG output

2007-10-23 Thread Benjamin Esham
Benjamin Esham wrote:

> [getting usable SVG output from LilyPond]

FWIW, this how-to is now available from the LSR at
.

Cheers,
-- 
Benjamin D. Esham
E-mail/Jabber: [EMAIL PROTECTED] | AIM bdesham128 | PGP D676BB9A
"Science is a differential equation.  Religion is a boundary
condition."— Alan Turing



___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond SVG output

2007-10-23 Thread Graham Percival

Benjamin Esham wrote:

Benjamin Esham wrote:


[getting usable SVG output from LilyPond]


FWIW, this how-to is now available from the LSR at
.


Great!  I'm very interested in this.  Is there any way to automate the 
inkscape step?  inkscape -T  does "export text to path", but presumably 
this doesn't handle the grouping/ungrouping stuff.


Cheers,
- Graham


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond SVG output

2007-10-23 Thread Benjamin Esham
Graham Percival wrote:

> Benjamin Esham wrote:
> > 
> > > [getting usable SVG output from LilyPond]
> > 
> > FWIW, this how-to is now available from the LSR at
> > .
> 
> Great!  I'm very interested in this.  Is there any way to automate the
> inkscape step?  inkscape -T  does "export text to path", but presumably
> this doesn't handle the grouping/ungrouping stuff.

I have no way to automate the Inkscape step.  Inkscape has a semi-native
Python interface, so it might be possible to write a script to iterate
through all of the objects in the file and ungroup/convert them as
appropriate.

(In fact, that might not be too bad at all for someone sufficiently familiar
with Inkscape's Python interface... specifically, one would ungroup the
first couple of document-wide groups, which correspond to the output page.
Then, the document will consist of a bunch of one-element groups; for each
of these that contains a svg:text element, ungroup and convert the text
element to a path.  All of the others should be svg:rect or :line and should
be safe to leave as-is.)

Needless to say, it would be more beneficial overall for someone to simply
fix LilyPond's SVG output in the first place ;-)

-- 
Benjamin D. Esham
E-mail/Jabber: [EMAIL PROTECTED] | AIM bdesham128 | PGP D676BB9A
My friend, you would not tell with such high zest 
  To children ardent for some desperate glory, 
The old Lie: Dulce et decorum est 
  Pro patria mori.— Wilfred Owen



___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond SVG output

2007-10-23 Thread Graham Percival


Benjamin Esham wrote:

Needless to say, it would be more beneficial overall for someone to simply
fix LilyPond's SVG output in the first place ;-)


Patches accepted.  :)

Cheers,
- Graham


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond SVG output

2007-10-23 Thread Graham Percival



Graham Percival wrote:


Benjamin Esham wrote:
Needless to say, it would be more beneficial overall for someone to 
simply

fix LilyPond's SVG output in the first place ;-)


Patches accepted.  :)


BTW, it might not be all that hard -- the output comes from the file 
scm/output-svg.scm   The file is 353 lines, including comments... as far 
as large software projects go, that isn't too bad.


This could be a nice project, and there's plenty of interest in this.

Cheers,
- Graham


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond SVG output

2007-10-24 Thread Vivian Barty-Taylor
BTW, I could never fix the italic font in SVG output (I think the  
font file inside Lilypond is wrong - it seems to contain Cyrillic  
characters) so I installed Century Schoolbook Italic fonts separately  
and altered my .sed file to look like this:


s/style="font-family:Schoolbook;font-style:L/style="font- 
family:Century Schoolbook L;font-style:Roman/g
s/style="font-family:L;font-style:Italic/style="font- 
family:NewCenturySchlbk LT Std;font-style:italic/g

s/feta-alphabet[0-9]+/Emmentaler/g
s/font-family:L;font-style:Bold/font-family:Century Schoolbook L;font- 
style:Bold/g


This solution has the advantage that it distinguishes between Roman,  
Italic and Bold font types.



On Oct 23, 2007, at 10:23 PM, Graham Percival wrote:




Graham Percival wrote:

Benjamin Esham wrote:
Needless to say, it would be more beneficial overall for someone  
to simply

fix LilyPond's SVG output in the first place ;-)

Patches accepted.  :)


BTW, it might not be all that hard -- the output comes from the  
file scm/output-svg.scm   The file is 353 lines, including  
comments... as far as large software projects go, that isn't too bad.


This could be a nice project, and there's plenty of interest in this.

Cheers,
- Graham


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user




___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond SVG output

2007-09-03 Thread Benjamin Esham

[cc'ing to the list]

Vivian Barty-Taylor wrote:


Dear Benjamin and Nick,

This was just to let you know that I've got fixing the Lilypond SVG  
output down to three "replace" operations in EMacs.


Editing the SVG file you replace:

1: all occurrences of "feta-alphabet20" with "Emmentaler"
2: all occurrences of "font-family:Century" with "font- 
family:Century Schoolbook L
3: all occurrences of "font-family:L" with "font-family:Century  
Schoolbook L"


The only output which remains incorrect is italic font type, which  
I haven't found any way of fixing - the SVG file seems to be  
correct, the font file is there, as far as I can see, but it always  
shows as Roman.


It would be perfectly feasible (I suppose) just to make a parser  
which was triggered by the writing of the SVG file by Lilypond  
which corrected these mistakes.


I'm not fluent enough in any language to write this, but maybe one  
of you is?


Hi Vivian,

Thanks for the info!  I wrote the following file to be used with the  
sed tool:


s/feta-alphabet[0-9]+/Emmentaler/g
s/font-family:Century/font-family:Century Schoolbook L/g
s/font-family:L/font-family:Century Schoolbook L/g

Call this with "sed -Ef lilyfix.sed lilyfile.svg > lilyfile_fixed.svg".

I did have to make one change, which was to generalize the expression  
for feta-alphabet to work with other sizes.  This sed script has to  
be run manually from the command line after each time you call  
lilypond; I found that to be a pain, so I wrote a shell script called  
lilysvg, which looks mostly like this (full paths are omitted for  
brevity):


#!/bin/sh
.../lilypond -bsvg -o /tmp/lilysvg $1.ly && sed -Ef .../fix.sed /tmp/ 
lilysvg.svg > $1.svg


Call it with "lilysvg lilyfile", being sure to leave off the ".ly" of  
the filename.


Thanks again for the information on this!  I've now used LilyPond to  
create SVG files of some music snippets for Wikipedia—you can see a  
small gallery at <http://commons.wikimedia.org/wiki/User:Bdesham/ 
Images#Musical_images>.


HTH,
--
Benjamin D. Esham
E-mail/Jabber: [EMAIL PROTECTED] | AIM bdesham128 | PGP D676BB9A
Esperanto, the international language  ☆  http://www.lernu.net

PGP.sig
Description: This is a digitally signed message part
___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond SVG output

2007-09-03 Thread Benjamin Esham
Benjamin Esham wrote:

> [how to get usable SVG output from LilyPond]

I neglected to mention two things...

First, there are still some symbols (such as the piano-staff brace) that do
not show up in Inkscape.  I'm not sure whether this is a LilyPond issue, a
font issue, or an Inkscape issue (although I did try playing around with the
font on the brace's text object and that did not help).

The second is a larger issue.  In order for anyone else to be able to make
use of a LilyPond SVG file, it is necessary to convert all of the text to
paths.  (In Inkscape, this is accomplished with the "Convert to Path"
command.)   Due to the way LilyPond exports its SVG stuff, every single
object is placed in its own group.  Usually, you'd be able to "Select All",
"Ungroup", and "Convert to Path" in order to get the text out of groups and
to convert it into paths.

However, when you actually do that, there's a curious effect: all of the
staff lines disappear!  It turns out that each of those groups actually
contained some style information that transformed or scaled its contents in
some way.  For example, the staff lines are initially very, very thin; only
after the transformation is applied do they become visible at all.

The result here is that while doing an "Ungroup" on the note heads,
accidentals, etc. has no apparent effect, there are serious effects if you
try to do it to staff lines, beams, and possibly some other simple shapes
like those.  The end result is that in order to make LilyPond's SVG output
usable by anyone else, you must select each note head and accidental in the
piece and perform an "Ungroup" and a "Convert to Path".  Needless to say,
this is nigh-unthinkable for any music longer than a snippet.

I think that the best solution to this issue would be to apply the
transformation information to the objects directly instead of wrapping them
with groups.  That way, a simple "Select All" and "Convert to Path" would
make a LilyPond SVG file readable by anyone.

Any workarounds would be greatly appreciated!  Any patches to LilyPond would
be *tremendously* appreciated ;-)

Cheers and HTH,
-- 
Benjamin D. Esham
E-mail/Jabber: [EMAIL PROTECTED] | AIM bdesham128 | PGP D676BB9A
"The silent h is very flexible.  When I'm talking, I'll toss in a
silent h every third syllable, and no one seems to mind.  I'm not
trying to show off by doing it.  I just like the way it doesn't
sound."— Scott Adams



___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond SVG output

2007-09-05 Thread Graham Percival
If you haven't added this to LSR already, could you do so?  You can add 
the script (and usage instructions) as a comment to the snippet.


Cheers,
- Graham


Benjamin Esham wrote:

[cc'ing to the list]

Vivian Barty-Taylor wrote:


Dear Benjamin and Nick,

This was just to let you know that I've got fixing the Lilypond SVG 
output down to three "replace" operations in EMacs.


Editing the SVG file you replace:

1: all occurrences of "feta-alphabet20" with "Emmentaler"
2: all occurrences of "font-family:Century" with "font-family:Century 
Schoolbook L
3: all occurrences of "font-family:L" with "font-family:Century 
Schoolbook L"


The only output which remains incorrect is italic font type, which I 
haven't found any way of fixing - the SVG file seems to be correct, 
the font file is there, as far as I can see, but it always shows as 
Roman.


It would be perfectly feasible (I suppose) just to make a parser 
which was triggered by the writing of the SVG file by Lilypond which 
corrected these mistakes.


I'm not fluent enough in any language to write this, but maybe one of 
you is?


Hi Vivian,

Thanks for the info!  I wrote the following file to be used with the 
sed tool:


s/feta-alphabet[0-9]+/Emmentaler/g
s/font-family:Century/font-family:Century Schoolbook L/g
s/font-family:L/font-family:Century Schoolbook L/g

Call this with "sed -Ef lilyfix.sed lilyfile.svg > lilyfile_fixed.svg".

I did have to make one change, which was to generalize the expression 
for feta-alphabet to work with other sizes.  This sed script has to be 
run manually from the command line after each time you call lilypond; 
I found that to be a pain, so I wrote a shell script called lilysvg, 
which looks mostly like this (full paths are omitted for brevity):


#!/bin/sh
.../lilypond -bsvg -o /tmp/lilysvg $1.ly && sed -Ef .../fix.sed 
/tmp/lilysvg.svg > $1.svg


Call it with "lilysvg lilyfile", being sure to leave off the ".ly" of 
the filename.


Thanks again for the information on this!  I've now used LilyPond to 
create SVG files of some music snippets for Wikipedia—you can see a 
small gallery at 
<http://commons.wikimedia.org/wiki/User:Bdesham/Images#Musical_images>.


HTH,
--Benjamin D. Esham
E-mail/Jabber: [EMAIL PROTECTED] | AIM bdesham128 | PGP D676BB9A
Esperanto, the international language  ☆  http://www.lernu.net


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user
  




___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Lilypond svg output to stdout?

2020-04-30 Thread Marcel Aartsen
Hi,

As the subject says, I would like to have Lilypond output svg to stdout.
Can it be done? How do I do that?

Some background: I am developing an online course in Open edX [1], and
for that course I am writing an XBlock [2]. This means that the user on
the front end triggers a request that is processed by some server-side
Python code that, in my case, in turn calls Lilypond. Lilypond's output
is ultimately on the front end to be displayed in html, so I figured
that svg output would be best. And I reckon that it will be
unnecessarily cumbersome and slow to let Lilypond write to file and then
let the Python code read that file back from disk.

Any ideas to output Lilypond's svg to stdout? Or better alternatives?

Thanks!
Marcel


[1] Open edX https://open.edx.org/ is an open source learning platform
(like e.g. Moodle) developed by MIT and Harvard

[2] XBlocks
https://edx.readthedocs.io/projects/xblock/en/latest/introduction.html
are Python libraries used to provide custom course units for learners
and instructors on the Open edX platform.



0xFAE136BF78A26731.asc
Description: application/pgp-keys


Lilypond SVG output in 2.12.1

2009-02-03 Thread Vivian Barty-Taylor
A while ago, we got a sed script working to fix Lilypond svg output.  
Looking at the SVG output from 2.12.1 on OSX and using InkScape 0.45  
all the grobs are incorrect. I don't have the problems mentioned by  
other users of missing bar lines, so I'll leave this issue.


I investigated the svg file, and found that the unicode values of all  
grobs (a three digit, hexadecimal value) has been offset by 15. Thus  
a quarter-note NoteHead has a unicode value of 136 in Lilypond  
generated SVG, and this needs to be corrected to 127. A G-clef, which  
has a unicode value of 1a7 in Lilypond SVG needs to be corrected to  
197. The previous corrections relating to font-names also need to be  
made - see thread http://lists.gnu.org/archive/html/lilypond-user/ 
2007-09/msg00029.html (Lilypond incorrectly names Century Schoolbook  
and Emmentaler fonts.)


I've had a look at making this correction using a sed script, but  
can't find anything in the documentation relating to the handling of  
hexadecimal numbers. Does anyone have any ideas, before I write a  
script manually correcting each grob? Does anyone know where the SVG  
output is generated and in what language? I might be able to fiddle  
with the source code too, as it seems to be quite a straightforward  
adjustment.


Thanks in advance for any tips.

Cheers,

Vivian.







___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond svg output to stdout?

2020-04-30 Thread David Wright
On Thu 30 Apr 2020 at 21:58:28 (+0200), Marcel Aartsen wrote:
> As the subject says, I would like to have Lilypond output svg to stdout.
> Can it be done? How do I do that?

I don't think you can use stdout itself, as LP already uses it.
However, you can use a pipe:

$ mkfifo foo.svg
$ lilypond -dbackend=svg -o foo music.ly 

which will block until you, say,

$ cat foo.svg | some-consumer-of-svg

I haven't tested whether LP *insists* on adding an .svg extension.

> Some background: I am developing an online course in Open edX [1], and
> for that course I am writing an XBlock [2]. This means that the user on
> the front end triggers a request that is processed by some server-side
> Python code that, in my case, in turn calls Lilypond. Lilypond's output
> is ultimately on the front end to be displayed in html, so I figured
> that svg output would be best. And I reckon that it will be
> unnecessarily cumbersome and slow to let Lilypond write to file and then
> let the Python code read that file back from disk.
> 
> Any ideas to output Lilypond's svg to stdout? Or better alternatives?

Cheers,
David.



Re: Lilypond svg output to stdout?

2020-05-03 Thread Valentin Villenave
On 4/30/20, David Wright  wrote:
> On Thu 30 Apr 2020 at 21:58:28 (+0200), Marcel Aartsen wrote:
> I don't think you can use stdout itself, as LP already uses it.

Well, there *used* to be some work towards something like that; see
the framework-socket.scm file in LilyPond’s source code…

> I haven't tested whether LP *insists* on adding an .svg extension.

It does, but that can be overriden:
https://lists.gnu.org/archive/html/lilypond-user/2019-12/msg00414.html

Cheers,
-- V.



Re: Lilypond svg output to stdout?

2020-05-05 Thread David Wright
On Sun 03 May 2020 at 12:22:31 (+0200), Valentin Villenave wrote:
> On 4/30/20, David Wright  wrote:
> > On Thu 30 Apr 2020 at 21:58:28 (+0200), Marcel Aartsen wrote:
> > I don't think you can use stdout itself, as LP already uses it.
> 
> Well, there *used* to be some work towards something like that; see
> the framework-socket.scm file in LilyPond’s source code…
> 
> > I haven't tested whether LP *insists* on adding an .svg extension.
> 
> It does, but that can be overriden:
> https://lists.gnu.org/archive/html/lilypond-user/2019-12/msg00414.html

Probably hardly worth the effort in this case (and when using files,
it's easy enough to rename them).

BTW I tested my example just by catting the pipe (to let LP run to
completion) and piping the output into less as the consumer (to save
it spewing onto the terminal).

I ought to make it clear that it was intended for the SVG-consumer
to normally be a program, like inkscape. So summarising:

  $ mkfifo foo.svg
  $ lilypond -dbackend=svg -o foo music.ly

  $ inkscape foo.svg

on two terminals, or

  $ mkfifo foo.svg
  $ lilypond -dbackend=svg -o foo music.ly &
  $ inkscape foo.svg

on one.

Sometime, perhaps, I'll try it on two machines, using a socket.

Cheers,
David.



Re: Lilypond svg output to stdout?

2020-05-22 Thread Curt McDowell

A way to output to stdout directly (on Linux):

   $ ln -s /dev/stdout foo.svg
   $ lilypond -dbackend=svg -o foo music.ly

Regards,
Curt

On 5/5/2020 2:42 PM, David Wright wrote:

On Sun 03 May 2020 at 12:22:31 (+0200), Valentin Villenave wrote:

On 4/30/20, David Wright  wrote:

On Thu 30 Apr 2020 at 21:58:28 (+0200), Marcel Aartsen wrote:
I don't think you can use stdout itself, as LP already uses it.

Well, there *used* to be some work towards something like that; see
the framework-socket.scm file in LilyPond’s source code…


I haven't tested whether LP *insists* on adding an .svg extension.

It does, but that can be overriden:
https://lists.gnu.org/archive/html/lilypond-user/2019-12/msg00414.html

Probably hardly worth the effort in this case (and when using files,
it's easy enough to rename them).

BTW I tested my example just by catting the pipe (to let LP run to
completion) and piping the output into less as the consumer (to save
it spewing onto the terminal).

I ought to make it clear that it was intended for the SVG-consumer
to normally be a program, like inkscape. So summarising:

   $ mkfifo foo.svg
   $ lilypond -dbackend=svg -o foo music.ly

   $ inkscape foo.svg

on two terminals, or

   $ mkfifo foo.svg
   $ lilypond -dbackend=svg -o foo music.ly &
   $ inkscape foo.svg

on one.

Sometime, perhaps, I'll try it on two machines, using a socket.

Cheers,
David.





Re: Lilypond SVG output in 2.12.1

2009-02-03 Thread Patrick McCarty
On Tue, Feb 3, 2009 at 5:02 AM, Vivian Barty-Taylor
 wrote:
> A while ago, we got a sed script working to fix Lilypond svg output. Looking
> at the SVG output from 2.12.1 on OSX and using InkScape 0.45 all the grobs
> are incorrect. I don't have the problems mentioned by other users of missing
> bar lines, so I'll leave this issue.
>
> I investigated the svg file, and found that the unicode values of all grobs
> (a three digit, hexadecimal value) has been offset by 15. Thus a
> quarter-note NoteHead has a unicode value of 136 in Lilypond generated SVG,
> and this needs to be corrected to 127. A G-clef, which has a unicode value
> of 1a7 in Lilypond SVG needs to be corrected to 197. The previous
> corrections relating to font-names also need to be made - see thread
> http://lists.gnu.org/archive/html/lilypond-user/2007-09/msg00029.html
> (Lilypond incorrectly names Century Schoolbook and Emmentaler fonts.)

I can reproduce the font-naming issues, but I can't reproduce the
`off-by-15' issue.  I made a very simple LY file, generated SVG from
that, and double-checked all of the hexadecimal values.

Also to be completely accurate here, the hexadecimal values are *four*
digits.  For example, the G-clef has a hex value of e1a7.

> I've had a look at making this correction using a sed script, but can't find
> anything in the documentation relating to the handling of hexadecimal
> numbers. Does anyone have any ideas, before I write a script manually
> correcting each grob? Does anyone know where the SVG output is generated and
> in what language? I might be able to fiddle with the source code too, as it
> seems to be quite a straightforward adjustment.

Here are the workarounds for Inkscape 0.46 that I am using:

1) Move all of LilyPond's OTF fonts into ~/.fonts
2) Change all instances of `currentColor' to `#000' in the SVG file.
Apparently this is no longer an issue with latest Inkscape SVN.

After ungrouping everything, I can use the SVG file just fine.

-Patrick


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond SVG output in 2.12.1

2009-02-03 Thread Benjamin Esham

Vivian Barty-Taylor wrote:

I've had a look at making this correction using a sed script, but  
can't find anything in the documentation relating to the handling of  
hexadecimal numbers. Does anyone have any ideas, before I write a  
script manually correcting each grob? Does anyone know where the SVG  
output is generated and in what language? I might be able to fiddle  
with the source code too, as it seems to be quite a straightforward  
adjustment.


Hi Vivian,

I'm not sure about sed, but this would probably be trivial in (g)awk.   
Are you familiar with that language at all?


--
Benjamin D. Esham   |   bdes...@gmail.com   |   bdesham128 (AIM)
“Given that sooner or later we're all just going to die, what's
the point of learning about integers?”  — Calvin





___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Lilypond SVG output in 2.12.1

2009-02-04 Thread Vivian Barty-Taylor
I figured out what I'd done as I was going to sleep last night -  
funny how these things come to you! I'd failed to update the font  
file in .fonts so the files were still those of the last Lilypond  
release I was using - i.e. 2.10.33. Done this now, and it's working  
so no need for hexadecimal corrections. The original sed script still  
fixes the file.


All the best,

Vivian.

Op Feb 4, 2009, om 2:15 AM heeft Benjamin Esham het volgende geschreven:


Vivian Barty-Taylor wrote:

I've had a look at making this correction using a sed script, but  
can't find anything in the documentation relating to the handling  
of hexadecimal numbers. Does anyone have any ideas, before I write  
a script manually correcting each grob? Does anyone know where the  
SVG output is generated and in what language? I might be able to  
fiddle with the source code too, as it seems to be quite a  
straightforward adjustment.


Hi Vivian,

I'm not sure about sed, but this would probably be trivial in (g) 
awk.  Are you familiar with that language at all?


--
Benjamin D. Esham   |   bdes...@gmail.com   |   bdesham128 (AIM)
“Given that sooner or later we're all just going to die, what's
the point of learning about integers?”  — Calvin







___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user