lilypond-devel
[Top][All Lists]
Advanced

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

Re: Cairo


From: Knut Petersen
Subject: Re: Cairo
Date: Sun, 27 Jun 2021 19:52:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2

Hi Han-Wen,

I agree. Creating a new backend is actually fairly simple. Just copy
framework-ps.scm to framework-cairo.scm. That should be enough to get
you support for -dbackend=cairo. If you want, you can also copy
output-ps.scm, but that's not strictly necessary (anything that
populates the dispatch alist for the paper-outputter will work.)

I had a quick look at the C++ code. The global variables are a bit
concerning. As a start, you could put them into

   class Cairo_context {
      RefPtr<Cairo::Context> cr;
      ...
   }

this struct will then later be a natural candidate to create a smob
from. However, I wonder why you want to go through Scheme in the first
place, as the output mechanism (Cairo) lives in C++, while steering
the output goes through C++ as well (see paper-outputter.cc).

For the prototype, I think it would be better to insert the Cairo data
(Cairo::Context etc.) into Paper_outputter itself. Then, you can
intercept the Stencils directly in Paper_outputter::output_scheme.
Once that works, we can figure out something with inheritance to
factor out the cairo-specific code.

Hope this helps,

Of course your comments help, as do those of others here on the list that I 
haven't (yet ) responded to.

I started with the Cairo project mainly because the license used by Ghostscript bothers me besides the repeatedly necessary adjustments to new Ghostscript versions. To integrate Ghostscript into Lilypond to the extent that it generates another intermediate format from the Postscript intermediate format, from which the final format is then created, would make a license change for Lilypond necessary, which is neither generally desired nor feasible. An example of things we can't integrate into Lilypond as long as Ghostscript is necessarily involved is code that directly generates videos like the one linked <https://www.youtube.com/watch?v=rb5uyOQLAfQ> here.

The easiest step for me to start with Cairo was to go directly into ps/*, 
scm/output-ps.scm and scm/framework-ps.scm and to program equivalents for the 
postscript code normally generated there.I'll finish that without changing the 
basic approach.

After that I'll look at how and where to integrate all this quite more 
elegantly and efficiently into the existing code.

After that it's time for a merge request, so Werner will have to be patient for 
a while ;-)

Thanks for the hint on paper-outputter.cc.

Knut



reply via email to

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