lilypond-user
[Top][All Lists]
Advanced

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

Re: Fonts in SVG output


From: Stuart Pullinger
Subject: Re: Fonts in SVG output
Date: Tue, 17 Jul 2007 14:23:47 +0100

Hi,

I thought I ought to follow up what Nick has said with a little
explanation of what I have done. (This is probably more appropriate to
the lilypond-devel list but, since the discussion was started on
*-user, I am following up here). I should also point out that I am not
a C/Guile/Scheme expert so there may be a much easier way to do the
following.

I have a database with music and performance data in it. I need to
create a score and display performance data above each note in the
score. I have written a Python script which creates a *.ly file from a
query to the database. Each line in the file contains just 1 note with
a comment at the end which contains the note ID number (which is unique
to each note in the database). The file is processed by a slightly
hacked version of lilypond to produce an *.svg file.

I changed the interpret_stencil_expression function, in
the ./lily/stencil-interpret.cc C file, after the

head == ly_symbol2scm ("grob-cause")

line. (If I understand correctly, the grob-cause function is called
once to create the links to source file lines in the pdf output). It
now calls "grob-cause" with an extra "begin" parameter, followed by
calling itself, followed by "grob-cause" with an "end" parameter.

I changed the grob-cause function in the ./scm/output-svg.scm scheme
file to create a link to the originating line in the *.ly file on each
notehead. It creates an opening tag the first time it is called and a
closing tag the second time.

I then process the *.svg file to follow each link to the *.ly file and
read the originating note ID number from the comment at the end of the
line. I can then use the ID to access relevant data in the database and
display it above the notehead.

There are several problems with this approach:
The hacks break support for any other output other than SVG.
- Solution: I keep the hacked version in its own source tree and link
to it using the "--relocate" option.

The output could be made more informative by adding more/different data
to the svg output. For example, so that an SVG line says "I am a ledger
line" or "I am a note stem". I hope to implement this in the not too
distant future. I'll keep the list posted.

No SVG viewers that I am aware of support multiple pages.
- Solution: An XSL transform or simple Python script could extract the
pages from the SVG output. I just haven't got around to this yet.

No SVG viewers that I am aware of actually use the font descriptions in
the lilypond SVG output - they rely on the correct font being available
in the system font directory.

Inkscape and rsvg-view (part of librsvg on most GNU-Linux distros) seem
to be the most reliable for displaying lilypond SVG output. I have had
some problems with SVGs and fonts. It seems to work OK if I use the
same version of lilypond for hacking and normal use and have copies of
the fonts in my ~/.fonts directory (GNU-Linux).

If anyone is interested in my hacks I would be happy to provide
code/patches.

Stuart




reply via email to

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