James Allwright - 2022-03-17

Changes in the latest release

The latest release of abcCairo fixes some bugs, but also
re-arranges the code to work in a slightly different way.

The original abcm2ps source code buffers up its output as
it goes along and writes out the buffer later at critical
moments. As the buffer is written, symbols are placed
relative to certain positions on the stave, and only when a whole
line of music has been processed can we work out where
the stave needs to be placed so that the current line of
music doesn't collide with the previous one.
Thus a whole lot of PostScript graphics
calls are generated, but these ultimately rely on a
variable whose value is not calculated until later, at
which point the PostScript to set the variable can be
generated and written to the file, followed by all the
commands making use of that variable.

The buffering mechanism is an ingenious solution which
works with PostScript, but doesn't work when you are
writing graphics directly to a screen (or canvas in the
terminology of the Cairo library), because you need to
have all the position information at the point when you
draw a graphical element. I had to replace this mechanism to get
abcCairo to work.

One common way to deal with this sort
of problem is to construct a data structure to represent
whatever you want to write and only write it out when you
have all the information you need.
The abcCairo code uses a different approach. There are two
passes through the abc. On the first pass, the position of
each stave is calculated and stored. On the second pass
these stave positions are retrieved so that we have all the
information to write graphics to the right place.

This makes it possible to write individual image files for
each abc tune. However, when we are writing to pages of
PostScript, there is additional logic to make sure that as
far as possible tunes are never broken across page boundaries.
The original abcm2ps code again used the buffering technique
to handle this. The current release uses a third pass to
remove any need for buffering. This has resulted in the
code in buffer.c being simplified. New code in page_manager.c
handles the placing of tunes onto pages. This will make it
possible to generate images of pages rather of individual
tunes at a later date.