+2005-06-22 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * VERSION (PATCH_LEVEL): release 2.5.32
+
+ * lily/lily-parser-scheme.cc (LY_DEFINE): don't set 'parser
+ variable in lily module
+
+ * scm/framework-ps.scm (output-classic-framework): error message
+ regarding the classic framework.
+
+ * Documentation/user/henle-flat-gray.png (Module): new file.
+
+ * Documentation/user/baer-flat-gray.png (Module): new file.
+
+ * scm/output-lib.scm (fret-number-tablature-format): vcenter and
+ whiteout for markups.
+
+ * buildscripts/substitute-encoding.py (note_glyph): include _ in
+ regex too. This fixes change clef appearance in PDF.
+
+ * ttftool/include/*: remove.
+
+ * configure.in (reloc_b): remove TTFTOOL_ENDIAN
+
+ * config.make.in (WINDRES): remove TTFTOOL_ENDIAN.
+
+ * lily/GNUmakefile (MODULE_INCLUDES): remove ttftool
+
+ * ttftool/*: remove ttftool subdirectory.
+
+ * GNUmakefile.in (SUBDIRS): remove ttftool subdirectory.
+
+ * lily/ttf.cc (print_header): new file. Convert to type42, using
+ FreeType to parse the TTF.
+
+ * ttftool/parse.c (readPostTable): ugh. Kludge: nglyphs in maxp
+ and post table may differ. Pass around post_nglyphs as well.
+
+2005-06-20 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * ly/music-functions-init.ly (musicMap): new music function
+ musicMap.
+
+2005-06-19 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * make/mutopia-rules.make: anti-alias-factor = 2
+
+ * scm/ps-to-png.scm (make-ps-images): cleanup multipage vs. single
+ page switch.
+
+ * make/lilypond-vars.make (LILYPOND_BOOK_FLAGS): set
+ anti-alias-factor for lilypond-book runs.
+
+ * scm/ps-to-png.scm (scale-down-image): new function.
+ (my-system): new function.
+ (make-ps-images): blow up GS resolution by anti-alias-factor,
+ scale down image by anti-alias-factor. This improves appearance
+ of bitmaps
+ (make-ps-images): remove showpage. Fixes spurious empty png at
+ end.
+
+ * scm/framework-ps.scm (write-preamble): downcase filename before
+ string-matching. Should fix .TTF files (as opposed to ttf files)
+
+ * Documentation/user/tutorial.itely (Running LilyPond for the
+ first time): separate subsections for windows, macos and unix.
+
+ * Documentation/user/invoking.itely (Updating files with
+ convert-ly): add MacOS X note.
+
+2005-06-18 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * Documentation/user/introduction.itely (Engraving): don't include
+ file optical-spacing, add directly.
+
+ * lily/paper-outputter.cc (file): open file in binary mode. This
+ fixes OTF embedding on windows.
+
+2005-06-17 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * scm/framework-ps.scm (write-preamble): remove debugging output.
+
+ * mf/aybabtu.pe.in (i): don't generate aybabtu.cff
+
+ * mf/GNUmakefile ($(outdir)/fonts.cache-1): create font cache for
+ outdir.
+ (install-fc-cache): install font cache in installation directories.
+
+2005-06-17 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * scm/editor.scm (editor-command-template-alist): Use char iso
+ column, except for Emacs.
+ (get-editor-command): Substitute char too (Bertalan Fodor).
+
+2005-06-16 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * scm/ps-to-png.scm (make-ps-images): Use ~S instead of single
+ quoted ~s. This should fix PNG output on Windows; single quotes
+ are regular characters on Windows.
+
+2005-06-16 Graham Percival <gperlist@shaw.ca>
+
+ * Documentation/user/basic-notation.itely: include ChoirStaff
+ in System start delimiters.
+
+ * Documentation/user/putting.itely: new doc section on
+ fixing overlapping notation.
+
+2005-06-16 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * Documentation/user/global.itely (Paper size): \paper is in
+ \book, not \score.
+
+ * make/mutopia-rules.make: -ddelete-intermediate-files
+
+ * ly/engraver-init.ly: make Staff default child of ChoirStaff.
+
+2005-06-16 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * ChangeLog: Recode utf-8.
+
+ * python/GNUmakefile (INSTALLATION_OUT_DIR): Install .so module in
+ datadir with .py modules.
+
+2005-06-15 Heikki Junes <hjunes@cc.hut.fi>
+
+ * Documentation/user/basic-notation.itely (Ties): add tieDashed.
+
+2005-06-15 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * make/mutopia-rules.make: switch off ps, p&c for lilypond runs.
+
+ * scm/framework-ps.scm (write-preamble): remove status check.
+
+ * Documentation/user/invoking.itely (Updating files with
+ convert-ly): remove -o option.
+
+ * VERSION (PACKAGE_NAME): release 2.5.31
+
+ * scm/framework-ps.scm (write-preamble): use ly:system.
+ (write-preamble): verbosity.
+
+ * scripts/convert-ly.py: cleanup. Use lilylib. Use convertrules.
+
+ * python/convertrules.py: new file. Store conversion rules
+ separately.
+
+2005-06-14 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * scm/backend-library.scm (postprocess-output): remove debugging gobs.
+
+2005-06-14 Mats Bengtsson <mabe@drongo.s3.kth.se>
+
+ * Documentation/topdocs/NEWS.tely (Top): Corrected name of
+ \musicDisplay
+
+ * Documentation/user/instrument-notation.itely (More stanzas): Add
+ reference to StanzaNumber.
+
+2005-06-14 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * THANKS: separate section for website translators.
+
2005-06-14 Graham Percival <gperlist@shaw.ca>
* Documentation/topdocs/INSTALL.texi: update vim info;
color names into an appendix.
2005-06-14 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
+
* lily/program-option.cc (LY_DEFINE): new function ly_add_option.
* scm/lily.scm (lambda): initialize program options from here.
* Documentation/pictures/GNUmakefile (OUT_DIST_FILES): Add ly-icon
rules.
->>>>>>> 1.3718
2005-05-28 Han-Wen Nienhuys <hanwen@xs4all.nl>
* lily/stencil-scheme.cc (LY_DEFINE): ly:stencil-in-color
* scm/backend-library.scm (postscript->pdf): Invoke gs instead of
going through ps2pdf wrappers.
-2005-05-09 Jürgen Reuter <reuter@ipd.uka.de>
+2005-05-09 Jürgen Reuter <reuter@ipd.uka.de>
* Documentation/user/instrument-notation.itely: petrucci note
heads: updated docu
* lily/mensural-ligature.cc (brew_flexa): apply thickness property
only on vertical lines of flexa shape, and use a constant
thickness value for horizontal lines (patch slightly modified by
- Jürgen Reuter)
+ Jürgen Reuter)
* lily/include/mensural-ligature.hh: make 2 comments clearer
-2005-04-28 Jürgen Reuter <reuter@ipd.uka.de>
+2005-04-28 Jürgen Reuter <reuter@ipd.uka.de>
* lily/vaticana-ligature-engraver.cc (need_extra_space): renamed
to need_extra_horizontal_space; bugfix: use class scope to avoid
* Documentation/user/global.itely (Page layout): remove
printpagenumber.
-2005-03-13 Jürgen Reuter <reuter@ipd.uka.de>
+2005-03-13 Jürgen Reuter <reuter@ipd.uka.de>
* input/regression/mensural-ligatures.ly: new file (with examples
compiled by Pal Benko).
* Documentation/user/notation.itely: small but urgent fix.
-2005-02-21 Jürgen Reuter <reuter@ipd.uka.de>
+2005-02-21 Jürgen Reuter <reuter@ipd.uka.de>
* lily/duration-scheme.cc: bugfix: correct parameters to
SCM_ASSERT_TYPE.
* configure.in: add endian test.
-2005-02-19 Jürgen Reuter <reuter@ipd.uka.de>
+2005-02-19 Jürgen Reuter <reuter@ipd.uka.de>
* Documentation/user/examples.itely: small
simplification/beautification
* tex/lily-pdf-defs.tex, tex/lily-ps-defs.tex
(\lilypondexperimentalfeatures): Removed.
-2004-10-20 Jürgen Reuter <reuter@ipd.uka.de>
+2004-10-20 Jürgen Reuter <reuter@ipd.uka.de>
* Documentation/user/notation.itely: fixed 2 typos
2004-04-01 Han-Wen Nienhuys <hanwen@xs4all.nl>
* VERSION (PACKAGE_NAME): release 2.2.0
+
+#Local variables:
+#coding: utf-8
+#End:
+
markup texts.
@item
-There is a music function @code{\musicDisplay}, which will display a
+There is a music function @code{\displayMusic}, which will display a
music expression as indented Scheme code.
@item
for texts, including kerning and accents.
@item
-LilyPond now uses FreeType read the Feta font as an OpenType font. This
-is a cleaner design and more robust. Recent versions of FontForge (2004
-1211 or newer) and Freetype are required. As a result,
+LilyPond now uses FreeType to read the Feta font as an OpenType
+font. This is a cleaner design and more robust. Recent versions of
+FontForge (2004 1211 or newer) and Freetype are required.
@item
-the SVG backend is now a fully functional backend.
+The SVG backend is now a fully functional backend.
@item
A new script, @code{\espressivo} has been added, for a combination of
@cindex brace, vertical
@cindex grand staff
@cindex staff group
+@cindex staff, choir
Many scores consist of more than one staff. These staves can be
-joined in three different ways
+joined in four different ways
@itemize @bullet
@item The group is started with a brace at the left, and bar lines are
>>
@end lilypond
+@item The group is started with a bracket, but bar lines are not
+connected. This is done with the @internalsref{ChoirStaff} context.
+
+@lilypond[verbatim,raggedright,quote]
+\new ChoirStaff
+\relative <<
+ \new Staff { c1 c }
+ \new Staff { c c }
+>>
+@end lilypond
+
@item The group is started with a vertical line. Bar lines are not
connected. This is the default for the score.
@code{\tieNeutral},
@cindex @code{\tieDotted}
@code{\tieDotted},
+@cindex @code{\tieDashed}
+@code{\tieDashed},
@cindex @code{\tieSolid}
@code{\tieSolid}.
The first command sets the size of all pages. The second command sets the size
of the pages that the @code{\paper} block applies to -- if the @code{\paper}
block is at the top of the file, then it will apply to all pages. If the
-@code{\paper} block is inside a @code{\score}, then the paper size will only
-apply to that score.
+@code{\paper} block is inside a @code{\book}, then the paper size will only
+apply to that book.
The following paper sizes are supported: @code{a6}, @code{a5}, @code{a4},
@code{a3}, @code{legal}, @code{letter}, @code{tabloid}.
@seealso
-Program reference: @internalsref{LyricText}, @internalsref{VocalName}.
+Program reference: @internalsref{LyricText}, @internalsref{StanzaNumber}, @internalsref{VocalName}.
@item @tab
@ifnotinfo
@iftex
-@image{henle-flat-bw,4cm}
+@image{henle-flat-gray,,8cm}
@end iftex
@ifnottex
-@image{henle-flat-bw,,,png}
+@image{henle-flat-gray,,,png}
@end ifnottex
@tab
@iftex
-@image{baer-flat-bw,4cm}
+@image{baer-flat-gray,,8.4cm}
@end iftex
@ifnottex
-@image{baer-flat-bw,,,png}
+@image{baer-flat-gray,,,png}
@end ifnottex
@tab
@iftex
-@image{lily-flat-bw,4cm}
+@image{lily-flat-bw,,8cm}
@end iftex
@ifnottex
@image{lily-flat-bw,,,png}
spot which fragment is which?
@cindex optical spacing
-@lilypondfile[quote,noindent]{spacing-optical.ly}
+@c file spacing-optical.
+@c need to include it here, because we want two images.
+@lilypond
+\paper {
+ raggedright = ##t
+ indent = #0.0
+}
+
+music = {
+ c'4 e''4 e'4 b'4 |
+ \stemDown
+ b'8[ e'' a' e'']
+ \stemNeutral
+ e'8[ e'8 e'8 e'8]
+}
+
+\score
+{
+ \music
+ \layout {
+ \context {
+ \Staff
+ \override NoteSpacing #'stem-spacing-correction = #0.6
+ }
+ }
+}
+@end lilypond
+
+@lilypond
+\paper {
+ raggedright = ##t
+ indent = #0.0
+}
+
+music = {
+ c'4 e''4 e'4 b'4 |
+ \stemDown
+ b'8[ e'' a' e'']
+ \stemNeutral
+ e'8[ e'8 e'8 e'8]
+}
+\score
+{
+ \music
+ \layout {
+ \context {
+ \Staff
+ \override NoteSpacing #'stem-spacing-correction = #0.0
+ \override NoteSpacing #'same-direction-correction = #0.0
+ \override StaffSpacing #'stem-spacing-correction = #0.0
+ }
+ }
+}
+@end lilypond
@cindex regular rhythms
@cindex regular spacing
the program @command{convert-ly} can be used to deal with most of the
syntax changes between LilyPond versions.
-It uses @code{\version} statements in the input files to detect the old
-version number. In most cases, to upgrade your input file it is sufficient
-to run
+It uses @code{\version} statements in the input files to detect the
+old version number. In most cases, to upgrade your input file it is
+sufficient to run@footnote{MacOS X users may execute this command
+under the menu entry @samp{Compile > Update syntax}.}
@example
convert-ly -e myfile.ly
Set the version to convert from. If this is not set, @command{convert-ly}
will guess this, on the basis of @code{\version} strings in the file.
-@item -o,--output=@var{file}
-Set the output file to write.
-
@item -n,--no-version
Normally, @command{convert-ly} adds a @code{\version} indicator
to the output. Specifying this option suppresses this.
@menu
* Suggestions for writing LilyPond files::
* Extending the templates::
+* Fixing overlapping notation::
@end menu
@end lilypond
+
+@node Fixing overlapping notation
+@section Fixing overlapping notation
+
+This may come as a surprise, but LilyPond isn't perfect. Some notation
+elements can overlap. This is unfortunate, but (in most cases) is easily
+solved.
+
+@lilypond[quote,fragment,raggedright,verbatim,relative=2]
+e4^\markup{ \italic ritenuto } g b e
+@end lilypond
+
+@cindex padding
+
+The easiest solution is to increase the distance between the object
+(in this case text, but it could easily be fingerings or dynamics
+instead) and the note. In LilyPond, this is called the
+@code{padding} property. For most objects, it is around 1.0 or
+less (it varies with each object). We want to increase it, so let's
+try 1.5
+
+@lilypond[quote,fragment,raggedright,verbatim,relative=2]
+\once \override TextScript #'padding = #1.5
+e4^\markup{ \italic ritenuto } g b e
+@end lilypond
+
+That looks better, but it isn't quite big enough. After experimenting
+with a few values, I think 2.3 is the best number. I leave this as an
+exercise for the reader.
+
+@cindex extra-offset
+
+Another solution gives us complete control over placing the object -- we
+can move it horizontally or vertically. This is done with the
+@code{extra-offset} property. It is slightly more complicated and can
+cause other problems. When we move objects with @code{extra-offset},
+the movement is done after LilyPond has placed all other objects. This means
+that the result can overlap with other objects.
+
+@lilypond[quote,fragment,raggedright,verbatim,relative=2]
+\once \override TextScript #'extra-offset = #'( 1.0 . -1.0 )
+e4^\markup{ \italic ritenuto } g b e
+@end lilypond
+
+With @code{extra-offset}, the first number controls the horizontal
+movement (left is negative); the second number controls the vertial
+movement (up is positive). After a bit of experimenting, I decided
+that these values look good
+
+@lilypond[quote,fragment,raggedright,verbatim,relative=2]
+\once \override TextScript #'extra-offset = #'( -1.6 . 1.0 )
+e4^\markup{ \italic ritenuto } g b e
+@end lilypond
+
+
+@seealso
+
+This manual: @ref{The \override command}, @ref{Common tweaks}.
+
+
@c cheesy title to avoid clash with chapter name.
-In the last section we explained what kind of things you can enter
-in a LilyPond file. In this section we will explain what commands to
-run and how to view or print the output. If you have not used
-LilyPond before, want to test your setup, or want to run an example
-file yourself, read this section. The instructions that follow are
-for Unix-like systems. Some additional instructions for Microsoft
-Windows are given at the end of this section.
+In the last section we explained what kind of things you can enter in
+a LilyPond file. In this section we will explain what commands to run
+and how to view or print the output. If you have not used LilyPond
+before, want to test your setup, or want to run an example file
+yourself, read this section.
+
+@unnumberedsubsec MacOS X
+
+If you double click LilyPond.app, it will open with an example
+file. Save it, for example, to @file{test.ly} on your Desktop, and
+then process it with the menu command @samp{Compile > Typeset File}.
+The resulting PDF file will be displayed on your screen.
+
+Be warned that the first-ever run will take a minute or two, because
+all of the system fonts have to be analyzed first.
+
+@unnumberedsubsec Windows
+
+On Windows, start up a text-editor@footnote{Any simple or
+programmer-oriented editor will do, for example Notepad. Do not use a
+word processor, since these insert formatting codes that will confuse
+LilyPond.} and enter
+
+@example
+@{ c'4 e' g' @}
+@end example
+
+Save it on the desktop as @file{test.ly} and make sure that it is not
+called @file{test.ly.TXT}. Double clicking @file{test.ly} will process
+the file and show the resulting PDF file.
+
+
+@unnumberedsubsec Unix
Begin by opening a terminal window and starting a text editor. For
example, you could open an xterm and execute
@code{joe}.@footnote{There are macro files for VIM addicts, and there
is a @code{LilyPond-mode} for Emacs addicts. If they have not been
-installed already, refer to
-the file @file{INSTALL.txt}.} In your text editor, enter the following
-input and save the file as @file{test.ly}
+installed already, refer to the file @file{INSTALL.txt}.} In your
+text editor, enter the following input and save the file as
+@file{test.ly}
@example
@{ c'4 e' g' @}
@uref{http://@/www@/.cs@/.wisc@/.edu/@/~ghost/,Ghostscript}, a freely
available package for viewing and printing PDF and PostScript files.}
-On Windows, start up a text-editor@footnote{Any simple or
-programmer-oriented editor will do, for example Notepad. Do not use a
-word processor, since these insert formatting codes that will confuse
-LilyPond.} and enter
-
-@example
-@{ c'4 e' g' @}
-@end example
-
-Save it on the desktop as @file{test.ly} and make sure that it is not
-called @file{test.ly.TXT}. Double clicking @file{test.ly} will process
-the file and show the resulting PDF file.
-
-
@node More about pitches
@section More about pitches
#
SUBDIRS = buildscripts python scripts \
elisp \
- flower kpath-guile ttftool lily \
+ flower kpath-guile lily \
mf ly tex ps scm \
po make \
cygwin debian stepmake \
John Williams
Jonatan Liljedahl
Juergen Reuter
-Juliusz Chroboczek
Mats Bengtsson
Matthias Neeracher
Mathieu Giraud
Olcay Yıldırım
Roland Stigge
Steven Michael Murphy
+
+
+WEBSITE TRANSLATORS
+
+Gauvain Pocentek
+Jean-Charles Malahieude
+John Mandereau
Tineke de Munnik
+
SPONSORS
Bertalan Fodor
PACKAGE_NAME=LilyPond
MAJOR_VERSION=2
MINOR_VERSION=5
-PATCH_LEVEL=31
+PATCH_LEVEL=32
MY_PATCH_LEVEL=
glyphs.append (nm)
- m = re.sub ("(/[a-z-.A-Z0-9]+) %", note_glyph, enc_str )
+ m = re.sub ("(/[a-z.A-Z0-9_]+) %", note_glyph, enc_str )
glyphs = filter (lambda x: None == re.match (r'/\.notdef', x),
glyphs)
SHELL = @SHELL@
SPLITTING_MAKEINFO = @SPLITTING_MAKEINFO@
TAR = @TAR@
-TTFTOOL_ENDIAN = @TTFTOOL_ENDIAN@
WINDRES = @WINDRES@
YACC = @YACC@
ZIP = @ZIP@
STEPMAKE_PANGO_FT2(pangoft2, REQUIRED, 1.6.0)
STEPMAKE_FONTCONFIG(fontconfig, OPTIONAL, 2.2.0)
-## TTFTOOL stuff
-AC_C_BIGENDIAN(TTFTOOL_ENDIAN="-DBIGENDIAN",
- TTFTOOL_ENDIAN="-DSMALLENDIAN")
-AC_SUBST(TTFTOOL_ENDIAN)
-
STEPMAKE_WINDOWS
## Optional tools for building documentation, website, extra fonts.
r8. cis,,16(\sustainUp <fis fis,>8 <gis gis,>
| %3
- \override Stem #'length = #5 %tweak
+% \once \override Stem #'length = #6 %tweak
<a a,>4\sustainDown
\change Staff=treble
- \revert Stem #'length %tweak
\revert Stem #'direction
\override Stem #'direction = #-1
<a' fis cis>)\arpeggio
NAME = lilypond
SUBDIRS = include
-MODULE_LIBS= $(depth)/ttftool $(depth)/flower $(depth)/kpath-guile
-MODULE_INCLUDES= $(depth)/flower/include $(depth)/ttftool/include
+MODULE_LIBS= $(depth)/flower $(depth)/kpath-guile
+MODULE_INCLUDES= $(depth)/flower/include
MODULE_CXXFLAGS=
HELP2MAN_EXECS = lilypond
#include "main.hh"
#include "warn.hh"
+FcConfig *font_config_global = 0;
+
void
init_fontconfig ()
{
message (_ ("Initializing FontConfig..."));
if (!FcInit ())
- error (_ ("initializing FontConfig"));
-
- FcConfig *fcc = FcConfigGetCurrent ();
+ error (_ ("initializing FontConfig failed"));
-#if 0
- /*
- Hmm. the cache is always out of date??!
- */
- FcChar8 *cache = FcConfigGetCache (fcc);
- if (!FcDirCacheValid (cache))
- {
- warning (_ ("FontConfig cache out of date. Rebuilding may take some time."));
- }
-#endif
+ font_config_global = FcConfigGetCurrent ();
Array<String> dirs;
struct stat statbuf;
String builddir = prefix_directory + "/mf/out/";
for (int i = 0; i < dirs.size (); i++)
{
String dir = dirs[i];
- if (!FcConfigAppFontAddDir (fcc, (FcChar8 *)dir.to_str0 ()))
+ if (!FcConfigAppFontAddDir (font_config_global, (FcChar8 *)dir.to_str0 ()))
error (_f ("adding font directory: %s", dir.to_str0 ()));
else if (be_verbose_global)
message (_f ("adding font directory: %s", dir.to_str0 ()));
#include <ft2build.h>
#include FT_FREETYPE_H
+#include "string.hh"
+
void init_freetype ();
extern FT_Library freetype2_library;
+
+FT_Face open_ft_face (String str);
+
#endif /* FREETYPE_HH */
Sources sources;
sources.set_path (&global_path);
Lily_parser *parser = new Lily_parser (&sources);
- scm_module_define (global_lily_module, ly_symbol2scm ("parser"),
- parser->self_scm ());
parser->parse_string (ly_scm2string (ly_code));
scm_gc_unprotect_object (parser->self_scm ());
parser = 0;
if (file_name_ == "-")
file_ = scm_current_output_port ();
else
+ /*
+ Opening binary sucks a little for DOS, since PS doesn't look like
+ ASCII anymore, but binary CFFs will get embedded correctly.
+ */
file_ = scm_open_file (scm_makfrom0str (file_name_.to_str0 ()),
- scm_makfrom0str ("w"));
+ scm_makfrom0str ("wb"));
return file_;
}
#include "program-option.hh"
#include "source-file.hh"
#include "memory-stream.hh"
-#include "ttftool.h"
#include "open-type-font.hh"
#include "main.hh"
#include "warn.hh"
return pfa_scm;
}
-LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa",
- 1, 0, 0, (SCM ttf_file_name),
- "Convert the contents of a TTF file to Type42 PFA, returning it as "
- " a string.")
-{
- SCM_ASSERT_TYPE (scm_is_string (ttf_file_name), ttf_file_name,
- SCM_ARG1, __FUNCTION__, "string");
-
- String file_name = ly_scm2string (ttf_file_name);
- if (be_verbose_global)
- progress_indication ("[" + file_name);
-
-
- Memory_out_stream stream;
- ttf_verbosity =
- robust_scm2int (ly_get_option (ly_symbol2scm ("ttf-verbosity")), 0);
-
- create_type42 (file_name.to_str0 (), (void*) &stream);
- SCM asscm = scm_from_locale_stringn (stream.get_string (),
- stream.get_length ());
-
- if (be_verbose_global)
- progress_indication ("]");
-
- return asscm;
-}
-
LY_DEFINE (ly_otf_to_cff, "ly:otf->cff",
const int INDENT = 2;
const int SEPARATION = 5;
+/*
+ Hmmm. should do in SCM / C++ ?
+ */
static String
get_help_string ()
{
SCM convertor = ly_lily_module_constant ("scm->string");
- String help ("Options supported by ly:set-option\n\n");
+ Array<String> opts;
+
for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
{
SCM sym = scm_caar (s);
String ("\n")
+ String_convert::char_string (' ', HELP_INDENT));
- help += opt_spec + opt_help + "\n";
+ opts.push (opt_spec + opt_help + "\n");
}
-
+
+ String help ("Options supported by ly:set-option\n\n");
+ opts.sort (String::compare);
+ for (int i = 0; i < opts.size (); i++)
+ help += opts[i];
+
help += String ("\n");
return help;
}
--- /dev/null
+/*
+ ttf.cc -- implement ttf -> pfa routine.
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "freetype.hh"
+
+#include <freetype/tttables.h>
+
+#include "lily-proto.hh"
+#include "memory-stream.hh"
+#include "warn.hh"
+#include "lily-guile.hh"
+#include "main.hh"
+
+static void
+print_header (void *out, FT_Face face)
+{
+ lily_cookie_fprintf (out, "%%!PS-TrueTypeFont\n");
+
+ TT_Postscript *pt =
+ (TT_Postscript*) FT_Get_Sfnt_Table(face, ft_sfnt_post);
+
+ if (pt->maxMemType42)
+ lily_cookie_fprintf (out, "%%%%VMUsage: %ld %ld\n", 0, 0);
+
+ lily_cookie_fprintf (out, "%d dict begin\n", 11);
+ lily_cookie_fprintf (out, "/FontName /%s def\n",
+ FT_Get_Postscript_Name (face));
+
+ lily_cookie_fprintf (out, "/Encoding StandardEncoding def\n");
+ lily_cookie_fprintf (out, "/PaintType 0 def\n");
+ lily_cookie_fprintf (out, "/FontMatrix [1 0 0 1 0 0] def\n");
+
+ TT_Header *ht =
+ (TT_Header*)FT_Get_Sfnt_Table(face, ft_sfnt_head);
+
+ lily_cookie_fprintf (out, "/FontBBox [%ld %ld %ld %ld] def\n",
+ ht->xMin * 1000L / ht->Units_Per_EM,
+ ht->yMin * 1000L / ht->Units_Per_EM,
+ ht->xMax * 1000L / ht->Units_Per_EM,
+ ht->yMax * 1000L / ht->Units_Per_EM);
+
+ lily_cookie_fprintf (out, "/FontType 42 def\n");
+ lily_cookie_fprintf (out, "/FontInfo 8 dict dup begin\n");
+ lily_cookie_fprintf (out, "/version (%d.%d) def\n",
+ (ht->Font_Revision >> 16),
+ (ht->Font_Revision & ((1 << 16) -1)));
+
+#if 0
+ if (strings[0])
+ {
+ lily_cookie_fprintf (out, "/Notice (");
+ fputpss (strings[0], out);
+ lily_cookie_fprintf (out, ") def\n");
+ }
+ if (strings[4])
+ {
+ lily_cookie_fprintf (out, "/FullName (");
+ fputpss (strings[4], out);
+ lily_cookie_fprintf (out, ") def\n");
+ }
+ if (strings[1])
+ {
+ lily_cookie_fprintf (out, "/FamilyName (");
+ fputpss (strings[1], out);
+ lily_cookie_fprintf (out, ") def\n");
+ }
+#endif
+
+ lily_cookie_fprintf (out, "/isFixedPitch %s def\n",
+ pt->isFixedPitch ? "true" : "false");
+ lily_cookie_fprintf (out, "/UnderlinePosition %ld def\n",
+ pt->underlinePosition * 1000L / ht->Units_Per_EM);
+ lily_cookie_fprintf (out, "/UnderlineThickness %ld def\n",
+ pt->underlineThickness * 1000L / ht->Units_Per_EM);
+ lily_cookie_fprintf (out, "end readonly def\n");
+}
+
+
+
+#define CHUNKSIZE 65534
+
+static void
+print_body (void *out, String name)
+{
+ FILE *fd = fopen (name.to_str0 (), "rb");
+
+ static char xdigits[] = "0123456789ABCDEF";
+
+ unsigned char *buffer;
+ int i, j;
+
+ buffer = new unsigned char[CHUNKSIZE];
+ lily_cookie_fprintf (out, "/sfnts [");
+ for (;;)
+ {
+ i = fread (buffer, 1, CHUNKSIZE, fd);
+ if (i == 0)
+ break;
+ lily_cookie_fprintf (out, "\n<");
+ for (j = 0; j < i; j++)
+ {
+ if (j != 0 && j % 36 == 0)
+ lily_cookie_putc ('\n', out);
+ /* lily_cookie_fprintf (out,"%02X",(int)buffer[j]) is too slow */
+ lily_cookie_putc (xdigits[(buffer[j] & 0xF0) >> 4], out);
+ lily_cookie_putc (xdigits[buffer[j] & 0x0F], out);
+ }
+ lily_cookie_fprintf (out, "00>"); /* Adobe bug? */
+ if (i < CHUNKSIZE)
+ break;
+ }
+ lily_cookie_fprintf (out, "\n] def\n");
+ delete[] buffer;
+ fclose (fd);
+}
+
+static void
+print_trailer (void *out,
+ FT_Face face)
+{
+ const int GLYPH_NAME_LEN = 256;
+ char glyph_name[GLYPH_NAME_LEN];
+
+ TT_MaxProfile * mp =
+ (TT_MaxProfile *)FT_Get_Sfnt_Table(face, ft_sfnt_maxp);
+
+ lily_cookie_fprintf (out, "/CharStrings %d dict dup begin\n", mp->numGlyphs);
+ for (int i = 0; i < mp->numGlyphs; i++)
+ {
+ FT_Error error = FT_Get_Glyph_Name (face, i, glyph_name, GLYPH_NAME_LEN);
+
+ if (error)
+ programming_error ("FT_Get_Glyph_Name() returned error");
+ else
+ lily_cookie_fprintf (out, "/%s %d def ", glyph_name, i);
+
+ if (!(i % 5))
+ lily_cookie_fprintf (out, "\n");
+ }
+ lily_cookie_fprintf (out, "end readonly def\n");
+ lily_cookie_fprintf (out, "FontName currentdict end definefont pop\n");
+}
+
+static void
+create_type42_font (void *out, String name)
+{
+ FT_Face face = open_ft_face (name);
+
+ print_header (out, face);
+ print_body (out, name);
+ print_trailer (out, face);
+}
+
+
+LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa",
+ 1, 0, 0, (SCM ttf_file_name),
+ "Convert the contents of a TTF file to Type42 PFA, returning it as "
+ " a string.")
+{
+ SCM_ASSERT_TYPE (scm_is_string (ttf_file_name), ttf_file_name,
+ SCM_ARG1, __FUNCTION__, "string");
+
+ String file_name = ly_scm2string (ttf_file_name);
+ if (be_verbose_global)
+ progress_indication ("[" + file_name);
+
+ Memory_out_stream stream;
+
+ create_type42_font (&stream, file_name);
+ SCM asscm = scm_from_locale_stringn (stream.get_string (),
+ stream.get_length ());
+
+ if (be_verbose_global)
+ progress_indication ("]");
+
+ return asscm;
+}
\InnerChoirStaff
\name ChoirStaff
- \defaultchild "InnerChoirStaff"
+ \defaultchild "Staff"
\accepts "InnerChoirStaff"
\accepts "InnerStaffGroup"
\description "Identical to @code{StaffGroup} except that the
'origin location
'procedure proc))
+musicMap = #(def-music-function (parser location proc mus) (procedure? ly:music?)
+ (music-map proc mus))
+
displayMusic = #(def-music-function (parser location music) (ly:music?)
(display-scheme-music music)
music)
LILYPOND = $(builddir)/lily/$(outconfbase)/lilypond
LILYPOND_BOOK = $(script-dir)/lilypond-book.py
LILYPOND_BOOK_INCLUDES = -I $(pwd) -I $(outdir) -I$(input-dir) -I $(input-dir)/regression/ -I $(input-dir)/test/ -I $(input-dir)/tutorial/ -I $(builddir)/mf/$(outconfbase)/ -I $(builddir)/mf/out/
-LILYPOND_BOOK_FLAGS = --process="$(LILYPOND) --backend=eps --formats=ps,png --header=texidoc -I $(srcdir)/input/test -dinternal-type-checking"
+LILYPOND_BOOK_FLAGS = --process="$(LILYPOND) --backend=eps --formats=ps,png --header=texidoc -I $(srcdir)/input/test -dinternal-type-checking -danti-alias-factor=2 "
#texi-html for www only:
%{_datadir}/lilypond/@TOPLEVEL_VERSION@/
%{_datadir}/locale/*/LC_MESSAGES/lilypond.mo
-%{_libdir}/lilypond/
+# %{_libdir}/lilypond/
%files documentation
# hmm. notdir builds srcdir builds?
$(outdir)/%.png $(outdir)/%.pdf $(outdir)/%.ly $(outdir)/%.ps: $(outdir)/%.ly
- cd $(outdir); $(LILYPOND) --pdf --ps --png -I $(shell pwd)/ $(notdir $<)
+ cd $(outdir); $(LILYPOND) --pdf --png -danti-alias-factor=2 -ddelete-intermediate-files -dno-point-and-click -I $(shell pwd)/ $(notdir $<)
touch $(outdir)/$(basename $(notdir $<)).png
$(outdir)/%.ly: %.ly
$(PE_SCRIPTS): $(buildscript-dir)/gen-emmentaler-scripts.py
$(PYTHON) $< --dir=$(outdir)
+$(outdir)/fonts.cache-1: $(PFA_OTF_FILES) $(PFA_FILES) $(OTF_FILES)
+ cd $(outdir) ; fc-cache .
+
+local-install: install-fc-cache
+
+install-fc-cache:
+ fc-cache $(foreach suff, $(INSTALLATION_OUT_SUFFIXES), $(DESTDIR)$(INSTALLATION_OUT_DIR$(suff)))
ALL_FONTS = $(FETA_FONTS) $(SAUTER_FONTS)
PFA_FILES = $(ALL_FONTS:%=$(outdir)/%.pfa) $(PFA_OTF_FILES)
# Make tfm files first, log files last,
# so that normally log files aren't made twice
-ALL_GEN_FILES= $(TFM_FILES) $(TEXTABLES) $(TFM_FILES) $(LOG_FILES) $(ENC_FILES) $(LISP_FILES) $(FETA_LIST_FILES) $(OTF_TABLES) $(PFA_FILES) $(OTF_FILES) $(SVG_FILES)
+ALL_GEN_FILES= $(TFM_FILES) $(TEXTABLES) $(TFM_FILES) $(LOG_FILES) $(ENC_FILES) $(LISP_FILES) $(FETA_LIST_FILES) $(OTF_TABLES) $(PFA_FILES) $(OTF_FILES) $(SVG_FILES) $(outdir)/fonts.cache-1
#PRE_INSTALL=$(MAKE) "$(ALL_GEN_FILES)"
INSTALLATION_DIR=$(local_lilypond_datadir)/fonts/source
MergeFonts ("feta-alphabet20.pfa");
Generate("aybabtu.otf");
-Generate("aybabtu.cff");
Generate("aybabtu.svg");
SetFontNames("PFAAybabtu-Regular", "PFAAybabtu", "PFAAybabtu Regular", "Regular", "GNU GPL", "@TOPLEVEL_VERSION@");
Generate("PFAaybabtu.pfa");
INSTALLATION_OUT_SUFFIXES=1
INSTALLATION_OUT_FILES=$(OUT_SO_MODULES)
-INSTALLATION_OUT_DIR=$(local_lilypond_libdir)/python
+INSTALLATION_OUT_DIR=$(local_lilypond_datadir)/python
INSTALLATION_OUT_DIR1=$(local_lilypond_datadir)/python
INSTALLATION_OUT_FILES1=$(OUT_PY_MODULES) $(OUT_PYC_MODULES)
--- /dev/null
+import string
+import re
+import sys
+import lilylib
+
+_ = lilylib._
+
+
+NOT_SMART = _ ("Not smart enough to convert %s")
+UPDATE_MANUALLY = _ ("Please refer to the manual for details, and update manually.")
+FROM_TO = _ ( "%s has been replaced by %s")
+
+
+class FatalConversionError:
+ pass
+
+conversions = []
+
+error_file = sys.stderr
+lilypond_version_re_str = '\\\\version *\"([^"]+)\"'
+lilypond_version_re = re.compile (lilypond_version_re_str)
+
+
+
+if 1:
+ def conv(str):
+ if re.search ('\\\\multi', str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "\\multi")
+ error_file.write ('\n')
+ return str
+
+ conversions.append (((0,1,9), conv, '\\header { key = concat + with + operator }'))
+
+if 1:
+ def conv (str):
+ if re.search ('\\\\octave', str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "\\octave")
+ error_file.write ('\n')
+ error_file.write (UPDATE_MANUALLY)
+ error_file.write ('\n')
+ # raise FatalConversionError ()
+
+ return str
+
+ conversions.append ((
+ ((0,1,19), conv, 'deprecated \\octave; cannot convert automatically')))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('\\\\textstyle([^;]+);',
+ '\\\\property Lyrics . textstyle = \\1', str)
+ # harmful to current .lys
+ # str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str)
+
+ return str
+
+ conversions.append ((
+ ((0,1,20), conv, 'deprecated \\textstyle, new \\key syntax')))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str)
+ str = re.sub ('\\\\meter', '\\\\time',str)
+
+ return str
+
+ conversions.append ((
+ ((0,1,21), conv, '\\musical_pitch -> \\musicalpitch, '+
+ '\\meter -> \\time')))
+
+if 1:
+ def conv (str):
+ return str
+
+ conversions.append ((
+ ((1,0,0), conv, '0.1.21 -> 1.0.0 ')))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('\\\\accidentals', '\\\\keysignature',str)
+ str = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str)
+ str = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str)
+
+ return str
+
+ conversions.append ((
+ ((1,0,1), conv, '\\accidentals -> \\keysignature, ' +
+ 'specialaccidentals -> keyoctaviation')))
+
+if 1:
+ def conv(str):
+ if re.search ('\\\\header', str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "new \\header format")
+ error_file.write ('\n')
+ return str
+
+ conversions.append (((1,0,2), conv, '\\header { key = concat + with + operator }'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('\\\\melodic([^a-zA-Z])', '\\\\notes\\1',str)
+ return str
+
+ conversions.append (((1,0,3), conv, '\\melodic -> \\notes'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('default_paper *=', '',str)
+ str = re.sub ('default_midi *=', '',str)
+ return str
+
+ conversions.append (((1,0,4), conv, 'default_{paper,midi}'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('ChoireStaff', 'ChoirStaff',str)
+ str = re.sub ('\\\\output', 'output = ',str)
+
+ return str
+
+ conversions.append (((1,0,5), conv, 'ChoireStaff -> ChoirStaff'))
+
+if 1:
+ def conv(str):
+ if re.search ('[a-zA-Z]+ = *\\translator',str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "\\translator syntax")
+ error_file.write ('\n')
+ # raise FatalConversionError ()
+ return str
+
+ conversions.append (((1,0,6), conv, 'foo = \\translator {\\type .. } ->\\translator {\\type ..; foo; }'))
+
+
+if 1:
+ def conv(str):
+ str = re.sub ('\\\\lyrics*', '\\\\lyrics',str)
+
+ return str
+
+ conversions.append (((1,0,7), conv, '\\lyric -> \\lyrics'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str)
+ str = re.sub ('\\[/3+', '\\\\times 2/3 { [',str)
+ str = re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str)
+ str = re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str)
+ str = re.sub ('\\\\\\]([0-9/]+)', '}', str)
+ str = re.sub ('\\\\\\]', '}',str)
+ str = re.sub ('\\]([0-9/]+)', '] }', str)
+ return str
+
+ conversions.append (((1,0,10), conv, '[2/3 ]1/1 -> \\times 2/3 '))
+
+if 1:
+ def conv(str):
+ return str
+ conversions.append (((1,0,12), conv, 'Chord syntax stuff'))
+
+
+if 1:
+ def conv(str):
+
+
+ str = re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str)
+
+ return str
+
+ conversions.append (((1,0,13), conv, '<a ~ b> c -> <a b> ~ c'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('<\\[','[<', str)
+ str = re.sub ('\\]>','>]', str)
+
+ return str
+
+ conversions.append (((1,0,14), conv, '<[a b> <a b]>c -> [<a b> <a b>]'))
+
+
+if 1:
+ def conv(str):
+ str = re.sub ('\\\\type([^\n]*engraver)','\\\\TYPE\\1', str)
+ str = re.sub ('\\\\type([^\n]*performer)','\\\\TYPE\\1', str)
+ str = re.sub ('\\\\type','\\\\context', str)
+ str = re.sub ('\\\\TYPE','\\\\type', str)
+ str = re.sub ('textstyle','textStyle', str)
+
+ return str
+
+ conversions.append (((1,0,16), conv, '\\type -> \\context, textstyle -> textStyle'))
+
+
+if 1:
+ def conv(str):
+ if re.search ('\\\\repeat',str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "\\repeat")
+ error_file.write ('\n')
+ # raise FatalConversionError ()
+ return str
+
+ conversions.append (((1,0,18), conv,
+ '\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('SkipBars','skipBars', str)
+ str = re.sub ('fontsize','fontSize', str)
+ str = re.sub ('midi_instrument','midiInstrument', str)
+
+ return str
+
+ conversions.append (((1,0,19), conv,
+ 'fontsize -> fontSize, midi_instrument -> midiInstrument, SkipBars -> skipBars'))
+
+
+if 1:
+ def conv(str):
+ str = re.sub ('tieydirection','tieVerticalDirection', str)
+ str = re.sub ('slurydirection','slurVerticalDirection', str)
+ str = re.sub ('ydirection','verticalDirection', str)
+
+ return str
+
+ conversions.append (((1,0,20), conv,
+ '{,tie,slur}ydirection -> {v,tieV,slurV}erticalDirection'))
+
+
+if 1:
+ def conv(str):
+ str = re.sub ('hshift','horizontalNoteShift', str)
+
+ return str
+
+ conversions.append (((1,0,21), conv,
+ 'hshift -> horizontalNoteShift'))
+
+
+if 1:
+ def conv(str):
+ str = re.sub ('\\\\grouping[^;]*;','', str)
+
+ return str
+
+ conversions.append (((1,1,52), conv,
+ 'deprecate \\grouping'))
+
+
+if 1:
+ def conv(str):
+ str = re.sub ('\\\\wheel','\\\\coda', str)
+
+ return str
+
+ conversions.append (((1,1,55), conv,
+ '\\wheel -> \\coda'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('keyoctaviation','keyOctaviation', str)
+ str = re.sub ('slurdash','slurDash', str)
+
+ return str
+
+ conversions.append (((1,1,65), conv,
+ 'slurdash -> slurDash, keyoctaviation -> keyOctaviation'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str)
+
+ return str
+
+ conversions.append (((1,1,66), conv,
+ 'semi -> volta'))
+
+
+if 1:
+ def conv(str):
+ str = re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str)
+
+ return str
+
+ conversions.append (((1,1,67), conv,
+ 'beamAuto -> noAutoBeaming'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('automaticMelismas', 'automaticMelismata', str)
+
+ return str
+
+ conversions.append (((1,2,0), conv,
+ 'automaticMelismas -> automaticMelismata'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('dynamicDir\\b', 'dynamicDirection', str)
+
+ return str
+
+ conversions.append (((1,2,1), conv,
+ 'dynamicDir -> dynamicDirection'))
+
+if 1:
+ def conv(str):
+ str = re.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str)
+ str = re.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str)
+
+ return str
+
+ conversions.append (((1,3,4), conv,
+ '\\cadenza -> \\cadenza{On|Off}'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('"?beamAuto([^"=]+)"? *= *"([0-9]+)/([0-9]+)" *;*',
+ 'beamAuto\\1 = #(make-moment \\2 \\3)',
+ str)
+ return str
+
+ conversions.append (((1,3,5), conv, 'beamAuto moment properties'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('stemStyle',
+ 'flagStyle',
+ str)
+ return str
+
+ conversions.append (((1,3,17), conv, 'stemStyle -> flagStyle'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('staffLineLeading',
+ 'staffSpace',
+ str)
+ return str
+
+ conversions.append (((1,3,18), conv, 'staffLineLeading -> staffSpace'))
+
+
+if 1:
+ def conv(str):
+ if re.search ('\\\\repetitions',str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "\\repetitions")
+ error_file.write ('\n')
+ # raise FatalConversionError ()
+ return str
+
+ conversions.append (((1,3,23), conv,
+ '\\\\repetitions feature dropped'))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('textEmptyDimension *= *##t',
+ 'textNonEmpty = ##f',
+ str)
+ str = re.sub ('textEmptyDimension *= *##f',
+ 'textNonEmpty = ##t',
+ str)
+ return str
+
+ conversions.append (((1,3,35), conv, 'textEmptyDimension -> textNonEmpty'))
+
+if 1:
+ def conv (str):
+ str = re.sub ("([a-z]+)[ \t]*=[ \t]*\\\\musicalpitch *{([- 0-9]+)} *\n",
+ "(\\1 . (\\2))\n", str)
+ str = re.sub ("\\\\musicalpitch *{([0-9 -]+)}",
+ "\\\\musicalpitch #'(\\1)", str)
+ if re.search ('\\\\notenames',str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "new \\notenames format")
+ error_file.write ('\n')
+ return str
+
+ conversions.append (((1,3,38), conv, '\musicalpitch { a b c } -> #\'(a b c)'))
+
+if 1:
+ def conv (str):
+ def replace (match):
+ return '\\key %s;' % string.lower (match.group (1))
+
+ str = re.sub ("\\\\key ([^;]+);", replace, str)
+ return str
+
+ conversions.append (((1,3,39), conv, '\\key A ; ->\\key a;'))
+
+if 1:
+ def conv (str):
+ if re.search ('\\[:',str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "new tremolo format")
+ error_file.write ('\n')
+ return str
+
+ conversions.append (((1,3,41), conv,
+ '[:16 c4 d4 ] -> \\repeat "tremolo" 2 { c16 d16 }'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('Staff_margin_engraver' , 'Instrument_name_engraver', str)
+ return str
+
+ conversions.append (((1,3,42), conv,
+ 'Staff_margin_engraver deprecated, use Instrument_name_engraver'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('note[hH]eadStyle\\s*=\\s*"?(\\w+)"?' , "noteHeadStyle = #'\\1", str)
+ return str
+
+ conversions.append (((1,3,49), conv,
+ 'noteHeadStyle value: string -> symbol'))
+
+if 1:
+ def conv (str):
+ if re.search ('\\\\keysignature', str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "new tremolo format")
+ error_file.write ('\n')
+ return str
+
+
+ conversions.append (((1,3,58), conv,
+ 'noteHeadStyle value: string -> symbol'))
+
+if 1:
+ def conv (str):
+ str = re.sub (r"""\\key *([a-z]+) *;""", r"""\\key \1 \major;""",str);
+ return str
+ conversions.append (((1,3,59), conv,
+ '\key X ; -> \key X major; '))
+
+if 1:
+ def conv (str):
+ str = re.sub (r'latexheaders *= *"\\\\input ',
+ 'latexheaders = "',
+ str)
+ return str
+ conversions.append (((1,3,68), conv, 'latexheaders = "\\input global" -> latexheaders = "global"'))
+
+
+
+
+# TODO: lots of other syntax change should be done here as well
+if 1:
+ def conv (str):
+ str = re.sub ('basicCollisionProperties', 'NoteCollision', str)
+ str = re.sub ('basicVoltaSpannerProperties' , "VoltaBracket", str)
+ str = re.sub ('basicKeyProperties' , "KeySignature", str)
+
+ str = re.sub ('basicClefItemProperties' ,"Clef", str)
+
+
+ str = re.sub ('basicLocalKeyProperties' ,"Accidentals", str)
+ str = re.sub ('basicMarkProperties' ,"Accidentals", str)
+ str = re.sub ('basic([A-Za-z_]+)Properties', '\\1', str)
+
+ str = re.sub ('Repeat_engraver' ,'Volta_engraver', str)
+ return str
+
+ conversions.append (((1,3,92), conv, 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver'))
+
+if 1:
+ def conv (str):
+ # Ugh, but meaning of \stemup changed too
+ # maybe we should do \stemup -> \stemUp\slurUp\tieUp ?
+ str = re.sub ('\\\\stemup', '\\\\stemUp', str)
+ str = re.sub ('\\\\stemdown', '\\\\stemDown', str)
+ str = re.sub ('\\\\stemboth', '\\\\stemBoth', str)
+
+ str = re.sub ('\\\\slurup', '\\\\slurUp', str)
+ str = re.sub ('\\\\slurboth', '\\\\slurBoth', str)
+ str = re.sub ('\\\\slurdown', '\\\\slurDown', str)
+ str = re.sub ('\\\\slurdotted', '\\\\slurDotted', str)
+ str = re.sub ('\\\\slurnormal', '\\\\slurNoDots', str)
+
+ str = re.sub ('\\\\shiftoff', '\\\\shiftOff', str)
+ str = re.sub ('\\\\shifton', '\\\\shiftOn', str)
+ str = re.sub ('\\\\shiftonn', '\\\\shiftOnn', str)
+ str = re.sub ('\\\\shiftonnn', '\\\\shiftOnnn', str)
+
+ str = re.sub ('\\\\onevoice', '\\\\oneVoice', str)
+ str = re.sub ('\\\\voiceone', '\\\\voiceOne', str)
+ str = re.sub ('\\\\voicetwo', '\\\\voiceTwo', str)
+ str = re.sub ('\\\\voicethree', '\\\\voiceThree', str)
+ str = re.sub ('\\\\voicefour', '\\\\voiceFour', str)
+
+ # I don't know exactly when these happened...
+ # ugh, we loose context setting here...
+ str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\stemUp\\\\slurUp\\\\tieUp', str)
+ str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\stemDown\\\\slurDown\\\\tieDown', str)
+ str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\stemBoth\\\\slurBoth\\\\tieBoth', str)
+
+ str = re.sub ('verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #1', str)
+ str = re.sub ('verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #-1', str)
+ str = re.sub ('verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #0', str)
+
+ str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\\\1Up', str)
+ str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str)
+ str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str)
+
+ # (lacks capitalisation slur -> Slur)
+ str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\1 \\\\override #\'direction = #1', str)
+ str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\1 \\override #\'direction = #-1', str)
+ str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\1 \\\\override #\'direction = #0', str)
+
+ ## dynamic..
+ str = re.sub ('\\\\property *[^ .]*[.]?dynamicDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\dynamicUp', str)
+ str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\dynamicDown', str)
+ str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?(0|(\\\\center))"?', '\\\\dynamicBoth', str)
+
+ str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?(0|(""))"?', '\\\\\\1NoDots', str)
+ str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?([1-9]+)"?', '\\\\\\1Dotted', str)
+
+ str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?(0|(""))"?', '\\\\autoBeamOn', str)
+ str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?([1-9]+)"?', '\\\\autoBeamOff', str)
+
+
+
+ return str
+
+ conversions.append (((1,3,93), conv,
+ 'property definiton case (eg. onevoice -> oneVoice)'))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('ChordNames*', 'ChordNames', str)
+ if re.search ('\\\\textscript "[^"]* *"[^"]*"', str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "new \\textscript markup text")
+ error_file.write ('\n')
+
+ str = re.sub ('\\textscript +("[^"]*")', '\\textscript #\\1', str)
+
+ return str
+
+ conversions.append (((1,3,97), conv, 'ChordName -> ChordNames'))
+
+
+# TODO: add lots of these
+
+if 1:
+ def conv (str):
+ str = re.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str)
+ str = re.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str)
+
+ str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str)
+
+ str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str)
+
+ str = re.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str)
+
+ str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str)
+
+ str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str)
+
+ # ugh
+ str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str)
+
+ str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str)
+ return str
+
+ conversions.append (((1,3,98), conv, 'CONTEXT.textStyle -> GROB.#font-style '))
+
+if 1:
+ def conv (str):
+ str = re.sub ('"?beamAutoEnd_([0-9]*)"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end 1 \\1 * *) = \\2', str)
+ str = re.sub ('"?beamAutoBegin_([0-9]*)"? *= *(#\\([^)]*\))', 'autoBeamSettings \\push #\'(begin 1 \\1 * *) = \\2', str)
+ str = re.sub ('"?beamAutoEnd"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end * * * *) = \\1', str)
+ str = re.sub ('"?beamAutoBegin"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(begin * * * *) = \\1', str)
+
+
+ return str
+
+ conversions.append (((1,3,102), conv, 'beamAutoEnd -> autoBeamSettings \\push (end * * * *)'))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('\\\\push', '\\\\override', str)
+ str = re.sub ('\\\\pop', '\\\\revert', str)
+
+ return str
+
+ conversions.append (((1,3,111), conv, '\\push -> \\override, \\pop -> \\revert'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('LyricVoice', 'LyricsVoice', str)
+ # old fix
+ str = re.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str)
+ str = re.sub ('Chord[Nn]ames([ \t\n]+\\\\override)', 'ChordName\\1', str)
+ return str
+
+ conversions.append (((1,3,113), conv, 'LyricVoice -> LyricsVoice'))
+
+def regularize_id (str):
+ s = ''
+ lastx = ''
+ for x in str:
+ if x == '_':
+ lastx = x
+ continue
+ elif x in string.digits:
+ x = chr(ord (x) - ord ('0') +ord ('A'))
+ elif x not in string.letters:
+ x = 'x'
+ elif x in string.lowercase and lastx == '_':
+ x = string.upper (x)
+ s = s + x
+ lastx = x
+ return s
+
+if 1:
+ def conv (str):
+
+ def regularize_dollar_reference (match):
+ return regularize_id (match.group (1))
+ def regularize_assignment (match):
+ return '\n' + regularize_id (match.group (1)) + ' = '
+ str = re.sub ('\$([^\t\n ]+)', regularize_dollar_reference, str)
+ str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str)
+ return str
+
+ conversions.append (((1,3,117), conv, 'identifier names: $!foo_bar_123 -> xfooBarABC'))
+
+
+if 1:
+ def conv (str):
+ def regularize_paper (match):
+ return regularize_id (match.group (1))
+
+ str = re.sub ('(paper_[a-z]+)', regularize_paper, str)
+ str = re.sub ('sustainup', 'sustainUp', str)
+ str = re.sub ('nobreak', 'noBreak', str)
+ str = re.sub ('sustaindown', 'sustainDown', str)
+ str = re.sub ('sostenutoup', 'sostenutoUp', str)
+ str = re.sub ('sostenutodown', 'sostenutoDown', str)
+ str = re.sub ('unachorda', 'unaChorda', str)
+ str = re.sub ('trechorde', 'treChorde', str)
+
+ return str
+
+ conversions.append (((1,3,120), conv, 'paper_xxx -> paperXxxx, pedalup -> pedalUp.'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('drarnChords', 'chordChanges', str)
+ str = re.sub ('\\musicalpitch', '\\pitch', str)
+ return str
+
+ conversions.append (((1,3,122), conv, 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str)
+ return str
+
+ conversions.append (((1,3,136), conv, 'ly-X-elt-property -> ly-X-grob-property'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('point-and-click +#t', 'point-and-click line-column-location', str)
+ return str
+
+ conversions.append (((1,3,138), conv, 'point-and-click argument changed to procedure.'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('followThread', 'followVoice', str)
+ str = re.sub ('Thread.FollowThread', 'Voice.VoiceFollower', str)
+ str = re.sub ('FollowThread', 'VoiceFollower', str)
+ return str
+
+ conversions.append (((1,3,138), conv, 'followThread -> followVoice.'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('font-point-size', 'font-design-size', str)
+ return str
+
+ conversions.append (((1,3,139), conv, 'font-point-size -> font-design-size.'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('([a-zA-Z]*)NoDots', '\\1Solid', str)
+ return str
+
+ conversions.append (((1,3,141), conv, 'xNoDots -> xSolid'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('([Cc])hord([ea])', '\\1ord\\2', str)
+ return str
+
+ conversions.append (((1,3,144), conv, 'Chorda -> Corda'))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('([A-Za-z]+)MinimumVerticalExtent', 'MinimumV@rticalExtent', str)
+ str = re.sub ('([A-Za-z]+)ExtraVerticalExtent', 'ExtraV@rticalExtent', str)
+ str = re.sub ('([A-Za-z]+)VerticalExtent', 'VerticalExtent', str)
+ str = re.sub ('ExtraV@rticalExtent', 'ExtraVerticalExtent', str)
+ str = re.sub ('MinimumV@rticalExtent', 'MinimumVerticalExtent', str)
+ return str
+
+ conversions.append (((1,3,145), conv,
+ 'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('\\\\key[ \t]*;', '\\key \\default;', str)
+ str = re.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str)
+
+ # Make sure groups of more than one ; have space before
+ # them, so that non of them gets removed by next rule
+ str = re.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str)
+
+ # Only remove ; that are not after spaces, # or ;
+ # Otherwise we interfere with Scheme comments,
+ # which is badbadbad.
+ str = re.sub ("([^ \t;#]);", "\\1", str)
+
+ return str
+ conversions.append (((1,3,146), conv, 'semicolons removed'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('default-neutral-direction', 'neutral-direction',str)
+ return str
+ conversions.append (((1,3,147), conv, 'default-neutral-direction -> neutral-direction'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('\(align', '(axis', str)
+ str = re.sub ('\(rows', '(columns', str)
+ return str
+ conversions.append (((1,3,148), conv, '"(align" -> "(axis", "(rows" -> "(columns"'))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('SystemStartDelimiter', 'systemStartDelimiter', str)
+ return str
+ conversions.append (((1,5,33), conv, 'SystemStartDelimiter -> systemStartDelimiter'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('arithmetic-multiplier', 'spacing-increment', str)
+ str = re.sub ('arithmetic-basicspace', 'shortest-duration-space', str)
+ return str
+
+ conversions.append (((1,5,38), conv, 'SystemStartDelimiter -> systemStartDelimiter'))
+
+
+if 1:
+ def conv (str):
+
+ def func(match):
+ break_dict = {
+ "Instrument_name": "instrument-name",
+ "Left_edge_item": "left-edge",
+ "Span_bar": "span-bar",
+ "Breathing_sign": "breathing-sign",
+ "Staff_bar": "staff-bar",
+ "Clef_item": "clef",
+ "Key_item": "key-signature",
+ "Time_signature": "time-signature",
+ "Custos": "custos"
+ }
+ props = match.group (1)
+ for (k,v) in break_dict.items():
+ props = re.sub (k, v, props)
+ return "breakAlignOrder = #'(%s)" % props
+
+ str = re.sub ("breakAlignOrder *= *#'\\(([a-z_\n\tA-Z ]+)\\)",
+ func, str)
+ return str
+
+ # 40 ?
+ conversions.append (((1,5,40), conv, 'breakAlignOrder property names'))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str)
+ str = re.sub ('noAutoBeaming *= *##t', 'autoBeaming = ##f', str)
+ return str
+
+ conversions.append (((1,5,49), conv, 'noAutoBeaming -> autoBeaming'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('tuplet-bracket-visibility', 'bracket-visibility', str)
+ str = re.sub ('tuplet-number-visibility', 'number-visibility', str)
+ return str
+
+ conversions.append (((1,5,52), conv, 'tuplet-X-visibility -> X-visibility'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('Pitch::transpose', 'ly-transpose-pitch', str)
+
+ return str
+
+ conversions.append (((1,5,56), conv, 'Pitch::transpose -> ly-transpose-pitch'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('textNonEmpty *= *##t', "TextScript \\set #'no-spacing-rods = ##f", str)
+ str = re.sub ('textNonEmpty *= *##f', "TextScript \\set #'no-spacing-rods = ##t", str)
+ return str
+
+ conversions.append (((1,5,58), conv, 'deprecate textNonEmpty'))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('MinimumVerticalExtent', 'minimumV@rticalExtent', str)
+ str = re.sub ('minimumVerticalExtent', 'minimumV@rticalExtent', str)
+ str = re.sub ('ExtraVerticalExtent', 'extraV@rticalExtent', str)
+ str = re.sub ('extraVerticalExtent', 'extraV@rticalExtent', str)
+ str = re.sub ('VerticalExtent', 'verticalExtent', str)
+ str = re.sub ('extraV@rticalExtent', 'extraVerticalExtent', str)
+ str = re.sub ('minimumV@rticalExtent', 'minimumVerticalExtent', str)
+ return str
+
+ conversions.append (((1,5,59), conv,
+ 'XxxxVerticalExtent -> xxxVerticalExtent'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('visibility-lambda', 'break-visibility', str)
+ return str
+
+ conversions.append (((1,5,62), conv,
+ 'visibility-lambda -> break-visibility'))
+
+
+if 1:
+ def conv (str):
+ if re.search (r'\addlyrics',str) \
+ and re.search ('automaticMelismata', str) == None:
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "automaticMelismata; turned on by default since 1.5.67.")
+ error_file.write ('\n')
+ raise FatalConversionError ()
+ return str
+
+ conversions.append (((1,5,67), conv,
+ 'automaticMelismata turned on by default'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('ly-set-grob-property([^!])', 'ly-set-grob-property!\1', str)
+ str = re.sub ('ly-set-mus-property([^!])', 'ly-set-mus-property!\1', str)
+ return str
+
+ conversions.append (((1,5,68), conv, 'ly-set-X-property -> ly-set-X-property!'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('extent-X', 'X-extent', str)
+ str = re.sub ('extent-Y', 'Y-extent', str)
+ return str
+
+ conversions.append (((1,5,71), conv, 'extent-[XY] -> [XY]-extent'))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ("""#\(set! +point-and-click +line-column-location\)""",
+ """#(set-point-and-click! \'line-column)""", str)
+ str = re.sub ("""#\(set![ \t]+point-and-click +line-location\)""",
+ '#(set-point-and-click! \'line)', str)
+ str = re.sub ('#\(set! +point-and-click +#f\)',
+ '#(set-point-and-click! \'none)', str)
+ return str
+
+ conversions.append (((1,5,72), conv, 'set! point-and-click -> set-point-and-click!'))
+
+
+if 1:
+ def conv (str):
+ str = re.sub ('flag-style', 'stroke-style', str)
+ str = re.sub (r"""Stem([ ]+)\\override #'style""", r"""Stem \\override #'flag-style""", str);
+ str = re.sub (r"""Stem([ ]+)\\set([ ]+)#'style""", r"""Stem \\set #'flag-style""", str);
+ return str
+
+ conversions.append (((1,6,5), conv, 'Stems: flag-style -> stroke-style; style -> flag-style'))
+
+
+if 1:
+ def subst_req_name (match):
+ return "(make-music-by-name \'%sEvent)" % regularize_id (match.group(1))
+
+ def conv (str):
+ str = re.sub ('\\(ly-make-music *\"([A-Z][a-z_]+)_req\"\\)', subst_req_name, str)
+ str = re.sub ('Request_chord', 'EventChord', str)
+ return str
+
+ conversions.append (((1,7,1), conv, 'ly-make-music foo_bar_req -> make-music-by-name FooBarEvent'))
+
+
+if 1:
+ spanner_subst ={
+ "text" : 'TextSpanEvent',
+ "decrescendo" : 'DecrescendoEvent',
+ "crescendo" : 'CrescendoEvent',
+ "Sustain" : 'SustainPedalEvent',
+ "slur" : 'SlurEvent',
+ "UnaCorda" : 'UnaCordaEvent',
+ "Sostenuto" : 'SostenutoEvent',
+ }
+ def subst_ev_name (match):
+ stype = 'STOP'
+ if re.search ('start', match.group(1)):
+ stype= 'START'
+
+ mtype = spanner_subst[match.group(2)]
+ return "(make-span-event '%s %s)" % (mtype , stype)
+
+ def subst_definition_ev_name(match):
+ return ' = #%s' % subst_ev_name (match)
+ def subst_inline_ev_name (match):
+ s = subst_ev_name (match)
+ return '#(ly-export %s)' % s
+ def subst_csp_definition (match):
+ return ' = #(make-event-chord (list %s))' % subst_ev_name (match)
+ def subst_csp_inline (match):
+ return '#(ly-export (make-event-chord (list %s)))' % subst_ev_name (match)
+
+ def conv (str):
+ str = re.sub (r' *= *\\spanrequest *([^ ]+) *"([^"]+)"', subst_definition_ev_name, str)
+ str = re.sub (r'\\spanrequest *([^ ]+) *"([^"]+)"', subst_inline_ev_name, str)
+ str = re.sub (r' *= *\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_definition, str)
+ str = re.sub (r'\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_inline, str)
+ str = re.sub (r'ly-id ', 'ly-import ', str)
+
+ str = re.sub (r' *= *\\script "([^"]+)"', ' = #(make-articulation "\\1")', str)
+ str = re.sub (r'\\script "([^"]+)"', '#(ly-export (make-articulation "\\1"))', str)
+ return str
+
+ conversions.append (((1,7,2), conv, '\\spanrequest -> #(make-span-event .. ), \script -> #(make-articulation .. )'))
+
+if 1:
+ def conv(str):
+ str = re.sub (r'\(ly-', '(ly:', str)
+
+ changed = [
+ r'duration\?',
+ r'font-metric\?',
+ r'molecule\?',
+ r'moment\?',
+ r'music\?',
+ r'pitch\?',
+ 'make-duration',
+ 'music-duration-length',
+ 'duration-log',
+ 'duration-dotcount',
+ 'intlog2',
+ 'duration-factor',
+ 'transpose-key-alist',
+ 'get-system',
+ 'get-broken-into',
+ 'get-original',
+ 'set-point-and-click!',
+ 'make-moment',
+ 'make-pitch',
+ 'pitch-octave',
+ 'pitch-alteration',
+ 'pitch-notename',
+ 'pitch-semitones',
+ r'pitch<\?',
+ r'dir\?',
+ 'music-duration-compress',
+ 'set-point-and-click!'
+ ]
+
+ origre = r'\b(%s)' % string.join (changed, '|')
+
+ str = re.sub (origre, r'ly:\1',str)
+ str = re.sub ('set-point-and-click!', 'set-point-and-click', str)
+
+ return str
+
+ conversions.append (((1,7,3), conv, 'ly- -> ly:'))
+
+if 1:
+ def conv(str):
+ if re.search ('new-chords-done',str):
+ return str
+
+ str = re.sub (r'<<', '< <', str)
+ str = re.sub (r'>>', '> >', str)
+ return str
+
+ conversions.append (((1,7,4), conv, '<< >> -> < < > >'))
+
+if 1:
+ def conv(str):
+ str = re.sub (r"\\transpose", r"\\transpose c'", str)
+ str = re.sub (r"\\transpose c' *([a-z]+)'", r"\\transpose c \1", str)
+ return str
+ conversions.append (((1,7,5), conv, '\\transpose TO -> \\transpose FROM TO'))
+
+if 1:
+ def conv(str):
+ kws = ['arpeggio',
+ 'sustainDown',
+ 'sustainUp',
+ 'f',
+ 'p',
+ 'pp',
+ 'ppp',
+ 'fp',
+ 'ff',
+ 'mf',
+ 'mp',
+ 'sfz',
+ ]
+
+ origstr = string.join (kws, '|')
+ str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str)
+ return str
+ conversions.append (((1,7,6), conv, 'note\\script -> note-\script'))
+
+
+if 1:
+ def conv(str):
+ str = re.sub (r"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)",
+ r"#(set-chord-name-style \2)", str)
+ str = re.sub (r"\\property *ChordNames *\. *ChordName *\\revert *#'style",
+ r"", str)
+ return str
+ conversions.append (((1,7,10), conv, "\property ChordName #'style -> #(set-chord-name-style 'style)"))
+
+
+
+if 1:
+ def conv(str):
+ str = re.sub (r"ly:transpose-pitch", "ly:pitch-transpose", str)
+
+ return str
+ conversions.append (((1,7,11), conv, "transpose-pitch -> pitch-transpose"))
+
+if 1:
+ def conv(str):
+ str = re.sub (r"ly:get-molecule-extent", "ly:molecule-get-extent", str)
+ str = re.sub (r"ly:set-molecule-extent!", "ly:molecule-set-extent!", str)
+ str = re.sub (r"ly:add-molecule", "ly:molecule-add", str)
+ str = re.sub (r"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str)
+ str = re.sub (r"ly:align-to!", "ly:molecule-align-to!", str)
+
+ return str
+
+ conversions.append (((1,7,13), conv, "ly:XX-molecule-YY -> ly:molecule-XX-YY"))
+
+if 1:
+ def conv(str):
+ str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str )
+ return str
+
+ conversions.append (((1,7,15), conv, "linewidth = -1 -> raggedright = ##t"))
+
+if 1:
+ def conv(str):
+ str = re.sub ("divisiomaior",
+ "divisioMaior", str)
+ str = re.sub ("divisiominima",
+ "divisioMinima", str)
+ str = re.sub ("divisiomaxima",
+ "divisioMaxima", str)
+ return str
+
+ conversions.append (((1,7,16), conv, "divisiomaior -> divisioMaior"))
+
+if 1:
+ def conv(str):
+ str = re.sub ("Skip_req_swallow_translator",
+ "Skip_event_swallow_translator", str)
+ return str
+
+ conversions.append (((1,7,17), conv, "Skip_req -> Skip_event"))
+
+if 1:
+ def conv(str):
+ str = re.sub ("groupOpen",
+ "startGroup", str)
+ str = re.sub ("groupClose",
+ "stopGroup", str)
+ str = re.sub ("#'outer",
+ "#'enclose-bounds", str)
+
+ return str
+
+ conversions.append (((1,7,18), conv,
+ """groupOpen/Close -> start/stopGroup,
+ #'outer -> #'enclose-bounds
+ """))
+
+if 1:
+ def conv(str):
+ if re.search( r'\\GraceContext', str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "GraceContext")
+ error_file.write (FROM_TO \
+ % ("GraceContext", "#(add-to-grace-init .. )"))
+ error_file.write ('\n')
+ error_file.write (UPDATE_MANUALLY)
+ error_file.write ('\n')
+ raise FatalConversionError ()
+
+ str = re.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str)
+ return str
+
+ conversions.append (((1,7,19), conv,"remove GraceContext"))
+
+
+
+if 1:
+ def conv(str):
+ str = re.sub (
+ r"(set|override|revert) *#'type",
+ r"\1 #'style",
+ str)
+ return str
+
+ conversions.append (((1,7,22), conv,"#'type -> #'style"))
+
+if 1:
+ def conv(str):
+ str = re.sub (
+ "barNonAuto *= *##t",
+ "automaticBars = ##f",
+ str)
+ str = re.sub (
+ "barNonAuto *= *##f",
+ "automaticBars = ##t",
+ str)
+ return str
+
+ conversions.append (((1,7,23), conv,"barNonAuto -> automaticBars"))
+
+
+if 1:
+ def conv(str):
+ if re.search( r'-(start|stop)Cluster', str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "Cluster syntax")
+ error_file.write ('\n')
+ error_file.write (UPDATE_MANUALLY)
+ error_file.write ('\n')
+
+ raise FatalConversionError ()
+
+ return str
+
+ conversions.append (((1,7,24), conv,"cluster syntax"))
+
+if 1:
+ def conv(str):
+ str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *",
+ r"\property Staff.pedal\1Style ", str)
+ str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str)
+ return str
+
+ conversions.append (((1,7,28), conv,"new Pedal style syntax"))
+
+
+
+if 1:
+
+ def sub_chord (m):
+ str = m.group(1)
+
+ origstr = '<%s>' % str
+ if re.search (r'\\\\', str):
+ return origstr
+
+ if re.search (r'\\property', str):
+ return origstr
+
+ if re.match (r'^\s*\)?\s*\\[a-zA-Z]+', str):
+ return origstr
+
+ durs = []
+ def sub_durs (m, durs = durs):
+ durs.append(m.group(2))
+ return m.group (1)
+
+ str = re.sub (r"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs, str)
+ dur_str = ''
+
+ for d in durs:
+ if dur_str == '':
+ dur_str = d
+ if dur_str <> d:
+ return '<%s>' % m.group (1)
+
+ pslur_strs = ['']
+ dyns = ['']
+ slur_strs = ['']
+
+ last_str = ''
+ while last_str <> str:
+ last_str = str
+
+ def sub_tremolos (m, slur_strs = slur_strs):
+ tr = m.group (2)
+ if tr not in slur_strs:
+ slur_strs.append (tr)
+ return m.group (1)
+
+ str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)",
+ sub_tremolos, str)
+
+ def sub_dyn_end (m, dyns = dyns):
+ dyns.append (' \!')
+ return ' ' + m.group(2)
+
+ str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str)
+ def sub_slurs(m, slur_strs = slur_strs):
+ if '-)' not in slur_strs:
+ slur_strs.append (')')
+ return m.group(1)
+
+ def sub_p_slurs(m, slur_strs = slur_strs):
+ if '-\)' not in slur_strs:
+ slur_strs.append ('\)')
+ return m.group(1)
+
+ str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str)
+ str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str)
+ def sub_begin_slurs(m, slur_strs = slur_strs):
+ if '-(' not in slur_strs:
+ slur_strs.append ('(')
+ return m.group(1)
+
+ str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(",
+ sub_begin_slurs, str)
+ def sub_begin_p_slurs(m, slur_strs = slur_strs):
+ if '-\(' not in slur_strs:
+ slur_strs.append ('\(')
+ return m.group(1)
+
+ str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(",
+ sub_begin_p_slurs, str)
+
+ def sub_dyns (m, slur_strs = slur_strs):
+ s = m.group(0)
+ if s == '@STARTCRESC@':
+ slur_strs.append ("\\<")
+ elif s == '@STARTDECRESC@':
+ slur_strs.append ("\\>")
+ elif s == r'-?\\!':
+ slur_strs.append ('\\!')
+ return ''
+
+ str = re.sub (r'@STARTCRESC@', sub_dyns, str)
+ str = re.sub (r'-?\\!', sub_dyns, str)
+
+ def sub_articulations (m, slur_strs = slur_strs):
+ a = m.group(1)
+ if a not in slur_strs:
+ slur_strs.append (a)
+ return ''
+
+ str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations,
+ str)
+ str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations,
+ str)
+ str = re.sub (r"([_^-][>_.+|^-])", sub_articulations,
+ str)
+ str = re.sub (r'([_^-]"[^"]+")', sub_articulations,
+ str)
+
+ def sub_pslurs(m, slur_strs = slur_strs):
+ slur_strs.append (' \\)')
+ return m.group(1)
+ str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str)
+
+ ## end of while <>
+
+ suffix = string.join (slur_strs, '') + string.join (pslur_strs,
+ '') \
+ + string.join (dyns, '')
+
+ return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix)
+
+
+
+ def sub_chords (str):
+ simend = '>'
+ simstart = '<'
+ chordstart = '<<'
+ chordend = '>>'
+ marker_str = '%% new-chords-done %%'
+
+ if re.search (marker_str,str):
+ return str
+ str = re.sub ('<<', '@STARTCHORD@', str)
+ str = re.sub ('>>', '@ENDCHORD@', str)
+
+ str = re.sub (r'\\<', '@STARTCRESC@', str)
+ str = re.sub (r'\\>', '@STARTDECRESC@', str)
+ str = re.sub (r'([_^-])>', r'\1@ACCENT@', str)
+ str = re.sub (r'<([^<>{}]+)>', sub_chord, str)
+
+ # add dash: -[, so that [<<a b>> c d] becomes
+ # <<a b>>-[ c d]
+ # and gets skipped by articulation_substitute
+ str = re.sub (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
+ r'\1-[', str)
+ str = re.sub (r'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
+ r'\1-\\!', str)
+
+ str = re.sub (r'<([^?])', r'%s\1' % simstart, str)
+ str = re.sub (r'>([^?])', r'%s\1' % simend, str)
+ str = re.sub ('@STARTCRESC@', r'\\<', str)
+ str = re.sub ('@STARTDECRESC@', r'\\>' ,str)
+ str = re.sub (r'\\context *Voice *@STARTCHORD@',
+ '@STARTCHORD@', str)
+ str = re.sub ('@STARTCHORD@', chordstart, str)
+ str = re.sub ('@ENDCHORD@', chordend, str)
+ str = re.sub (r'@ACCENT@', '>', str)
+ return str
+
+ markup_start = re.compile(r"([-^_]|\\mark)\s*(#\s*'\s*)\(")
+ musicglyph = re.compile(r"\(\s*music\b")
+ columns = re.compile(r"\(\s*columns\b")
+ submarkup_start = re.compile(r"\(\s*([a-zA-Z]+)")
+ leftpar = re.compile(r"\(")
+ rightpar = re.compile(r"\)")
+
+ def text_markup (str):
+ result = ''
+ # Find the beginning of each markup:
+ match = markup_start.search (str)
+ while match:
+ result = result + str[:match.end (1)] + " \markup"
+ str = str[match.end( 2):]
+ # Count matching parentheses to find the end of the
+ # current markup:
+ nesting_level = 0
+ pars = re.finditer(r"[()]",str)
+ for par in pars:
+ if par.group () == '(':
+ nesting_level = nesting_level + 1
+ else:
+ nesting_level = nesting_level - 1
+ if nesting_level == 0:
+ markup_end = par.end ()
+ break
+ # The full markup in old syntax:
+ markup = str[:markup_end]
+ # Modify to new syntax:
+ markup = musicglyph.sub (r"{\\musicglyph", markup)
+ markup = columns.sub (r"{", markup)
+ markup = submarkup_start.sub (r"{\\\1", markup)
+ markup = leftpar.sub ("{", markup)
+ markup = rightpar.sub ("}", markup)
+
+ result = result + markup
+ # Find next markup
+ str = str[markup_end:]
+ match = markup_start.search(str)
+ result = result + str
+ return result
+
+ def articulation_substitute (str):
+ str = re.sub (r"""([^-])\[ *(\\?\)?[a-z]+[,']*[!?]?[0-9:]*\.*)""",
+ r"\1 \2[", str)
+ str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
+ r"\1 \2\\)", str)
+ str = re.sub (r"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
+ r"\1 \2)", str)
+ str = re.sub (r"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
+ r"\1 \2\\!", str)
+ return str
+
+ string_or_scheme = re.compile ('("(?:[^"\\\\]|\\\\.)*")|(#\\s*\'?\\s*\\()')
+
+ # Only apply articulation_substitute () outside strings and
+ # Scheme expressions:
+ def smarter_articulation_subst (str):
+ result = ''
+ # Find the beginning of next string or Scheme expr.:
+ match = string_or_scheme.search (str)
+ while match:
+ # Convert the preceding LilyPond code:
+ previous_chunk = str[:match.start()]
+ result = result + articulation_substitute (previous_chunk)
+ if match.group (1): # Found a string
+ # Copy the string to output:
+ result = result + match.group (1)
+ str = str[match.end(1):]
+ else: # Found a Scheme expression. Count
+ # matching parentheses to find its end
+ str = str[match.start ():]
+ nesting_level = 0
+ pars = re.finditer(r"[()]",str)
+ for par in pars:
+ if par.group () == '(':
+ nesting_level = nesting_level + 1
+ else:
+ nesting_level = nesting_level - 1
+ if nesting_level == 0:
+ scheme_end = par.end ()
+ break
+ # Copy the Scheme expression to output:
+ result = result + str[:scheme_end]
+ str = str[scheme_end:]
+ # Find next string or Scheme expression:
+ match = string_or_scheme.search (str)
+ # Convert the remainder of the file
+ result = result + articulation_substitute (str)
+ return result
+
+ def conv_relative(str):
+ if re.search (r"\\relative", str):
+ str= "#(ly:set-option 'old-relative)\n" + str
+
+ return str
+
+ def conv (str):
+ str = re.sub (r"#'\(\)", "@SCM_EOL@", str)
+ str = conv_relative (str)
+ str = sub_chords (str)
+
+ str = text_markup (str)
+ str = smarter_articulation_subst (str)
+ str = re.sub ("@SCM_EOL@", "#'()", str)
+
+ return str
+
+ conversions.append (((1,9,0), conv, """New relative mode,
+Postfix articulations, new text markup syntax, new chord syntax."""))
+
+if 1:
+ def conv (str):
+ if re.search ("font-style",str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "font-sytle")
+ error_file.write ('\n')
+ error_file.write (UPDATE_MANUALLY)
+ error_file.write ('\n')
+
+ raise FatalConversionError ()
+
+ str = re.sub (r'-\\markup', r'@\\markup', str)
+ str = re.sub (r'-\\', r'\\', str)
+ str = re.sub (r'-\)', ')', str)
+ str = re.sub (r'-\(', '(', str)
+ str = re.sub ('-\[', '[', str)
+ str = re.sub ('-\]', ']', str)
+ str = re.sub ('-~', '~', str)
+ str = re.sub (r'@\\markup', r'-\\markup', str)
+ return str
+
+ conversions.append (((1,9,1), conv, """Remove - before articulation"""))
+if 1:
+ def conv (str):
+ str = re.sub ('ly:set-context-property',
+ 'ly:set-context-property!', str)
+ str = re.sub ('\\\\newcontext', '\\\\new', str)
+ str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)',
+ r'\\grace { \1 }', str)
+ str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}",
+ r"""\\grace {
+ \\property Voice.Stem \\override #'stroke-style = #"grace"
+ \1
+ \\property Voice.Stem \\revert #'stroke-style }
+""", str)
+
+ return str
+
+ conversions.append (((1,9,2), conv, """\\newcontext -> \\new"""))
+
+if 1:
+ def conv (str):
+ str = re.sub ('accacciatura',
+ 'acciaccatura', str)
+
+ if re.search ("context-spec-music", str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "context-spec-music")
+ error_file.write ('\n')
+ error_file.write (UPDATE_MANUALLY)
+ error_file.write ('\n')
+
+ raise FatalConversionError ()
+
+ str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)',
+ "fingeringOrientations = #'(up down left)", str)
+ str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)',
+ "fingeringOrientations = #'(up down right)", str)
+
+ return str
+
+ conversions.append (((1,9,3), conv,
+ """\\acciaccatura misspelling, fingerHorizontalDirection -> fingeringOrientations"""))
+
+
+def conv (str):
+ if re.search ('\\figures', str):
+ error_file.write ("Warning: attempting automatic \\figures conversion. Check results!");
+
+
+ def figures_replace (m):
+ s = m.group (1)
+ s = re.sub ('<', '@FIGOPEN@',s)
+ s = re.sub ('>', '@FIGCLOSE@',s)
+ return '\\figures { %s }' % s
+
+ str = re.sub (r'\\figures[ \t\n]*{([^}]+)}', figures_replace, str)
+ str = re.sub (r'\\<', '@STARTCRESC@', str)
+ str = re.sub (r'\\>', '@STARTDECRESC@', str)
+ str = re.sub (r'([-^_])>', r'\1@ACCENT@', str)
+ str = re.sub (r'<<', '@STARTCHORD@', str)
+ str = re.sub (r'>>', '@ENDCHORD@', str)
+ str = re.sub (r'>', '@ENDSIMUL@', str)
+ str = re.sub (r'<', '@STARTSIMUL@', str)
+ str = re.sub ('@STARTDECRESC@', '\\>', str)
+ str = re.sub ('@STARTCRESC@', '\\<', str)
+ str = re.sub ('@ACCENT@', '>', str)
+ str = re.sub ('@ENDCHORD@', '>', str)
+ str = re.sub ('@STARTCHORD@', '<', str)
+ str = re.sub ('@STARTSIMUL@', '<<', str)
+ str = re.sub ('@ENDSIMUL@', '>>', str)
+ str = re.sub ('@FIGOPEN@', '<', str)
+ str = re.sub ('@FIGCLOSE@', '>', str)
+
+ return str
+
+conversions.append (((1,9,4), conv, 'Swap < > and << >>'))
+
+
+def conv (str):
+ str = re.sub ('HaraKiriVerticalGroup', 'RemoveEmptyVerticalGroup', str)
+
+ return str
+
+conversions.append (((1,9,5), conv, 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup'))
+
+def conv (str):
+ if re.search ("ly:get-font", str) :
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "(ly:-get-font")
+ error_file.write ('\n')
+ error_file.write (FROM_TO \
+ % ("(ly:paper-get-font (ly:grob-get-paper foo) .. )",
+ "(ly:paper-get-font (ly:grob-get-paper foo) .. )"))
+ error_file.write (UPDATE_MANUALLY)
+ error_file.write ('\n')
+ raise FatalConversionError ()
+
+ if re.search ("\\pitch *#", str) :
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "\\pitch")
+ error_file.write ('\n')
+ error_file.write ("Use Scheme code to construct arbitrary note events.")
+ error_file.write ('\n')
+
+ raise FatalConversionError ()
+
+ return str
+
+
+conversions.append (((1,9,6), conv, 'ly:get-font deprecated.'))
+
+def conv (str):
+ def sub_alteration (m):
+ alt = m.group (3)
+ alt = {
+ '-1': 'FLAT',
+ '-2': 'DOUBLE-FLAT',
+ '0': 'NATURAL',
+ '1': 'SHARP',
+ '2': 'DOUBLE-SHARP',
+ }[alt]
+
+ return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2),
+ alt)
+
+ str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
+ sub_alteration, str)
+
+
+ str = re.sub ("ly:verbose", "ly:get-option 'verbose", str)
+
+ m= re.search ("\\\\outputproperty #([^#]+)[\t\n ]*#'([^ ]+)", str)
+ if m:
+ error_file.write (\
+ r"""\outputproperty found,
+Please hand-edit, using
+
+ \applyoutput #(outputproperty-compatibility %s '%s <GROB PROPERTY VALUE>)
+
+as a substitution text.""" % (m.group (1), m.group (2)) )
+ raise FatalConversionError ()
+
+ if re.search ("ly:(make-pitch|pitch-alteration)", str) \
+ or re.search ("keySignature", str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "pitches")
+ error_file.write ('\n')
+ error_file.write (
+"""The alteration field of Scheme pitches was multiplied by 2
+to support quarter tone accidentals. You must update the following constructs by manually:
+
+* calls of ly:make-pitch and ly:pitch-alteration
+* keySignature settings made with \property
+""")
+ raise FatalConversionError ()
+
+ return str
+conversions.append (((1,9,7), conv,
+ '''use symbolic constants for alterations,
+remove \\outputproperty, move ly:verbose into ly:get-option'''))
+
+
+def conv (str):
+ if re.search ("dash-length",str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "dash-length")
+ error_file.write ('\n')
+ error_file.write (FROM_TO % ("dash-length", "dash-fraction"))
+ error_file.write ('\n')
+ error_file.write (UPDATE_MANUALLY)
+ error_file.write ('\n')
+ raise FatalConversionError ()
+ return str
+
+conversions.append (((1,9,8), conv, """dash-length -> dash-fraction"""))
+
+
+def conv (str):
+ def func(match):
+ return "#'font-size = #%d" % (2*string.atoi (match.group (1)))
+
+ str =re.sub (r"#'font-relative-size\s*=\s*#\+?([0-9-]+)", func, str)
+ str =re.sub (r"#'font-family\s*=\s*#'ancient",
+ r"#'font-family = #'music", str)
+
+ return str
+
+conversions.append (((2,1,1), conv, """font-relative-size -> font-size"""))
+
+def conv (str):
+ str =re.sub (r"ly:get-music-length", "ly:music-length", str)
+ return str
+
+conversions.append (((2,1,2), conv, """ly:get-music-length -> ly:music-length"""))
+
+def conv (str):
+ str =re.sub (r"\.\s+stz=", ". instr ", str)
+ return str
+
+conversions.append (((2,1,3), conv, """stanza -> instrument"""))
+
+def conv (str):
+ def func (match):
+ c = match.group (1)
+ b = match.group (2)
+
+ if b == 't':
+ if c == 'Score':
+ return ''
+ else:
+ return r" \property %s.melismaBusyProperties \unset" % c
+ elif b == 'f':
+ return r"\property %s.melismaBusyProperties = #'(melismaBusy)" % c
+
+ str = re.sub (r"\\property ([a-zA-Z]+)\s*\.\s*automaticMelismata\s*=\s*##([ft])", func, str)
+ return str
+
+conversions.append (((2,1,4), conv, """removal of automaticMelismata; use melismaBusyProperties instead."""))
+
+
+
+def conv (str):
+ str =re.sub (r"\\translator\s+([a-zA-Z]+)", r"\\change \1", str)
+ return str
+
+conversions.append (((2,1,7), conv, """\\translator Staff -> \\change Staff"""))
+
+def conv (str):
+ str =re.sub (r"\\newaddlyrics", r"\\lyricsto", str)
+ return str
+
+conversions.append (((2,1,10), conv, """\\newaddlyrics -> \\lyricsto"""))
+
+def conv (str):
+ str = re.sub (r'\\include\s*"paper([0-9]+)(-init)?.ly"',
+ r"#(set-staff-size \1)", str)
+
+ def sub_note (match):
+ dur = ''
+ log = string.atoi (match.group (1))
+ dots = string.atoi (match.group (2))
+
+ if log >= 0:
+ dur = '%d' % (1 << log)
+ else:
+ dur = { -1 : 'breve',
+ -2 : 'longa',
+ -3 : 'maxima'}[log]
+
+ dur += ('.' * dots)
+
+ return r'\note #"%s" #%s' % (dur, match.group (3))
+
+ str = re.sub (r'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
+ sub_note, str)
+ return str
+
+conversions.append (((2,1,11), conv, """\\include "paper16.ly" -> #(set-staff-size 16)
+\\note #3 #1 #1 -> \\note #"8." #1
+"""))
+
+
+def conv (str):
+ str =re.sub (r"OttavaSpanner", r"OttavaBracket", str)
+ return str
+
+conversions.append (((2,1,12), conv, """OttavaSpanner -> OttavaBracket"""))
+
+
+def conv (str):
+ str =re.sub (r"\(set-staff-size ", r"(set-global-staff-size ", str)
+ return str
+
+conversions.append (((2,1,13), conv, """set-staff-size -> set-global-staff-size"""))
+
+def conv (str):
+ str =re.sub (r"#'style\s*=\s*#'dotted-line",
+ r"#'dash-fraction = #0.0 ", str)
+ return str
+
+conversions.append (((2,1,14), conv, """style = dotted -> dash-fraction = 0"""))
+
+def conv (str):
+ str =re.sub (r'LyricsVoice\s*\.\s*instrument\s*=\s*("[^"]*")',
+ r'LyricsVoice . vocalName = \1', str)
+
+ str =re.sub (r'LyricsVoice\s*\.\s*instr\s*=\s*("[^"]*")',
+ r'LyricsVoice . vocNam = \1', str)
+ return str
+
+conversions.append (((2,1,15), conv, """LyricsVoice . instr(ument) -> vocalName"""))
+
+def conv (str):
+ def sub_acc (m):
+ d = {
+ '4': 'doublesharp',
+ '3': 'threeqsharp',
+ '2': 'sharp',
+ '1': 'semisharp',
+ '0': 'natural',
+ '-1': 'semiflat',
+ '-2': 'flat',
+ '-3': 'threeqflat',
+ '-4': 'doubleflat'}
+ return '\\%s' % d[m.group (1)]
+
+ str = re.sub (r'\\musicglyph\s*#"accidentals-([0-9-]+)"',
+ sub_acc, str)
+ return str
+
+conversions.append (((2,1,16), conv, """\\musicglyph #"accidentals-NUM" -> \\sharp/flat/etc."""))
+
+
+def conv (str):
+
+ if re.search (r'\\partcombine', str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "\\partcombine")
+ error_file.write ('\n')
+ error_file.write (UPDATE_MANUALLY)
+ error_file.write ('\n')
+ raise FatalConversionError ()
+
+ # this rule doesn't really work,
+ # too lazy to figure out why.
+ str = re.sub (r'\\context\s+Voice\s*=\s*one\s*\\partcombine\s+Voice\s*\\context\s+Thread\s*=\s*one(.*)\s*'
+ + r'\\context\s+Thread\s*=\s*two',
+ '\\\\newpartcombine\n\\1\n', str)
+
+
+ return str
+
+conversions.append (((2,1,17), conv, """\\partcombine syntax change to \\newpartcombine"""))
+
+
+def conv (str):
+ str = re.sub (r'\\newpartcombine', r'\\partcombine', str)
+ str = re.sub (r'\\autochange\s+Staff', r'\\autochange ', str)
+ return str
+
+conversions.append (((2,1,18), conv, """\\newpartcombine -> \\partcombine,
+\\autochange Staff -> \\autochange
+"""))
+
+
+
+
+def conv (str):
+ str = re.sub (r'\\include "drumpitch-init.ly"','', str)
+ str = re.sub (r'\\pitchnames ','pitchnames = ', str)
+ str = re.sub (r'\\chordmodifiers ','chordmodifiers = ', str)
+ str = re.sub (r'\bdrums\b\s*=','drumContents = ', str)
+ str = re.sub (r'\\drums\b','\\drumContents ', str)
+
+
+ if re.search ('drums->paper', str):
+ error_file.write ("\nDrum notation found. Check file manually!")
+
+ str = re.sub (r"""\\apply\s+#\(drums->paper\s+'([a-z]+)\)""",
+ r"""\property DrumStaff.drumStyleTable = #\1-style""",
+ str)
+
+ if re.search ('Thread', str):
+ error_file.write ("\nThread found. Check file manually!\n");
+
+ str = re.sub (r"""(\\once\s*)?\\property\s+Thread\s*\.\s*NoteHead\s*"""
+ + r"""\\(set|override)\s*#'style\s*=\s*#'harmonic"""
+ + r"""\s+([a-z]+[,'=]*)([0-9]*\.*)"""
+ ,r"""<\3\\harmonic>\4""", str)
+
+ str = re.sub (r"""\\new Thread""", """\context Voice""", str)
+ str = re.sub (r"""Thread""", """Voice""", str)
+
+ if re.search ('\bLyrics\b', str):
+ error_file.write ("\nLyrics found. Check file manually!\n");
+
+ str = re.sub (r"""LyricsVoice""", r"""L@ricsVoice""", str)
+ str = re.sub (r"""\bLyrics\b""", r"""LyricsVoice""", str)
+ str = re.sub (r"""LyricsContext""", r"""LyricsVoiceContext""", str)
+ str = re.sub (r"""L@ricsVoice""", r"""LyricsVoice""",str)
+
+
+ return str
+
+conversions.append (((2,1,19), conv, """Drum notation changes, Removing \\chordmodifiers, \\notenames.
+Harmonic notes. Thread context removed. Lyrics context removed."""))
+
+def conv (str):
+ str = re.sub (r'nonevent-skip', 'skip-music', str)
+ return str
+
+conversions.append (((2,1,20), conv, """nonevent-skip -> skip-music""" ))
+
+def conv (str):
+ str = re.sub (r'molecule-callback', 'print-function', str)
+ str = re.sub (r'brew_molecule', 'print', str)
+ str = re.sub (r'brew-new-markup-molecule', 'Text_item::print', str)
+ str = re.sub (r'LyricsVoice', 'Lyrics', str)
+ str = re.sub (r'tupletInvisible',
+ r"TupletBracket \\set #'transparent", str)
+# str = re.sub (r'molecule', 'collage', str)
+#molecule -> collage
+ str = re.sub (r"\\property\s+[a-zA-Z]+\s*\.\s*[a-zA-Z]+\s*"
+ + r"\\set\s*#'X-extent-callback\s*=\s*#Grob::preset_extent",
+ "", str)
+
+ return str
+
+conversions.append (((2,1,21), conv, """molecule-callback -> print-function,
+brew_molecule -> print
+brew-new-markup-molecule -> Text_item::print
+LyricsVoice -> Lyrics
+tupletInvisible -> TupletBracket \set #'transparent
+Grob::preset_extent removed.
+""" ))
+
+
+def conv (str):
+ str = re.sub (r'(\\property[^=]+)=\s*([-0-9]+)',
+ r'\1= #\2', str)
+ str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\=]+)\s*\\(set|override)',
+ r"\\overrid@ \1.\2 ", str)
+ str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*=\s*',
+ r'\\s@t \1.\2 = ', str)
+ str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\unset',
+ r'\\uns@t \1.\2 ', str)
+ str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\revert'
+ + r"\s*#'([-a-z0-9_]+)",
+ r"\\rev@rt \1.\2 #'\3", str)
+ str = re.sub (r'Voice\.', '', str)
+ str = re.sub (r'Lyrics\.', '', str)
+ str = re.sub (r'ChordNames\.', '', str)
+
+ str = re.sub ('rev@rt', 'revert',str)
+ str = re.sub ('s@t', 'set',str)
+ str = re.sub ('overrid@', 'override',str)
+
+ str = re.sub ('molecule', 'stencil', str)
+ str = re.sub ('Molecule', 'Stencil', str)
+ return str
+
+conversions.append (((2,1,22), conv, """new syntax for property settings:
+ \\set A.B = #C , \\unset A.B
+ \\override A.B #C = #D, \\revert A.B #C
+
+"""))
+
+def conv (str):
+ def subst_in_trans (match):
+ s = match.group (0)
+ s = re.sub (r'\s([a-zA-Z]+)\s*\\override',
+ r' \\override \1', s)
+ s = re.sub (r'\s([a-zA-Z]+)\s*\\set',
+ r' \\override \1', s)
+ s = re.sub (r'\s([a-zA-Z]+)\s*\\revert',
+ r' \\revert \1', s)
+ return s
+ str = re.sub (r'\\(translator|with)\s*{[^}]+}', subst_in_trans, str)
+
+ def sub_abs (m):
+
+ context = m.group ('context')
+ d = m.groupdict ()
+ if context:
+ context = " '%s" % context[:-1] # -1: remove .
+ else:
+ context = ''
+
+ d['context'] = context
+
+ return r"""#(override-auto-beam-setting %(prop)s %(num)s %(den)s%(context)s)""" % d
+
+ str = re.sub (r"""\\override\s*(?P<context>[a-zA-Z]+\s*\.\s*)?autoBeamSettings"""
+ +r"""\s*#(?P<prop>[^=]+)\s*=\s*#\(ly:make-moment\s+(?P<num>\d+)\s+(?P<den>\d)\s*\)""",
+ sub_abs, str)
+
+ return str
+
+conversions.append (((2,1,23), conv, """Property setting syntax in \\translator{ }"""))
+def conv (str):
+ str = re.sub (r'music-list\?', 'ly:music-list?', str)
+ str = re.sub (r'\|\s*~', '~ |', str)
+ return str
+
+conversions.append (((2,1,24), conv, """music-list? -> ly:music-list?"""))
+
+def conv (str):
+ str = re.sub (r'ly:get-spanner-bound', 'ly:spanner-get-bound', str)
+ str = re.sub (r'ly:get-extent', 'ly:grob-extent', str)
+ str = re.sub (r'ly:get-system', 'ly:grob-system', str)
+ str = re.sub (r'ly:get-original', 'ly:grob-original', str)
+ str = re.sub (r'ly:get-parent', 'ly:grob-parent', str)
+ str = re.sub (r'ly:get-broken-into', 'ly:spanner-broken-into', str)
+ str = re.sub (r'Melisma_engraver', 'Melisma_translator', str)
+ if re.search ("ly:get-paper-variable", str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "ly:paper-get-variable")
+ error_file.write ('\n')
+ error_file.write ('use (ly:paper-lookup (ly:grob-paper ))')
+ error_file.write ('\n')
+ raise FatalConversionError ()
+
+ str = re.sub (r'\\defaultAccidentals', "#(set-accidental-style 'default)", str)
+ str = re.sub (r'\\voiceAccidentals', "#(set-accidental-style 'voice)", str)
+ str = re.sub (r'\\modernAccidentals', "#(set-accidental-style 'modern)", str)
+ str = re.sub (r'\\modernCautionaries', "#(set-accidental-style 'modern-cautionary)", str)
+ str = re.sub (r'\\modernVoiceAccidental', "#(set-accidental-style 'modern-voice)", str)
+ str = re.sub (r'\\modernVoiceCautionaries', "#(set-accidental-style 'modern-voice-cautionary)", str)
+ str = re.sub (r'\\pianoAccidentals', "#(set-accidental-style 'piano)", str)
+ str = re.sub (r'\\pianoCautionaries', "#(set-accidental-style 'piano-cautionary)", str)
+ str = re.sub (r'\\forgetAccidentals', "#(set-accidental-style 'forget)", str)
+ str = re.sub (r'\\noResetKey', "#(set-accidental-style 'no-reset)", str)
+
+ return str
+
+conversions.append (((2,1,25), conv, """Scheme grob function renaming"""))
+
+
+def conv (str):
+ str = re.sub ('ly:set-grob-property!', 'ly:grob-set-property!',str)
+ str = re.sub ('ly:set-mus-property!', 'ly:music-set-property!',str)
+ str = re.sub ('ly:set-context-property!', 'ly:context-set-property!', str)
+ str = re.sub ('ly:get-grob-property', 'ly:grob-property',str)
+ str = re.sub ('ly:get-mus-property', 'ly:music-property',str)
+ str = re.sub ('ly:get-context-property', 'ly:context-property',str)
+
+ return str
+
+conversions.append (((2,1,26), conv, """More Scheme function renaming"""))
+
+def conv (str):
+ def subst (m):
+ g = string.atoi (m.group (2))
+ o = g / 12
+ g -= o * 12
+ if g < 0:
+ g += 12
+ o -= 1
+
+
+ lower_pitches = filter (lambda x : x <= g, [0, 2, 4, 5, 7, 9, 11, 12])
+ s = len (lower_pitches) -1
+ a = g - lower_pitches [-1]
+
+
+ print s , lower_pitches, g, a, s
+ str = 'cdefgab' [s]
+ str += ['eses', 'es', '', 'is', 'isis'][a + 2]
+ if o < 0:
+ str += ',' * (-o - 1)
+ elif o >= 0:
+ str += "'" * (o + 1)
+
+ return '\\transposition %s ' % str
+
+
+ str = re.sub (r"\\set ([A-Za-z]+\s*\.\s*)?transposing\s*=\s*#([-0-9]+)",
+ subst, str)
+ return str
+
+conversions.append (((2,1,27), conv, """property transposing -> tuning"""))
+
+def conv (str):
+ str = re.sub (r'make-music-by-name', 'make-music', str)
+ str = re.sub (r"\\override\s+.*Arpeggio\s+#.print-function\s+=\s+\\arpeggioBracket", r"\\arpeggioBracket", str)
+ return str
+
+conversions.append (((2,1,28), conv,
+ """make-music-by-name -> make-music,
+new syntax for setting \\arpeggioBracket"""))
+
+def conv (str):
+ str = re.sub (r'\\center([^-])', '\\center-align\\1', str)
+ str = re.sub (r'\\translator', '\\context', str)
+ return str
+
+conversions.append (((2,1,29), conv,
+ '\\center -> \\center-align, \\translator -> \\context'))
+
+
+def conv (str):
+ str = re.sub (r'\\threeq(flat|sharp)', r'\\sesqui\1', str)
+ str = re.sub (r'ly:stencil-get-extent',
+ 'ly:stencil-extent', str)
+ str = re.sub (r'ly:translator-find',
+ 'ly:context-find', str)
+ str = re.sub ('ly:unset-context-property','ly:context-unset-property',
+ str)
+
+ str = re.sub (r'ly:get-mutable-properties',
+ 'ly:mutable-music-properties',str)
+ str = re.sub (r'centralCPosition',
+ 'middleCPosition',str)
+ return str
+
+conversions.append (((2,1,30), conv,
+ '''\\threeq{flat,sharp} -> \\sesqui{flat,sharp}
+ly:get-mutable-properties -> ly:mutable-music-properties
+centralCPosition -> middleCPosition
+ly:unset-context-property -> ly:context-unset-property
+ly:translator-find -> ly:context-find
+ly:get-stencil-extent -> ly:stencil-extent
+'''))
+
+
+def conv (str):
+ str = re.sub (r'\\alias\s*"?Timing"?', '', str)
+ return str
+
+conversions.append (((2,1,31), conv,
+ '''remove \\alias Timing'''))
+
+def conv (str):
+ str = re.sub (r"(\\set\s+)?(?P<context>(Score\.)?)breakAlignOrder\s*=\s*#'(?P<list>[^\)]+)",
+ r"\n\\override \g<context>BreakAlignment #'break-align-orders = "
+ + "#(make-vector 3 '\g<list>)", str)
+
+ return str
+
+conversions.append (((2,1,33), conv,
+ '''breakAlignOrder -> break-align-orders.'''))
+
+def conv (str):
+ str = re.sub (r"\(set-paper-size",
+ "(set-default-paper-size",str)
+ return str
+
+conversions.append (((2,1,34), conv,
+ '''set-paper-size -> set-default-paper-size.'''))
+
+def conv (str):
+ str = re.sub (r"ly:mutable-music-properties",
+ "ly:music-mutable-properties", str)
+ return str
+
+conversions.append (((2,1, 36), conv,
+ '''ly:mutable-music-properties -> ly:music-mutable-properties'''))
+
+
+
+def conv (str):
+ return str
+
+conversions.append (((2, 2, 0), conv,
+ '''clean up version. '''))
+
+def conv (str):
+ return re.sub (r'\\apply\b', r'\\applymusic', str)
+
+conversions.append (((2, 3, 1), conv,
+ '''\\apply -> \\applymusic'''))
+
+def conv (str):
+ if re.search ('textheight', str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "textheight")
+ error_file.write ('\n')
+ error_file.write (UPDATE_MANUALLY)
+ error_file.write ('\n')
+ error_file.write (
+"""Page layout has been changed, using paper size and margins.
+textheight is no longer used.
+""")
+ str = re.sub (r'\\OrchestralScoreContext', '\\Score', str)
+ def func(m):
+ if m.group(1) not in ['RemoveEmptyStaff',
+ 'AncientRemoveEmptyStaffContext',
+ 'EasyNotation']:
+ return '\\' + m.group (1)
+ else:
+ return m.group (0)
+
+
+ str = re.sub (r'\\([a-zA-Z]+)Context\b', func, str)
+ str = re.sub ('ly:paper-lookup', 'ly:output-def-lookup', str)
+ return str
+
+conversions.append (((2, 3, 2), conv,
+ '''\\FooContext -> \\Foo'''))
+
+def conv (str):
+ str = re.sub (r'\\notes\b', '', str)
+
+ return str
+
+conversions.append (((2, 3, 4), conv,
+ '''remove \\notes'''))
+
+
+
+def conv (str):
+ str = re.sub (r'lastpagefill\s*=\s*"?1"', 'raggedlastbottom = ##t', str)
+ return str
+
+conversions.append (((2, 3, 6), conv,
+ '''lastpagefill -> raggedlastbottom'''))
+
+
+
+def conv (str):
+ str = re.sub (r'\\consistsend', '\\consists', str)
+ str = re.sub (r'\\lyricsto\s+("?[a-zA-Z]+"?)(\s*\\new Lyrics\s*)?\\lyrics',
+ r'\\lyricsto \1 \2', str)
+ return str
+
+conversions.append (((2, 3, 8), conv,
+ '''remove \\consistsend, strip \\lyrics from \\lyricsto.'''))
+
+def conv (str):
+ str = re.sub (r'neo_mensural', 'neomensural', str)
+ str = re.sub (r'if-text-padding', 'bound-padding', str)
+ return str
+
+conversions.append (((2, 3, 9), conv,
+ '''neo_mensural -> neomensural, if-text-padding -> bound-padding'''))
+
+
+
+def conv (str):
+ str = re.sub (r'\\addlyrics', r'\\oldaddlyrics', str)
+ str = re.sub (r'\\newlyrics', r'\\addlyrics', str)
+ if re.search (r"\\override\s*TextSpanner", str):
+ error_file.write ("\nWarning: TextSpanner has been split into DynamicTextSpanner and TextSpanner\n")
+ return str
+
+conversions.append (((2, 3, 10), conv,
+ '''\\addlyrics -> \\oldaddlyrics, \\newlyrics -> \\addlyrics'''))
+
+def conv (str):
+ str = re.sub (r'\\setMmRestFermata\s+(R[0-9.*/]*)',
+ r'\1^\\fermataMarkup', str)
+ return str
+
+conversions.append (((2, 3, 11), conv,
+ '''\\setMmRestFermata -> ^\\fermataMarkup'''))
+
+def conv (str):
+ str = re.sub (r'\\newpage', r'\\pageBreak', str)
+ str = re.sub (r'\\scriptUp', r"""{
+ \\override TextScript #'direction = #1
+ \\override Script #'direction = #1
+}""", str)
+ str = re.sub (r'\\scriptDown', r"""{
+ \\override TextScript #'direction = #-1
+ \\override Script #'direction = #-1
+}""", str)
+ str = re.sub (r'\\scriptBoth', r"""{
+ \\revert TextScript #'direction
+ \\revert Script #'direction
+}""", str)
+ str = re.sub ('soloADue', 'printPartCombineTexts', str)
+ str = re.sub (r'\\applymusic\s*#notes-to-clusters',
+ '\\makeClusters', str)
+
+ str = re.sub (r'pagenumber\s*=', 'firstpagenumber = ', str)
+ return str
+
+conversions.append (((2, 3, 12), conv,
+ '''\\newpage -> \\pageBreak, junk \\script{up,down,both},
+soloADue -> printPartCombineTexts, #notes-to-clusters -> \\makeClusters
+'''))
+
+
+def conv (str):
+ str = re.sub (r'\\chords\b', r'\\chordmode', str)
+ str = re.sub (r'\\lyrics\b', r'\\lyricmode', str)
+ str = re.sub (r'\\figures\b', r'\\figuremode', str)
+ str = re.sub (r'\\notes\b', r'\\notemode', str)
+ str = re.sub (r'\\drums\b', r'\\drummode', str)
+ str = re.sub (r'\\chordmode\s*\\new ChordNames', r'\\chords', str)
+ str = re.sub (r'\\new ChordNames\s*\\chordmode', r'\\chords', str)
+ str = re.sub (r'\\new FiguredBass\s*\\figuremode', r'\\figures', str)
+ str = re.sub (r'\\figuremode\s*\new FiguredBass', r'\\figures', str)
+ str = re.sub (r'\\new DrumStaff\s*\\drummode', r'\\drums', str)
+ str = re.sub (r'\\drummode\s*\\new DrumStaff', r'\\drums', str)
+
+ return str
+
+conversions.append (((2, 3, 16), conv,
+ '''\foo -> \foomode (for chords, notes, etc.)
+fold \new FooContext \foomode into \foo.'''))
+
+def conv (str):
+ str = re.sub (r'(slur|stem|phrasingSlur|tie|dynamic|dots|tuplet|arpeggio|)Both', r'\1Neutral', str)
+ str = re.sub (r"\\applymusic\s*#\(remove-tag\s*'([a-z-0-9]+)\)",
+ r"\\removeWithTag #'\1", str)
+ return str
+
+conversions.append (((2, 3, 17), conv,
+ '''\foo -> \foomode (for chords, notes, etc.)
+fold \new FooContext \foomode into \foo.'''))
+
+
+def conv (str):
+ str = re.sub (r'Text_item', 'Text_interface', str)
+ return str
+
+conversions.append (((2, 3, 18),
+ conv,
+ '''Text_item -> Text_interface''' ))
+
+def conv (str):
+ str = re.sub (r'\\paper', r'\\layout', str)
+ str = re.sub (r'\\bookpaper', r'\\paper', str)
+ if re.search ('paper-set-staff-size', str):
+ error_file.write ('''\nWarning: staff size should be changed at top-level
+with
+
+ #(set-global-staff-size <STAFF-HEIGHT-IN-POINT>)
+
+''')
+
+
+ str = re.sub (r'#\(paper-set-staff-size', '%Use set-global-staff-size at toplevel\n% #(layout-set-staff-size', str)
+ return str
+
+conversions.append (((2, 3, 22),
+ conv,
+ '''paper -> layout
+ bookpaper -> paper''' ))
+
+
+def conv (str):
+ str = re.sub (r'\\context\s+([a-zA-Z]+)\s*=\s*([a-z]+)\s',
+ r'\\context \1 = "\2" ',
+ str )
+ return str
+
+conversions.append (((2, 3, 23),
+ conv,
+ '''\context Foo = NOTENAME -> \context Foo = "NOTENAME"'''))
+
+def conv (str):
+ def sub(m):
+ return regularize_id (m.group (1))
+ str = re.sub (r'(maintainer_email|maintainer_web|midi_stuff|gourlay_maxmeasures)',
+ sub, str)
+ return str
+
+conversions.append (((2, 3, 24),
+ conv,
+ '''regularize other identifiers.'''))
+
+
+def conv (str):
+ return str
+
+conversions.append (((2, 4, 0),
+ conv,
+ ''))
+
+
+def conv (str):
+ str = re.sub (r'\\quote\s+"?([a-zA-Z0-9]+)"?\s+([0-9.*/]+)',
+ r'\\quoteDuring #"\1" { \skip \2 }',
+ str
+ )
+ return str
+
+conversions.append (((2, 5, 0),
+ conv,
+ ''))
+
+
+def conv (str):
+ str = re.sub (r'ly:import-module',
+ r'ly:module-copy', str)
+ return str
+
+conversions.append (((2, 5, 1),
+ conv,
+ 'ly:import-module -> ly:module-copy'))
+
+def conv (str):
+ str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
+ r'\\\1 {\2}', str)
+ str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
+ r'\\\1 {\2}', str)
+ str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
+ r'\\\1 {\2}', str)
+ def get_markup (m):
+ s = m.group (0)
+ s = re.sub (r'''((\\"|})\s*){''', '\2 \\line {', s)
+ return s
+ str = re.sub (r'\\markup\s*{([^}]|{[^}]*})*}', get_markup, str)
+ return str
+
+conversions.append (((2, 5, 2),
+ conv,
+ '\markup .. < .. > .. -> \markup .. { .. } ..'))
+
+def conv (str):
+ str = re.sub ('ly:find-glyph-by-name', 'ly:font-get-glyph', str)
+ str = re.sub ('"(scripts|clefs|accidentals)-', r'"\1.', str)
+ str = re.sub ("'hufnagel-do-fa", "'hufnagel.do.fa", str)
+ str = re.sub ("'(vaticana|hufnagel|medicaea|petrucci|neomensural|mensural)-", r"'\1.", str)
+ return str
+
+conversions.append (((2, 5, 3),
+ conv,
+ 'ly:find-glyph-by-name -> ly:font-get-glyph, remove - from glyphnames.'))
+
+
+def conv (str):
+ str = re.sub (r"\\override\s+(Voice\.)?Slur #'dashed\s*=\s*#\d*(\.\d+)?",
+ r"\\slurDashed", str)
+ return str
+
+conversions.append (((2, 5, 12),
+ conv,
+ '\set Slur #\'dashed = #X -> \slurDashed'))
+
+def conv (str):
+ input_encoding = 'latin1'
+ def func (match):
+ encoding = match.group (1)
+
+ # FIXME: automatic recoding of other than latin1?
+ if encoding == 'latin1':
+ return match.group (2)
+
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % ("\\encoding: %s" % encoding))
+ error_file.write ('\n')
+ error_file.write (_ ("LilyPond source must be UTF-8"))
+ error_file.write ('\n')
+ if encoding == 'TeX':
+ error_file.write (_ ("Try the texstrings backend"))
+ error_file.write ('\n')
+ else:
+ error_file.write ( _("Do something like: %s") % \
+ ("recode %s..utf-8 FILE" % encoding))
+ error_file.write ('\n')
+ error_file.write (_ ("Or save as UTF-8 in your editor"))
+ error_file.write ('\n')
+ raise FatalConversionError ()
+
+ return match.group (0)
+
+ str = re.sub (r'\\encoding\s+"?([a-zA-Z0-9]+)"?(\s+)', func, str)
+
+ import codecs
+ de_ascii = codecs.getdecoder ('ascii')
+ de_utf_8 = codecs.getdecoder ('utf_8')
+ de_input = codecs.getdecoder (input_encoding)
+ en_utf_8 = codecs.getencoder ('utf_8')
+ try:
+ de_ascii (str)
+ # only in python >= 2.3
+ # except UnicodeDecodeError:
+ except UnicodeError:
+ # do not re-recode UTF-8 input
+ try:
+ de_utf_8 (str)
+ #except UnicodeDecodeError:
+ except UnicodeError:
+ str = en_utf_8 (de_input (str)[0])[0]
+
+
+
+ str = re.sub (r"#\(ly:set-point-and-click '[a-z-]+\)", '', str)
+ return str
+
+conversions.append (((2, 5, 13),
+ conv,
+ '\\encoding: smart recode latin1..utf-8. Remove ly:point-and-click'))
+
+
+def conv (str):
+ if re.search ("ly:stencil-set-extent!", str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "ly:stencil-set-extent!")
+ error_file.write ('\n')
+ error_file.write ('use (set! VAR (ly:make-stencil (ly:stencil-expr VAR) X-EXT Y-EXT))\n')
+ raise FatalConversionError ()
+ if re.search ("ly:stencil-align-to!", str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "ly:stencil-align-to!")
+ error_file.write ('\n')
+ error_file.write ('use (set! VAR (ly:stencil-aligned-to VAR AXIS DIR))\n')
+ raise FatalConversionError ()
+ return str
+
+conversions.append (((2, 5, 17),
+ conv,
+ 'ly:stencil-set-extent! removed'))
+
+def conv (str):
+ str = re.sub (r"ly:warn\b", 'ly:warning', str)
+ return str
+
+conversions.append (((2, 5, 18),
+ conv,
+ 'ly:warn -> ly:warning'))
+def conv (str):
+ if re.search ("(override-|revert-)auto-beam-setting", str)\
+ or re.search ("autoBeamSettings", str):
+ error_file.write ('\n')
+ error_file.write (NOT_SMART % "auto beam settings")
+ error_file.write ('\n')
+ error_file.write ('''
+Auto beam settings must now specify each interesting moment in a measure
+explicitely; 1/4 is no longer multiplied to cover moments 1/2 and 3/4 too.
+''')
+ error_file.write (UPDATE_MANUALLY)
+ error_file.write ('\n')
+ raise FatalConversionError ()
+ return str
+
+conversions.append (((2, 5, 21),
+ conv,
+ 'warn about auto beam settings'))
+
+def conv (str):
+ str = re.sub (r"unfoldrepeats", 'unfoldRepeats', str)
+ str = re.sub (r"compressmusic", 'compressMusic', str)
+ return str
+
+conversions.append (((2, 5, 25), conv,
+
+ 'unfoldrepeats -> unfoldRepeats,'
+ + 'compressmusic -> compressMusic'))
+
+################################################################
+
+def str_to_tuple (s):
+ return tuple (map (string.atoi, string.split (s, '.')))
+
+def tup_to_str (t):
+ return string.join (map (lambda x: '%s' % x, list (t)), '.')
+
+def version_cmp (t1, t2):
+ for x in [0, 1, 2]:
+ if t1[x] - t2[x]:
+ return t1[x] - t2[x]
+ return 0
+
+def get_conversions (from_version, to_version):
+ def is_applicable (v, f = from_version, t = to_version):
+ return version_cmp (v[0], f) > 0 and version_cmp (v[0], t) <= 0
+ return filter (is_applicable, conversions)
+
+def latest_version ():
+ return conversions[-1][0]
+
+def show_rules (file, from_version, to_version):
+ for x in conversions:
+ if (not from_version or x[0] > from_version) \
+ and (not to_version or x[0] <= to_version):
+ file.write ('%s: %s\n' % (tup_to_str (x[0]), x[2]))
+
+
+def do_conversion (str, from_version, to_version):
+
+ """Apply conversions from FROM_VERSION to TO_VERSION. Return
+tuple (LAST,STR), with the last succesful conversion and the resulting
+string."""
+
+
+ conv_list = get_conversions (from_version, to_version)
+
+ if error_file:
+ error_file.write (_ ("Applying conversion: "))
+
+ last_conversion = ()
+ try:
+ for x in conv_list:
+ error_file.write (tup_to_str (x[0]))
+ if x != conv_list[-1]:
+ error_file.write (', ')
+ str = x[1] (str)
+ last_conversion = x[0]
+
+ except FatalConversionError:
+ error_file.write (_ ("%s: error while converting") \
+ % program_name)
+ error_file.write ('\n')
+ error_file.write (_ ("Aborting"))
+ error_file.write ('\n')
+
+
+
+ return (last_conversion, str)
+
))
(use-modules (scm ps-to-png))
+
(define-public (postscript->png resolution paper-size-name name)
;; Do not try to guess the name of the png file,
;; GS produces PNG files like BASE-page%d.png.
(verbose (ly:get-option 'verbose))
(rename-page-1 #f))
(ly:message (_ "Converting to ~a...") "PNG")
- (make-ps-images name resolution paper-size rename-page-1 verbose)
+ (make-ps-images name resolution paper-size rename-page-1 verbose
+ (ly:get-option 'anti-alias-factor))
(ly:progress "\n")))
(define-public (postprocess-output paper-book module filename formats)
(if (ly:get-option 'delete-intermediate-files)
(for-each
(lambda (f)
- (display (string-append base "." f))
- (display "del\n")
(delete-file (string-append base "." f)))
intermediate))
))
(font-series . bold)
(meta . ((interfaces
. (rhythmic-head-interface
- font-interface
+ font-interface
note-head-interface staff-symbol-referencer-interface
text-interface item-interface ))))
))
(define editor-command-template-alist
'(("emacs" . "emacsclient --no-wait +%(line)s:%(column)s %(file)s || (emacs +%(line)s:%(column)s %(file)s&)")
- ("gvim" . "gvim --remote +:%(line)s:norm%(column)s %(file)s")
- ("uedit32" . "uedit32 %(file)s -l%(line)s -c%(column)s")
+ ("gvim" . "gvim --remote +:%(line)s:norm%(char)s %(file)s")
+ ("uedit32" . "uedit32 %(file)s -l%(line)s -c%(char)s")
("nedit" . "nc -noask +%(line)s %(file)s")
("gedit" . "gedit +%(line)s %(file)s")
("jedit" . "jedit -reuseview %(file)s +line:%(line)s")
- ("syn" . "syn -line %(line)s -col %(column)s %(file)s")
- ("lilypad" . "lilypad +%(line)s:%(column)s %(file)s")))
+ ("syn" . "syn -line %(line)s -col %(char)s %(file)s")
+ ("lilypad" . "lilypad +%(line)s:%(char)s %(file)s")))
(define (get-command-template alist editor)
(define (get-command-template-helper)
(command
(re-sub "%\\(file\\)s" (format #f "~S" file-name)
(re-sub "%\\(line\\)s" (format #f "~a" line)
- (re-sub "%\\(column\\)s" (format #f "~a" column)
- (slashify template))))))
+ (re-sub "%\\(char\\)s" (format #f "~a" char)
+ (re-sub
+ "%\\(column\\)s" (format #f "~a" column)
+ (slashify template)))))))
command))
(srfi srfi-13)
(lily))
+
(define framework-ps-module (current-module))
;;(define pdebug stderr)
((dir-name (tmpnam))
(files '())
(status 0)
- (embed ""))
+ (embed #f))
- (display (list filename name))
(mkdir dir-name #o700)
- (set! status (system
- (format "cd ~a && fondu -force ~a" dir-name filename)))
-
- (if (!= status 0)
- (ly:error "Fondu failed."))
+ (set! status (ly:system
+ (format "cd ~a && fondu -force '~a'" dir-name filename)))
(set! files (dir-listing dir-name))
(for-each
(lambda (f)
- (if (string-match (string-append name "\\.") f)
+ (if (and (not embed)
+ (string-match (string-append name "\\.") f))
(set! embed
(font-file-as-ps-string name (path-join dir-name f))))
(delete-file (path-join dir-name f))))
files)
(rmdir dir-name)
+
+ (if (not embed)
+ (begin
+ (set! embed "% failed \n")
+ (ly:warn (_ "Couldn't extract file matching ~a from ~a") name filename)))
embed))
(define (font-file-as-ps-string name file-name)
+ (let*
+ ((downcase-file-name (string-downcase file-name)))
+
(cond
- ((and file-name (string-match "\\.pfa" file-name))
+ ((and file-name (string-match "\\.pfa" downcase-file-name))
(cached-file-contents file-name))
- ((and file-name (string-match "\\.pfb" file-name))
+ ((and file-name (string-match "\\.pfb" downcase-file-name))
(ly:pfb->pfa file-name))
- ((and file-name (string-match "\\.ttf" file-name))
+ ((and file-name (string-match "\\.ttf" downcase-file-name))
(ly:ttf->pfa file-name))
- ((and file-name (string-match "\\.otf" file-name))
+ ((and file-name (string-match "\\.otf" downcase-file-name))
(ps-embed-cff (ly:otf->cff file-name) name 0))
- ((and file-name (string-match "\\.ttf" file-name))
- (ly:ttf->pfa file-name))
(else
(ly:warning (_ "don't know how to embed ~S=~S") name file-name)
"")
- ))
+ )))
(define (load-font font-name-filename)
(let* ((font (car font-name-filename))
(define-public (convert-to-ps book name)
#t)
+
+(define-public (output-classic-framework basename book scopes fields)
+
+ (ly:error (_ "\nThe PostScript backend does not support the 'classic'
+framework. Use the EPS backend instead,
+
+ lilypond -b eps <file>
+
+or remove the lilypond-book specific settings from the input.
+")))
(old-relative #f
"relative for simultaneous music works
similar to chord syntax")
- (resolution 90 "resolution for generating bitmaps")
+
+ (resolution 101 "resolution for generating bitmaps")
+ (anti-alias-factor 1 "render at higher resolution and scale down result\nto prevent jaggies in PNG")
(preview-include-book-title #t "include book-titles in preview images.")
(gs-font-load #f
"load fonts via Ghostscript.")
;; The TabNoteHead tablatureFormat callback.
;; Compute the text grob-property
(define-public (fret-number-tablature-format string tuning pitch)
- (number->string
- (- (ly:pitch-semitones pitch)
- (list-ref tuning
- ;; remove 1 because list index starts at 0 and guitar string at 1.
- (- string 1)))))
+ (make-whiteout-markup
+ (make-vcenter-markup
+ (number->string
+ (- (ly:pitch-semitones pitch)
+ (list-ref tuning
+ ;; remove 1 because list index starts at 0 and guitar string at 1.
+ (- string 1)))))))
;; The 5-string banjo has got a extra string, the fifth (duh), wich
;; starts at the fifth fret on the neck. Frets on the fifth string
;; on the banjo neck.
;; We solve this by defining a new fret-number-tablature function:
(define-public (fret-number-tablature-format-banjo string tuning pitch)
+ (make-whiteout-markup
+ (make-vcenter-markup
(let ((fret (- (ly:pitch-semitones pitch) (list-ref tuning (- string 1)))))
- (number->string (cond
- ((and (> fret 0) (= string 5))
- (+ fret 5))
- (else fret)))))
+ (number->string (cond
+ ((and (> fret 0) (= string 5))
+ (+ fret 5))
+ (else fret)))))))
(define-public (hammer-print-function grob)
(let* ((note-collums (ly:grob-property grob 'note-columns))
"c = close"
(format #f "</~S>\n" entity))
+
+(define-public (setcolor r g b))
+
+(define-public (resetcolor))
+
+
(define-public (entity entity string . attributes-alist)
(if (equal? string "")
(apply eoc entity attributes-alist)
(map (lambda (x) (string->number (car x))) (vector->list m)))
#f)))
+
+;; copy of ly:system. ly:* not available via lilypond-ps2png.scm
+(define (my-system be-verbose exit-on-error cmd)
+ (define status 0)
+ (if be-verbose
+ (begin
+ (format (current-error-port) (_ "Invoking `~a'...") cmd)
+ (newline (current-error-port))))
+
+
+ (set! status (system cmd))
+
+ (if (not (= status 0))
+ (begin
+ (format (current-error-port)
+ (format #f (_ "~a exited with status: ~S") "GS" status))
+ (if exit-on-error
+ (exit 1))))
+
+ status)
+
+(define (scale-down-image be-verbose factor file)
+ (let* ((status 0)
+ (percentage (* 100 (/ 1.0 factor)))
+ (old (string-append file ".old")))
+
+ (rename-file file old)
+ (my-system be-verbose
+ #t
+ (format #f "convert -scale \"~a%\" ~a ~a" percentage old file))
+ (delete-file old)
+ ))
+
(define-public (make-ps-images ps-name . rest)
(let-optional
rest ((resolution 90)
(paper-size "a4")
(rename-page-1? #f)
- (verbose? #f))
+ (verbose? #f)
+ (aa-factor 1)
+ )
+
(let* ((base (basename (re-sub "[.]e?ps" "" ps-name)))
(header (gulp-port (open-file ps-name "r") 10240))
(png1 (string-append base ".png"))
(output-file (if multi-page? pngn png1))
;;png16m is because Lily produces color nowadays.
- (cmd (if multi-page?
- (format #f "~a\
+ (gs-variable-options
+ (if multi-page?
+ (format #f "-sPAPERSIZE=~a" paper-size)
+ "-dEPSCrop"))
+ (cmd (format #f "~a\
~a\
- -dGraphicsAlphaBits=4\
- -dNOPAUSE\
- -dTextAlphaBits=4\
- -sDEVICE=png16m\
- -sOutputFile='~a'\
- -sPAPERSIZE=~a\
- -r~S\
- '~a'\
- -c showpage\
- -c quit"
- (search-gs)
- (if verbose? "" "-q")
- output-file paper-size resolution ps-name)
- (format #f "~a\
~a\
- -s\
-dGraphicsAlphaBits=4\
- -dEPSCrop\
- -dNOPAUSE\
-dTextAlphaBits=4\
+ -dNOPAUSE\
-sDEVICE=png16m\
- -sOutputFile='~a'\
+ -sOutputFile=~S\
-r~S\
- '~a'\
+ ~S\
-c quit"
(search-gs)
(if verbose? "" "-q")
- output-file resolution ps-name)))
- (foo (for-each delete-file (append (dir-re "." png1)
- (dir-re "." pngn-re))))
- (bar (if verbose?
- (begin
- (format (current-error-port) (_ "Invoking `~a'...") cmd)
- (newline (current-error-port)))))
- (baz
- ;; The wrapper on windows cannot handle `=' signs,
- ;; gs has a workaround with #.
- (if (eq? PLATFORM 'windows)
- (begin
- (set! cmd (re-sub "=" "#" cmd))
- (set! cmd (re-sub "-dSAFER " "" cmd)))))
- (status (system cmd)))
- (if (not (= status 0))
+ gs-variable-options
+ output-file
+ (* aa-factor resolution) ps-name))
+ (status 0)
+ (files '()))
+
+ (for-each delete-file (append (dir-re "." png1)
+ (dir-re "." pngn-re)))
+
+ ;; The wrapper on windows cannot handle `=' signs,
+ ;; gs has a workaround with #.
+ (if (eq? PLATFORM 'windows)
(begin
- (map delete-file
- (append (dir-re "." png1) (dir-re "." pngn-re)))
- (format (current-error-port)
- (format #f (_ "~a exited with status: ~S") "GS" status))
+ (set! cmd (re-sub "=" "#" cmd))
+ (set! cmd (re-sub "-dSAFER " "" cmd))))
+
+ (set! status (my-system verbose? #f cmd))
+
+ (set! files
+ (append (dir-re "." png1) (dir-re "." pngn-re)))
+
+ (if (not (= 0 status))
+ (begin
+ (map delete-file files)
(exit 1)))
+
(if (and rename-page-1? multi-page?)
(rename-file (re-sub "%d" "1" pngn) png1))
- (append (dir-re "." png1) (dir-re "." pngn-re)))))
+
+ (set! files
+ (append (dir-re "." png1) (dir-re "." pngn-re)))
+
+
+ (if (not (= 1 aa-factor))
+ (for-each (lambda (f) (scale-down-image verbose? aa-factor f))
+ files))
+
+ files)))
import sys
import __main__
import getopt
-import string
-import re
-import time
+import string
-localedir = '@localedir@'
-try:
- import gettext
- gettext.bindtextdomain ('lilypond', localedir)
- gettext.textdomain ('lilypond')
- _ = gettext.gettext
-except:
- def _ (s):
- return s
-underscore = _
+datadir = '@local_lilypond_datadir@'
+if not os.path.isdir (datadir):
+ datadir = '@lilypond_datadir@'
+if os.environ.has_key ('LILYPONDPREFIX'):
+ datadir = os.environ['LILYPONDPREFIX']
+ while datadir[-1] == os.sep:
+ datadir= datadir[:-1]
-program_name = os.path.basename (sys.argv[0])
-version = '@TOPLEVEL_VERSION@'
-
-FROM_TO = _ ( "%s has been replaced by %s")
-NOT_SMART = _ ("Not smart enough to convert %s")
-UPDATE_MANUALLY = _ ("Please refer to the manual for details, and update manually.")
-
-# Did we ever have \mudela-version? I doubt it.
-# lilypond_version_re_str = '\\\\version *\"(.*)\"'
-lilypond_version_re_str = '\\\\(mudela-)?version *\"([^"]+)\"'
-lilypond_version_re = re.compile (lilypond_version_re_str)
-add_version = 1
-
-
-def program_id ():
- return '%s (GNU LilyPond) %s' % (program_name, version)
-
-def identify ():
- sys.stderr.write (program_id () + '\n')
-
-def usage ():
- sys.stdout.write (_ ("Usage: %s [OPTION]... [FILE]..." \
- % program_name))
- sys.stdout.write ('\n\n')
- sys.stdout.write (_ ("""\
-Update LilyPond input to newer version. By default, update from the
-version taken from the \\version command, to the current LilyPond version."""))
- sys.stdout.write ('\n\n')
- sys.stdout.write (_ ("Options:"))
- sys.stdout.write ('\n')
- sys.stdout.write (_ ("""\
- -e, --edit edit in place
- -f, --from=VERSION start from VERSION [default: \\version found in file]
- -h, --help print this help
- -n, --no-version do not add \\version command if missing
- -s, --show-rules print rules [default: --from=0, --to=@TOPLEVEL_VERSION@]
- -t, --to=VERSION convert to VERSION [default: @TOPLEVEL_VERSION@]
- -v, --version print program version"""))
- sys.stdout.write ('\n\n')
- sys.stdout.write (_ ('Examples'))
- sys.stdout.write ('\n')
- sys.stdout.write (' convert-ly -e *ly')
- sys.stdout.write ('\n')
- sys.stdout.write (' convert-ly --from=2.4.0 -e $(find . -name "*ly")')
- sys.stdout.write ('\n\n')
- sys.stdout.write (_ ("Report bugs to %s.") % "bug-lilypond@gnu.org")
- sys.stdout.write ('\n')
- sys.exit (0)
-
-def print_version ():
- sys.stdout.write (program_id ())
- sys.stdout.write ('\n')
- sys.stdout.write (_ ("""\
-This program is free software. It is covered by the GNU General Public
-License and you are welcome to change it and/or distribute copies of it
-under certain conditions. Invoke as `%s --warranty' for more
-information.
-""") % "lilypond")
-
-def str_to_tuple (s):
- return tuple (map (string.atoi, string.split (s, '.')))
-
-def tup_to_str (t):
- return string.join (map (lambda x: '%s' % x, list (t)), '.')
-
-def version_cmp (t1, t2):
- for x in [0, 1, 2]:
- if t1[x] - t2[x]:
- return t1[x] - t2[x]
- return 0
-
-def guess_lilypond_version (filename):
- s = open (filename).read ()
- m = lilypond_version_re.search (s)
- if m:
- return m.group (2)
- else:
- return ''
-
-class FatalConversionError:
- pass
-
-conversions = []
-
-def show_rules (file):
- for x in conversions:
- if (not from_version or x[0] > from_version) \
- and (not to_version or x[0] <= to_version):
- file.write ('%s: %s\n' % (tup_to_str (x[0]), x[2]))
-
-############################
-
-if 1:
- def conv(str):
- if re.search ('\\\\multi', str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "\\multi")
- sys.stderr.write ('\n')
- return str
-
- conversions.append (((0,1,9), conv, '\\header { key = concat + with + operator }'))
-
-if 1:
- def conv (str):
- if re.search ('\\\\octave', str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "\\octave")
- sys.stderr.write ('\n')
- sys.stderr.write (UPDATE_MANUALLY)
- sys.stderr.write ('\n')
- # raise FatalConversionError ()
-
- return str
-
- conversions.append ((
- ((0,1,19), conv, 'deprecated \\octave; cannot convert automatically')))
-
-
-if 1:
- def conv (str):
- str = re.sub ('\\\\textstyle([^;]+);',
- '\\\\property Lyrics . textstyle = \\1', str)
- # harmful to current .lys
- # str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str)
-
- return str
-
- conversions.append ((
- ((0,1,20), conv, 'deprecated \\textstyle, new \\key syntax')))
-
-
-if 1:
- def conv (str):
- str = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str)
- str = re.sub ('\\\\meter', '\\\\time',str)
-
- return str
-
- conversions.append ((
- ((0,1,21), conv, '\\musical_pitch -> \\musicalpitch, '+
- '\\meter -> \\time')))
-
-if 1:
- def conv (str):
- return str
-
- conversions.append ((
- ((1,0,0), conv, '0.1.21 -> 1.0.0 ')))
-
-
-if 1:
- def conv (str):
- str = re.sub ('\\\\accidentals', '\\\\keysignature',str)
- str = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str)
- str = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str)
-
- return str
-
- conversions.append ((
- ((1,0,1), conv, '\\accidentals -> \\keysignature, ' +
- 'specialaccidentals -> keyoctaviation')))
-
-if 1:
- def conv(str):
- if re.search ('\\\\header', str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "new \\header format")
- sys.stderr.write ('\n')
- return str
-
- conversions.append (((1,0,2), conv, '\\header { key = concat + with + operator }'))
-
-if 1:
- def conv(str):
- str = re.sub ('\\\\melodic([^a-zA-Z])', '\\\\notes\\1',str)
- return str
-
- conversions.append (((1,0,3), conv, '\\melodic -> \\notes'))
-
-if 1:
- def conv(str):
- str = re.sub ('default_paper *=', '',str)
- str = re.sub ('default_midi *=', '',str)
- return str
-
- conversions.append (((1,0,4), conv, 'default_{paper,midi}'))
-
-if 1:
- def conv(str):
- str = re.sub ('ChoireStaff', 'ChoirStaff',str)
- str = re.sub ('\\\\output', 'output = ',str)
-
- return str
-
- conversions.append (((1,0,5), conv, 'ChoireStaff -> ChoirStaff'))
-
-if 1:
- def conv(str):
- if re.search ('[a-zA-Z]+ = *\\translator',str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "\\translator syntax")
- sys.stderr.write ('\n')
- # raise FatalConversionError ()
- return str
-
- conversions.append (((1,0,6), conv, 'foo = \\translator {\\type .. } ->\\translator {\\type ..; foo; }'))
-
-
-if 1:
- def conv(str):
- str = re.sub ('\\\\lyrics*', '\\\\lyrics',str)
-
- return str
-
- conversions.append (((1,0,7), conv, '\\lyric -> \\lyrics'))
-
-if 1:
- def conv(str):
- str = re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str)
- str = re.sub ('\\[/3+', '\\\\times 2/3 { [',str)
- str = re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str)
- str = re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str)
- str = re.sub ('\\\\\\]([0-9/]+)', '}', str)
- str = re.sub ('\\\\\\]', '}',str)
- str = re.sub ('\\]([0-9/]+)', '] }', str)
- return str
-
- conversions.append (((1,0,10), conv, '[2/3 ]1/1 -> \\times 2/3 '))
-
-if 1:
- def conv(str):
- return str
- conversions.append (((1,0,12), conv, 'Chord syntax stuff'))
-
-
-if 1:
- def conv(str):
-
-
- str = re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str)
-
- return str
-
- conversions.append (((1,0,13), conv, '<a ~ b> c -> <a b> ~ c'))
-
-if 1:
- def conv(str):
- str = re.sub ('<\\[','[<', str)
- str = re.sub ('\\]>','>]', str)
-
- return str
-
- conversions.append (((1,0,14), conv, '<[a b> <a b]>c -> [<a b> <a b>]'))
-
-
-if 1:
- def conv(str):
- str = re.sub ('\\\\type([^\n]*engraver)','\\\\TYPE\\1', str)
- str = re.sub ('\\\\type([^\n]*performer)','\\\\TYPE\\1', str)
- str = re.sub ('\\\\type','\\\\context', str)
- str = re.sub ('\\\\TYPE','\\\\type', str)
- str = re.sub ('textstyle','textStyle', str)
-
- return str
-
- conversions.append (((1,0,16), conv, '\\type -> \\context, textstyle -> textStyle'))
-
-
-if 1:
- def conv(str):
- if re.search ('\\\\repeat',str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "\\repeat")
- sys.stderr.write ('\n')
- # raise FatalConversionError ()
- return str
-
- conversions.append (((1,0,18), conv,
- '\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative'))
-
-if 1:
- def conv(str):
- str = re.sub ('SkipBars','skipBars', str)
- str = re.sub ('fontsize','fontSize', str)
- str = re.sub ('midi_instrument','midiInstrument', str)
-
- return str
-
- conversions.append (((1,0,19), conv,
- 'fontsize -> fontSize, midi_instrument -> midiInstrument, SkipBars -> skipBars'))
-
-
-if 1:
- def conv(str):
- str = re.sub ('tieydirection','tieVerticalDirection', str)
- str = re.sub ('slurydirection','slurVerticalDirection', str)
- str = re.sub ('ydirection','verticalDirection', str)
-
- return str
-
- conversions.append (((1,0,20), conv,
- '{,tie,slur}ydirection -> {v,tieV,slurV}erticalDirection'))
-
-
-if 1:
- def conv(str):
- str = re.sub ('hshift','horizontalNoteShift', str)
-
- return str
-
- conversions.append (((1,0,21), conv,
- 'hshift -> horizontalNoteShift'))
-
-
-if 1:
- def conv(str):
- str = re.sub ('\\\\grouping[^;]*;','', str)
-
- return str
-
- conversions.append (((1,1,52), conv,
- 'deprecate \\grouping'))
-
-
-if 1:
- def conv(str):
- str = re.sub ('\\\\wheel','\\\\coda', str)
-
- return str
-
- conversions.append (((1,1,55), conv,
- '\\wheel -> \\coda'))
-
-if 1:
- def conv(str):
- str = re.sub ('keyoctaviation','keyOctaviation', str)
- str = re.sub ('slurdash','slurDash', str)
-
- return str
-
- conversions.append (((1,1,65), conv,
- 'slurdash -> slurDash, keyoctaviation -> keyOctaviation'))
-
-if 1:
- def conv(str):
- str = re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str)
-
- return str
-
- conversions.append (((1,1,66), conv,
- 'semi -> volta'))
-
-
-if 1:
- def conv(str):
- str = re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str)
-
- return str
-
- conversions.append (((1,1,67), conv,
- 'beamAuto -> noAutoBeaming'))
-
-if 1:
- def conv(str):
- str = re.sub ('automaticMelismas', 'automaticMelismata', str)
-
- return str
-
- conversions.append (((1,2,0), conv,
- 'automaticMelismas -> automaticMelismata'))
-
-if 1:
- def conv(str):
- str = re.sub ('dynamicDir\\b', 'dynamicDirection', str)
-
- return str
-
- conversions.append (((1,2,1), conv,
- 'dynamicDir -> dynamicDirection'))
-
-if 1:
- def conv(str):
- str = re.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str)
- str = re.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str)
-
- return str
-
- conversions.append (((1,3,4), conv,
- '\\cadenza -> \\cadenza{On|Off}'))
-
-if 1:
- def conv (str):
- str = re.sub ('"?beamAuto([^"=]+)"? *= *"([0-9]+)/([0-9]+)" *;*',
- 'beamAuto\\1 = #(make-moment \\2 \\3)',
- str)
- return str
-
- conversions.append (((1,3,5), conv, 'beamAuto moment properties'))
-
-if 1:
- def conv (str):
- str = re.sub ('stemStyle',
- 'flagStyle',
- str)
- return str
-
- conversions.append (((1,3,17), conv, 'stemStyle -> flagStyle'))
-
-if 1:
- def conv (str):
- str = re.sub ('staffLineLeading',
- 'staffSpace',
- str)
- return str
-
- conversions.append (((1,3,18), conv, 'staffLineLeading -> staffSpace'))
-
-
-if 1:
- def conv(str):
- if re.search ('\\\\repetitions',str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "\\repetitions")
- sys.stderr.write ('\n')
- # raise FatalConversionError ()
- return str
-
- conversions.append (((1,3,23), conv,
- '\\\\repetitions feature dropped'))
-
-
-if 1:
- def conv (str):
- str = re.sub ('textEmptyDimension *= *##t',
- 'textNonEmpty = ##f',
- str)
- str = re.sub ('textEmptyDimension *= *##f',
- 'textNonEmpty = ##t',
- str)
- return str
-
- conversions.append (((1,3,35), conv, 'textEmptyDimension -> textNonEmpty'))
-
-if 1:
- def conv (str):
- str = re.sub ("([a-z]+)[ \t]*=[ \t]*\\\\musicalpitch *{([- 0-9]+)} *\n",
- "(\\1 . (\\2))\n", str)
- str = re.sub ("\\\\musicalpitch *{([0-9 -]+)}",
- "\\\\musicalpitch #'(\\1)", str)
- if re.search ('\\\\notenames',str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "new \\notenames format")
- sys.stderr.write ('\n')
- return str
-
- conversions.append (((1,3,38), conv, '\musicalpitch { a b c } -> #\'(a b c)'))
-
-if 1:
- def conv (str):
- def replace (match):
- return '\\key %s;' % string.lower (match.group (1))
-
- str = re.sub ("\\\\key ([^;]+);", replace, str)
- return str
-
- conversions.append (((1,3,39), conv, '\\key A ; ->\\key a;'))
-
-if 1:
- def conv (str):
- if re.search ('\\[:',str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "new tremolo format")
- sys.stderr.write ('\n')
- return str
-
- conversions.append (((1,3,41), conv,
- '[:16 c4 d4 ] -> \\repeat "tremolo" 2 { c16 d16 }'))
-
-if 1:
- def conv (str):
- str = re.sub ('Staff_margin_engraver' , 'Instrument_name_engraver', str)
- return str
-
- conversions.append (((1,3,42), conv,
- 'Staff_margin_engraver deprecated, use Instrument_name_engraver'))
-
-if 1:
- def conv (str):
- str = re.sub ('note[hH]eadStyle\\s*=\\s*"?(\\w+)"?' , "noteHeadStyle = #'\\1", str)
- return str
-
- conversions.append (((1,3,49), conv,
- 'noteHeadStyle value: string -> symbol'))
-
-if 1:
- def conv (str):
- if re.search ('\\\\keysignature', str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "new tremolo format")
- sys.stderr.write ('\n')
- return str
-
-
- conversions.append (((1,3,58), conv,
- 'noteHeadStyle value: string -> symbol'))
-
-if 1:
- def conv (str):
- str = re.sub (r"""\\key *([a-z]+) *;""", r"""\\key \1 \major;""",str);
- return str
- conversions.append (((1,3,59), conv,
- '\key X ; -> \key X major; '))
-
-if 1:
- def conv (str):
- str = re.sub (r'latexheaders *= *"\\\\input ',
- 'latexheaders = "',
- str)
- return str
- conversions.append (((1,3,68), conv, 'latexheaders = "\\input global" -> latexheaders = "global"'))
-
-
-
-
-# TODO: lots of other syntax change should be done here as well
-if 1:
- def conv (str):
- str = re.sub ('basicCollisionProperties', 'NoteCollision', str)
- str = re.sub ('basicVoltaSpannerProperties' , "VoltaBracket", str)
- str = re.sub ('basicKeyProperties' , "KeySignature", str)
-
- str = re.sub ('basicClefItemProperties' ,"Clef", str)
-
-
- str = re.sub ('basicLocalKeyProperties' ,"Accidentals", str)
- str = re.sub ('basicMarkProperties' ,"Accidentals", str)
- str = re.sub ('basic([A-Za-z_]+)Properties', '\\1', str)
-
- str = re.sub ('Repeat_engraver' ,'Volta_engraver', str)
- return str
-
- conversions.append (((1,3,92), conv, 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver'))
-
-if 1:
- def conv (str):
- # Ugh, but meaning of \stemup changed too
- # maybe we should do \stemup -> \stemUp\slurUp\tieUp ?
- str = re.sub ('\\\\stemup', '\\\\stemUp', str)
- str = re.sub ('\\\\stemdown', '\\\\stemDown', str)
- str = re.sub ('\\\\stemboth', '\\\\stemBoth', str)
-
- str = re.sub ('\\\\slurup', '\\\\slurUp', str)
- str = re.sub ('\\\\slurboth', '\\\\slurBoth', str)
- str = re.sub ('\\\\slurdown', '\\\\slurDown', str)
- str = re.sub ('\\\\slurdotted', '\\\\slurDotted', str)
- str = re.sub ('\\\\slurnormal', '\\\\slurNoDots', str)
-
- str = re.sub ('\\\\shiftoff', '\\\\shiftOff', str)
- str = re.sub ('\\\\shifton', '\\\\shiftOn', str)
- str = re.sub ('\\\\shiftonn', '\\\\shiftOnn', str)
- str = re.sub ('\\\\shiftonnn', '\\\\shiftOnnn', str)
-
- str = re.sub ('\\\\onevoice', '\\\\oneVoice', str)
- str = re.sub ('\\\\voiceone', '\\\\voiceOne', str)
- str = re.sub ('\\\\voicetwo', '\\\\voiceTwo', str)
- str = re.sub ('\\\\voicethree', '\\\\voiceThree', str)
- str = re.sub ('\\\\voicefour', '\\\\voiceFour', str)
-
- # I don't know exactly when these happened...
- # ugh, we loose context setting here...
- str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\stemUp\\\\slurUp\\\\tieUp', str)
- str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\stemDown\\\\slurDown\\\\tieDown', str)
- str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\stemBoth\\\\slurBoth\\\\tieBoth', str)
-
- str = re.sub ('verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #1', str)
- str = re.sub ('verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #-1', str)
- str = re.sub ('verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #0', str)
-
- str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\\\1Up', str)
- str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str)
- str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str)
-
- # (lacks capitalisation slur -> Slur)
- str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\1 \\\\override #\'direction = #1', str)
- str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\1 \\override #\'direction = #-1', str)
- str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\1 \\\\override #\'direction = #0', str)
-
- ## dynamic..
- str = re.sub ('\\\\property *[^ .]*[.]?dynamicDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\dynamicUp', str)
- str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\dynamicDown', str)
- str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?(0|(\\\\center))"?', '\\\\dynamicBoth', str)
-
- str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?(0|(""))"?', '\\\\\\1NoDots', str)
- str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?([1-9]+)"?', '\\\\\\1Dotted', str)
-
- str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?(0|(""))"?', '\\\\autoBeamOn', str)
- str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?([1-9]+)"?', '\\\\autoBeamOff', str)
-
-
-
- return str
-
- conversions.append (((1,3,93), conv,
- 'property definiton case (eg. onevoice -> oneVoice)'))
-
-
-if 1:
- def conv (str):
- str = re.sub ('ChordNames*', 'ChordNames', str)
- if re.search ('\\\\textscript "[^"]* *"[^"]*"', str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "new \\textscript markup text")
- sys.stderr.write ('\n')
-
- str = re.sub ('\\textscript +("[^"]*")', '\\textscript #\\1', str)
-
- return str
-
- conversions.append (((1,3,97), conv, 'ChordName -> ChordNames'))
-
-
-# TODO: add lots of these
-
-if 1:
- def conv (str):
- str = re.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str)
- str = re.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str)
-
- str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str)
-
- str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str)
-
- str = re.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str)
-
- str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str)
-
- str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str)
-
- # ugh
- str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str)
-
- str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str)
- return str
-
- conversions.append (((1,3,98), conv, 'CONTEXT.textStyle -> GROB.#font-style '))
-
-if 1:
- def conv (str):
- str = re.sub ('"?beamAutoEnd_([0-9]*)"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end 1 \\1 * *) = \\2', str)
- str = re.sub ('"?beamAutoBegin_([0-9]*)"? *= *(#\\([^)]*\))', 'autoBeamSettings \\push #\'(begin 1 \\1 * *) = \\2', str)
- str = re.sub ('"?beamAutoEnd"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end * * * *) = \\1', str)
- str = re.sub ('"?beamAutoBegin"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(begin * * * *) = \\1', str)
-
-
- return str
-
- conversions.append (((1,3,102), conv, 'beamAutoEnd -> autoBeamSettings \\push (end * * * *)'))
-
-
-if 1:
- def conv (str):
- str = re.sub ('\\\\push', '\\\\override', str)
- str = re.sub ('\\\\pop', '\\\\revert', str)
-
- return str
-
- conversions.append (((1,3,111), conv, '\\push -> \\override, \\pop -> \\revert'))
-
-if 1:
- def conv (str):
- str = re.sub ('LyricVoice', 'LyricsVoice', str)
- # old fix
- str = re.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str)
- str = re.sub ('Chord[Nn]ames([ \t\n]+\\\\override)', 'ChordName\\1', str)
- return str
-
- conversions.append (((1,3,113), conv, 'LyricVoice -> LyricsVoice'))
-
-def regularize_id (str):
- s = ''
- lastx = ''
- for x in str:
- if x == '_':
- lastx = x
- continue
- elif x in string.digits:
- x = chr(ord (x) - ord ('0') +ord ('A'))
- elif x not in string.letters:
- x = 'x'
- elif x in string.lowercase and lastx == '_':
- x = string.upper (x)
- s = s + x
- lastx = x
- return s
-
-if 1:
- def conv (str):
-
- def regularize_dollar_reference (match):
- return regularize_id (match.group (1))
- def regularize_assignment (match):
- return '\n' + regularize_id (match.group (1)) + ' = '
- str = re.sub ('\$([^\t\n ]+)', regularize_dollar_reference, str)
- str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str)
- return str
-
- conversions.append (((1,3,117), conv, 'identifier names: $!foo_bar_123 -> xfooBarABC'))
-
-
-if 1:
- def conv (str):
- def regularize_paper (match):
- return regularize_id (match.group (1))
-
- str = re.sub ('(paper_[a-z]+)', regularize_paper, str)
- str = re.sub ('sustainup', 'sustainUp', str)
- str = re.sub ('nobreak', 'noBreak', str)
- str = re.sub ('sustaindown', 'sustainDown', str)
- str = re.sub ('sostenutoup', 'sostenutoUp', str)
- str = re.sub ('sostenutodown', 'sostenutoDown', str)
- str = re.sub ('unachorda', 'unaChorda', str)
- str = re.sub ('trechorde', 'treChorde', str)
-
- return str
-
- conversions.append (((1,3,120), conv, 'paper_xxx -> paperXxxx, pedalup -> pedalUp.'))
-
-if 1:
- def conv (str):
- str = re.sub ('drarnChords', 'chordChanges', str)
- str = re.sub ('\\musicalpitch', '\\pitch', str)
- return str
-
- conversions.append (((1,3,122), conv, 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch'))
-
-if 1:
- def conv (str):
- str = re.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str)
- return str
-
- conversions.append (((1,3,136), conv, 'ly-X-elt-property -> ly-X-grob-property'))
-
-if 1:
- def conv (str):
- str = re.sub ('point-and-click +#t', 'point-and-click line-column-location', str)
- return str
-
- conversions.append (((1,3,138), conv, 'point-and-click argument changed to procedure.'))
-
-if 1:
- def conv (str):
- str = re.sub ('followThread', 'followVoice', str)
- str = re.sub ('Thread.FollowThread', 'Voice.VoiceFollower', str)
- str = re.sub ('FollowThread', 'VoiceFollower', str)
- return str
-
- conversions.append (((1,3,138), conv, 'followThread -> followVoice.'))
-
-if 1:
- def conv (str):
- str = re.sub ('font-point-size', 'font-design-size', str)
- return str
-
- conversions.append (((1,3,139), conv, 'font-point-size -> font-design-size.'))
-
-if 1:
- def conv (str):
- str = re.sub ('([a-zA-Z]*)NoDots', '\\1Solid', str)
- return str
-
- conversions.append (((1,3,141), conv, 'xNoDots -> xSolid'))
-
-if 1:
- def conv (str):
- str = re.sub ('([Cc])hord([ea])', '\\1ord\\2', str)
- return str
-
- conversions.append (((1,3,144), conv, 'Chorda -> Corda'))
-
-
-if 1:
- def conv (str):
- str = re.sub ('([A-Za-z]+)MinimumVerticalExtent', 'MinimumV@rticalExtent', str)
- str = re.sub ('([A-Za-z]+)ExtraVerticalExtent', 'ExtraV@rticalExtent', str)
- str = re.sub ('([A-Za-z]+)VerticalExtent', 'VerticalExtent', str)
- str = re.sub ('ExtraV@rticalExtent', 'ExtraVerticalExtent', str)
- str = re.sub ('MinimumV@rticalExtent', 'MinimumVerticalExtent', str)
- return str
-
- conversions.append (((1,3,145), conv,
- 'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent'))
-
-if 1:
- def conv (str):
- str = re.sub ('\\\\key[ \t]*;', '\\key \\default;', str)
- str = re.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str)
-
- # Make sure groups of more than one ; have space before
- # them, so that non of them gets removed by next rule
- str = re.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str)
-
- # Only remove ; that are not after spaces, # or ;
- # Otherwise we interfere with Scheme comments,
- # which is badbadbad.
- str = re.sub ("([^ \t;#]);", "\\1", str)
-
- return str
- conversions.append (((1,3,146), conv, 'semicolons removed'))
-
-if 1:
- def conv (str):
- str = re.sub ('default-neutral-direction', 'neutral-direction',str)
- return str
- conversions.append (((1,3,147), conv, 'default-neutral-direction -> neutral-direction'))
-
-if 1:
- def conv (str):
- str = re.sub ('\(align', '(axis', str)
- str = re.sub ('\(rows', '(columns', str)
- return str
- conversions.append (((1,3,148), conv, '"(align" -> "(axis", "(rows" -> "(columns"'))
-
-
-if 1:
- def conv (str):
- str = re.sub ('SystemStartDelimiter', 'systemStartDelimiter', str)
- return str
- conversions.append (((1,5,33), conv, 'SystemStartDelimiter -> systemStartDelimiter'))
-
-if 1:
- def conv (str):
- str = re.sub ('arithmetic-multiplier', 'spacing-increment', str)
- str = re.sub ('arithmetic-basicspace', 'shortest-duration-space', str)
- return str
-
- conversions.append (((1,5,38), conv, 'SystemStartDelimiter -> systemStartDelimiter'))
-
-
-if 1:
- def conv (str):
-
- def func(match):
- break_dict = {
- "Instrument_name": "instrument-name",
- "Left_edge_item": "left-edge",
- "Span_bar": "span-bar",
- "Breathing_sign": "breathing-sign",
- "Staff_bar": "staff-bar",
- "Clef_item": "clef",
- "Key_item": "key-signature",
- "Time_signature": "time-signature",
- "Custos": "custos"
- }
- props = match.group (1)
- for (k,v) in break_dict.items():
- props = re.sub (k, v, props)
- return "breakAlignOrder = #'(%s)" % props
-
- str = re.sub ("breakAlignOrder *= *#'\\(([a-z_\n\tA-Z ]+)\\)",
- func, str)
- return str
-
- # 40 ?
- conversions.append (((1,5,40), conv, 'breakAlignOrder property names'))
-
-
-if 1:
- def conv (str):
- str = re.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str)
- str = re.sub ('noAutoBeaming *= *##t', 'autoBeaming = ##f', str)
- return str
-
- conversions.append (((1,5,49), conv, 'noAutoBeaming -> autoBeaming'))
-
-if 1:
- def conv (str):
- str = re.sub ('tuplet-bracket-visibility', 'bracket-visibility', str)
- str = re.sub ('tuplet-number-visibility', 'number-visibility', str)
- return str
-
- conversions.append (((1,5,52), conv, 'tuplet-X-visibility -> X-visibility'))
-
-if 1:
- def conv (str):
- str = re.sub ('Pitch::transpose', 'ly-transpose-pitch', str)
-
- return str
-
- conversions.append (((1,5,56), conv, 'Pitch::transpose -> ly-transpose-pitch'))
-
-if 1:
- def conv (str):
- str = re.sub ('textNonEmpty *= *##t', "TextScript \\set #'no-spacing-rods = ##f", str)
- str = re.sub ('textNonEmpty *= *##f', "TextScript \\set #'no-spacing-rods = ##t", str)
- return str
-
- conversions.append (((1,5,58), conv, 'deprecate textNonEmpty'))
-
-
-if 1:
- def conv (str):
- str = re.sub ('MinimumVerticalExtent', 'minimumV@rticalExtent', str)
- str = re.sub ('minimumVerticalExtent', 'minimumV@rticalExtent', str)
- str = re.sub ('ExtraVerticalExtent', 'extraV@rticalExtent', str)
- str = re.sub ('extraVerticalExtent', 'extraV@rticalExtent', str)
- str = re.sub ('VerticalExtent', 'verticalExtent', str)
- str = re.sub ('extraV@rticalExtent', 'extraVerticalExtent', str)
- str = re.sub ('minimumV@rticalExtent', 'minimumVerticalExtent', str)
- return str
-
- conversions.append (((1,5,59), conv,
- 'XxxxVerticalExtent -> xxxVerticalExtent'))
-
-if 1:
- def conv (str):
- str = re.sub ('visibility-lambda', 'break-visibility', str)
- return str
-
- conversions.append (((1,5,62), conv,
- 'visibility-lambda -> break-visibility'))
-
-
-if 1:
- def conv (str):
- if re.search (r'\addlyrics',str) \
- and re.search ('automaticMelismata', str) == None:
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "automaticMelismata; turned on by default since 1.5.67.")
- sys.stderr.write ('\n')
- raise FatalConversionError ()
- return str
-
- conversions.append (((1,5,67), conv,
- 'automaticMelismata turned on by default'))
-
-if 1:
- def conv (str):
- str = re.sub ('ly-set-grob-property([^!])', 'ly-set-grob-property!\1', str)
- str = re.sub ('ly-set-mus-property([^!])', 'ly-set-mus-property!\1', str)
- return str
-
- conversions.append (((1,5,68), conv, 'ly-set-X-property -> ly-set-X-property!'))
-
-if 1:
- def conv (str):
- str = re.sub ('extent-X', 'X-extent', str)
- str = re.sub ('extent-Y', 'Y-extent', str)
- return str
-
- conversions.append (((1,5,71), conv, 'extent-[XY] -> [XY]-extent'))
-
-
-if 1:
- def conv (str):
- str = re.sub ("""#\(set! +point-and-click +line-column-location\)""",
- """#(set-point-and-click! \'line-column)""", str)
- str = re.sub ("""#\(set![ \t]+point-and-click +line-location\)""",
- '#(set-point-and-click! \'line)', str)
- str = re.sub ('#\(set! +point-and-click +#f\)',
- '#(set-point-and-click! \'none)', str)
- return str
-
- conversions.append (((1,5,72), conv, 'set! point-and-click -> set-point-and-click!'))
-
-
-if 1:
- def conv (str):
- str = re.sub ('flag-style', 'stroke-style', str)
- str = re.sub (r"""Stem([ ]+)\\override #'style""", r"""Stem \\override #'flag-style""", str);
- str = re.sub (r"""Stem([ ]+)\\set([ ]+)#'style""", r"""Stem \\set #'flag-style""", str);
- return str
-
- conversions.append (((1,6,5), conv, 'Stems: flag-style -> stroke-style; style -> flag-style'))
-
-
-if 1:
- def subst_req_name (match):
- return "(make-music-by-name \'%sEvent)" % regularize_id (match.group(1))
-
- def conv (str):
- str = re.sub ('\\(ly-make-music *\"([A-Z][a-z_]+)_req\"\\)', subst_req_name, str)
- str = re.sub ('Request_chord', 'EventChord', str)
- return str
-
- conversions.append (((1,7,1), conv, 'ly-make-music foo_bar_req -> make-music-by-name FooBarEvent'))
-
-
-if 1:
- spanner_subst ={
- "text" : 'TextSpanEvent',
- "decrescendo" : 'DecrescendoEvent',
- "crescendo" : 'CrescendoEvent',
- "Sustain" : 'SustainPedalEvent',
- "slur" : 'SlurEvent',
- "UnaCorda" : 'UnaCordaEvent',
- "Sostenuto" : 'SostenutoEvent',
- }
- def subst_ev_name (match):
- stype = 'STOP'
- if re.search ('start', match.group(1)):
- stype= 'START'
-
- mtype = spanner_subst[match.group(2)]
- return "(make-span-event '%s %s)" % (mtype , stype)
-
- def subst_definition_ev_name(match):
- return ' = #%s' % subst_ev_name (match)
- def subst_inline_ev_name (match):
- s = subst_ev_name (match)
- return '#(ly-export %s)' % s
- def subst_csp_definition (match):
- return ' = #(make-event-chord (list %s))' % subst_ev_name (match)
- def subst_csp_inline (match):
- return '#(ly-export (make-event-chord (list %s)))' % subst_ev_name (match)
-
- def conv (str):
- str = re.sub (r' *= *\\spanrequest *([^ ]+) *"([^"]+)"', subst_definition_ev_name, str)
- str = re.sub (r'\\spanrequest *([^ ]+) *"([^"]+)"', subst_inline_ev_name, str)
- str = re.sub (r' *= *\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_definition, str)
- str = re.sub (r'\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_inline, str)
- str = re.sub (r'ly-id ', 'ly-import ', str)
-
- str = re.sub (r' *= *\\script "([^"]+)"', ' = #(make-articulation "\\1")', str)
- str = re.sub (r'\\script "([^"]+)"', '#(ly-export (make-articulation "\\1"))', str)
- return str
-
- conversions.append (((1,7,2), conv, '\\spanrequest -> #(make-span-event .. ), \script -> #(make-articulation .. )'))
-
-if 1:
- def conv(str):
- str = re.sub (r'\(ly-', '(ly:', str)
-
- changed = [
- r'duration\?',
- r'font-metric\?',
- r'molecule\?',
- r'moment\?',
- r'music\?',
- r'pitch\?',
- 'make-duration',
- 'music-duration-length',
- 'duration-log',
- 'duration-dotcount',
- 'intlog2',
- 'duration-factor',
- 'transpose-key-alist',
- 'get-system',
- 'get-broken-into',
- 'get-original',
- 'set-point-and-click!',
- 'make-moment',
- 'make-pitch',
- 'pitch-octave',
- 'pitch-alteration',
- 'pitch-notename',
- 'pitch-semitones',
- r'pitch<\?',
- r'dir\?',
- 'music-duration-compress',
- 'set-point-and-click!'
- ]
-
- origre = r'\b(%s)' % string.join (changed, '|')
-
- str = re.sub (origre, r'ly:\1',str)
- str = re.sub ('set-point-and-click!', 'set-point-and-click', str)
-
- return str
-
- conversions.append (((1,7,3), conv, 'ly- -> ly:'))
-
-if 1:
- def conv(str):
- if re.search ('new-chords-done',str):
- return str
-
- str = re.sub (r'<<', '< <', str)
- str = re.sub (r'>>', '> >', str)
- return str
-
- conversions.append (((1,7,4), conv, '<< >> -> < < > >'))
-
-if 1:
- def conv(str):
- str = re.sub (r"\\transpose", r"\\transpose c'", str)
- str = re.sub (r"\\transpose c' *([a-z]+)'", r"\\transpose c \1", str)
- return str
- conversions.append (((1,7,5), conv, '\\transpose TO -> \\transpose FROM TO'))
-
-if 1:
- def conv(str):
- kws = ['arpeggio',
- 'sustainDown',
- 'sustainUp',
- 'f',
- 'p',
- 'pp',
- 'ppp',
- 'fp',
- 'ff',
- 'mf',
- 'mp',
- 'sfz',
- ]
-
- origstr = string.join (kws, '|')
- str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str)
- return str
- conversions.append (((1,7,6), conv, 'note\\script -> note-\script'))
-
-
-if 1:
- def conv(str):
- str = re.sub (r"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)",
- r"#(set-chord-name-style \2)", str)
- str = re.sub (r"\\property *ChordNames *\. *ChordName *\\revert *#'style",
- r"", str)
- return str
- conversions.append (((1,7,10), conv, "\property ChordName #'style -> #(set-chord-name-style 'style)"))
-
-
-
-if 1:
- def conv(str):
- str = re.sub (r"ly:transpose-pitch", "ly:pitch-transpose", str)
-
- return str
- conversions.append (((1,7,11), conv, "transpose-pitch -> pitch-transpose"))
-
-if 1:
- def conv(str):
- str = re.sub (r"ly:get-molecule-extent", "ly:molecule-get-extent", str)
- str = re.sub (r"ly:set-molecule-extent!", "ly:molecule-set-extent!", str)
- str = re.sub (r"ly:add-molecule", "ly:molecule-add", str)
- str = re.sub (r"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str)
- str = re.sub (r"ly:align-to!", "ly:molecule-align-to!", str)
-
- return str
-
- conversions.append (((1,7,13), conv, "ly:XX-molecule-YY -> ly:molecule-XX-YY"))
-
-if 1:
- def conv(str):
- str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str )
- return str
-
- conversions.append (((1,7,15), conv, "linewidth = -1 -> raggedright = ##t"))
-
-if 1:
- def conv(str):
- str = re.sub ("divisiomaior",
- "divisioMaior", str)
- str = re.sub ("divisiominima",
- "divisioMinima", str)
- str = re.sub ("divisiomaxima",
- "divisioMaxima", str)
- return str
-
- conversions.append (((1,7,16), conv, "divisiomaior -> divisioMaior"))
-
-if 1:
- def conv(str):
- str = re.sub ("Skip_req_swallow_translator",
- "Skip_event_swallow_translator", str)
- return str
-
- conversions.append (((1,7,17), conv, "Skip_req -> Skip_event"))
-
-if 1:
- def conv(str):
- str = re.sub ("groupOpen",
- "startGroup", str)
- str = re.sub ("groupClose",
- "stopGroup", str)
- str = re.sub ("#'outer",
- "#'enclose-bounds", str)
-
- return str
-
- conversions.append (((1,7,18), conv,
- """groupOpen/Close -> start/stopGroup,
- #'outer -> #'enclose-bounds
- """))
-
-if 1:
- def conv(str):
- if re.search( r'\\GraceContext', str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "GraceContext")
- sys.stderr.write (FROM_TO \
- % ("GraceContext", "#(add-to-grace-init .. )"))
- sys.stderr.write ('\n')
- sys.stderr.write (UPDATE_MANUALLY)
- sys.stderr.write ('\n')
- raise FatalConversionError ()
-
- str = re.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str)
- return str
-
- conversions.append (((1,7,19), conv,"remove GraceContext"))
-
-
-
-if 1:
- def conv(str):
- str = re.sub (
- r"(set|override|revert) *#'type",
- r"\1 #'style",
- str)
- return str
-
- conversions.append (((1,7,22), conv,"#'type -> #'style"))
-
-if 1:
- def conv(str):
- str = re.sub (
- "barNonAuto *= *##t",
- "automaticBars = ##f",
- str)
- str = re.sub (
- "barNonAuto *= *##f",
- "automaticBars = ##t",
- str)
- return str
-
- conversions.append (((1,7,23), conv,"barNonAuto -> automaticBars"))
-
-
-if 1:
- def conv(str):
- if re.search( r'-(start|stop)Cluster', str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "Cluster syntax")
- sys.stderr.write ('\n')
- sys.stderr.write (UPDATE_MANUALLY)
- sys.stderr.write ('\n')
-
- raise FatalConversionError ()
-
- return str
-
- conversions.append (((1,7,24), conv,"cluster syntax"))
-
-if 1:
- def conv(str):
- str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *",
- r"\property Staff.pedal\1Style ", str)
- str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str)
- return str
-
- conversions.append (((1,7,28), conv,"new Pedal style syntax"))
-
-
-
-if 1:
-
- def sub_chord (m):
- str = m.group(1)
-
- origstr = '<%s>' % str
- if re.search (r'\\\\', str):
- return origstr
-
- if re.search (r'\\property', str):
- return origstr
-
- if re.match (r'^\s*\)?\s*\\[a-zA-Z]+', str):
- return origstr
-
- durs = []
- def sub_durs (m, durs = durs):
- durs.append(m.group(2))
- return m.group (1)
-
- str = re.sub (r"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs, str)
- dur_str = ''
-
- for d in durs:
- if dur_str == '':
- dur_str = d
- if dur_str <> d:
- return '<%s>' % m.group (1)
-
- pslur_strs = ['']
- dyns = ['']
- slur_strs = ['']
-
- last_str = ''
- while last_str <> str:
- last_str = str
-
- def sub_tremolos (m, slur_strs = slur_strs):
- tr = m.group (2)
- if tr not in slur_strs:
- slur_strs.append (tr)
- return m.group (1)
-
- str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)",
- sub_tremolos, str)
-
- def sub_dyn_end (m, dyns = dyns):
- dyns.append (' \!')
- return ' ' + m.group(2)
-
- str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str)
- def sub_slurs(m, slur_strs = slur_strs):
- if '-)' not in slur_strs:
- slur_strs.append (')')
- return m.group(1)
-
- def sub_p_slurs(m, slur_strs = slur_strs):
- if '-\)' not in slur_strs:
- slur_strs.append ('\)')
- return m.group(1)
-
- str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str)
- str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str)
- def sub_begin_slurs(m, slur_strs = slur_strs):
- if '-(' not in slur_strs:
- slur_strs.append ('(')
- return m.group(1)
-
- str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(",
- sub_begin_slurs, str)
- def sub_begin_p_slurs(m, slur_strs = slur_strs):
- if '-\(' not in slur_strs:
- slur_strs.append ('\(')
- return m.group(1)
-
- str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(",
- sub_begin_p_slurs, str)
-
- def sub_dyns (m, slur_strs = slur_strs):
- s = m.group(0)
- if s == '@STARTCRESC@':
- slur_strs.append ("\\<")
- elif s == '@STARTDECRESC@':
- slur_strs.append ("\\>")
- elif s == r'-?\\!':
- slur_strs.append ('\\!')
- return ''
-
- str = re.sub (r'@STARTCRESC@', sub_dyns, str)
- str = re.sub (r'-?\\!', sub_dyns, str)
-
- def sub_articulations (m, slur_strs = slur_strs):
- a = m.group(1)
- if a not in slur_strs:
- slur_strs.append (a)
- return ''
-
- str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations,
- str)
- str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations,
- str)
- str = re.sub (r"([_^-][>_.+|^-])", sub_articulations,
- str)
- str = re.sub (r'([_^-]"[^"]+")', sub_articulations,
- str)
-
- def sub_pslurs(m, slur_strs = slur_strs):
- slur_strs.append (' \\)')
- return m.group(1)
- str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str)
-
- ## end of while <>
-
- suffix = string.join (slur_strs, '') + string.join (pslur_strs,
- '') \
- + string.join (dyns, '')
-
- return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix)
-
-
-
- def sub_chords (str):
- simend = '>'
- simstart = '<'
- chordstart = '<<'
- chordend = '>>'
- marker_str = '%% new-chords-done %%'
-
- if re.search (marker_str,str):
- return str
- str = re.sub ('<<', '@STARTCHORD@', str)
- str = re.sub ('>>', '@ENDCHORD@', str)
-
- str = re.sub (r'\\<', '@STARTCRESC@', str)
- str = re.sub (r'\\>', '@STARTDECRESC@', str)
- str = re.sub (r'([_^-])>', r'\1@ACCENT@', str)
- str = re.sub (r'<([^<>{}]+)>', sub_chord, str)
-
- # add dash: -[, so that [<<a b>> c d] becomes
- # <<a b>>-[ c d]
- # and gets skipped by articulation_substitute
- str = re.sub (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
- r'\1-[', str)
- str = re.sub (r'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
- r'\1-\\!', str)
-
- str = re.sub (r'<([^?])', r'%s\1' % simstart, str)
- str = re.sub (r'>([^?])', r'%s\1' % simend, str)
- str = re.sub ('@STARTCRESC@', r'\\<', str)
- str = re.sub ('@STARTDECRESC@', r'\\>' ,str)
- str = re.sub (r'\\context *Voice *@STARTCHORD@',
- '@STARTCHORD@', str)
- str = re.sub ('@STARTCHORD@', chordstart, str)
- str = re.sub ('@ENDCHORD@', chordend, str)
- str = re.sub (r'@ACCENT@', '>', str)
- return str
-
- markup_start = re.compile(r"([-^_]|\\mark)\s*(#\s*'\s*)\(")
- musicglyph = re.compile(r"\(\s*music\b")
- columns = re.compile(r"\(\s*columns\b")
- submarkup_start = re.compile(r"\(\s*([a-zA-Z]+)")
- leftpar = re.compile(r"\(")
- rightpar = re.compile(r"\)")
-
- def text_markup (str):
- result = ''
- # Find the beginning of each markup:
- match = markup_start.search (str)
- while match:
- result = result + str[:match.end (1)] + " \markup"
- str = str[match.end( 2):]
- # Count matching parentheses to find the end of the
- # current markup:
- nesting_level = 0
- pars = re.finditer(r"[()]",str)
- for par in pars:
- if par.group () == '(':
- nesting_level = nesting_level + 1
- else:
- nesting_level = nesting_level - 1
- if nesting_level == 0:
- markup_end = par.end ()
- break
- # The full markup in old syntax:
- markup = str[:markup_end]
- # Modify to new syntax:
- markup = musicglyph.sub (r"{\\musicglyph", markup)
- markup = columns.sub (r"{", markup)
- markup = submarkup_start.sub (r"{\\\1", markup)
- markup = leftpar.sub ("{", markup)
- markup = rightpar.sub ("}", markup)
-
- result = result + markup
- # Find next markup
- str = str[markup_end:]
- match = markup_start.search(str)
- result = result + str
- return result
-
- def articulation_substitute (str):
- str = re.sub (r"""([^-])\[ *(\\?\)?[a-z]+[,']*[!?]?[0-9:]*\.*)""",
- r"\1 \2[", str)
- str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
- r"\1 \2\\)", str)
- str = re.sub (r"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
- r"\1 \2)", str)
- str = re.sub (r"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
- r"\1 \2\\!", str)
- return str
-
- string_or_scheme = re.compile ('("(?:[^"\\\\]|\\\\.)*")|(#\\s*\'?\\s*\\()')
-
- # Only apply articulation_substitute () outside strings and
- # Scheme expressions:
- def smarter_articulation_subst (str):
- result = ''
- # Find the beginning of next string or Scheme expr.:
- match = string_or_scheme.search (str)
- while match:
- # Convert the preceding LilyPond code:
- previous_chunk = str[:match.start()]
- result = result + articulation_substitute (previous_chunk)
- if match.group (1): # Found a string
- # Copy the string to output:
- result = result + match.group (1)
- str = str[match.end(1):]
- else: # Found a Scheme expression. Count
- # matching parentheses to find its end
- str = str[match.start ():]
- nesting_level = 0
- pars = re.finditer(r"[()]",str)
- for par in pars:
- if par.group () == '(':
- nesting_level = nesting_level + 1
- else:
- nesting_level = nesting_level - 1
- if nesting_level == 0:
- scheme_end = par.end ()
- break
- # Copy the Scheme expression to output:
- result = result + str[:scheme_end]
- str = str[scheme_end:]
- # Find next string or Scheme expression:
- match = string_or_scheme.search (str)
- # Convert the remainder of the file
- result = result + articulation_substitute (str)
- return result
-
- def conv_relative(str):
- if re.search (r"\\relative", str):
- str= "#(ly:set-option 'old-relative)\n" + str
-
- return str
-
- def conv (str):
- str = re.sub (r"#'\(\)", "@SCM_EOL@", str)
- str = conv_relative (str)
- str = sub_chords (str)
-
- str = text_markup (str)
- str = smarter_articulation_subst (str)
- str = re.sub ("@SCM_EOL@", "#'()", str)
-
- return str
-
- conversions.append (((1,9,0), conv, """New relative mode,
-Postfix articulations, new text markup syntax, new chord syntax."""))
-
-if 1:
- def conv (str):
- if re.search ("font-style",str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "font-sytle")
- sys.stderr.write ('\n')
- sys.stderr.write (UPDATE_MANUALLY)
- sys.stderr.write ('\n')
-
- raise FatalConversionError ()
-
- str = re.sub (r'-\\markup', r'@\\markup', str)
- str = re.sub (r'-\\', r'\\', str)
- str = re.sub (r'-\)', ')', str)
- str = re.sub (r'-\(', '(', str)
- str = re.sub ('-\[', '[', str)
- str = re.sub ('-\]', ']', str)
- str = re.sub ('-~', '~', str)
- str = re.sub (r'@\\markup', r'-\\markup', str)
- return str
-
- conversions.append (((1,9,1), conv, """Remove - before articulation"""))
-if 1:
- def conv (str):
- str = re.sub ('ly:set-context-property',
- 'ly:set-context-property!', str)
- str = re.sub ('\\\\newcontext', '\\\\new', str)
- str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)',
- r'\\grace { \1 }', str)
- str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}",
- r"""\\grace {
- \\property Voice.Stem \\override #'stroke-style = #"grace"
- \1
- \\property Voice.Stem \\revert #'stroke-style }
-""", str)
-
- return str
-
- conversions.append (((1,9,2), conv, """\\newcontext -> \\new"""))
-
-if 1:
- def conv (str):
- str = re.sub ('accacciatura',
- 'acciaccatura', str)
-
- if re.search ("context-spec-music", str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "context-spec-music")
- sys.stderr.write ('\n')
- sys.stderr.write (UPDATE_MANUALLY)
- sys.stderr.write ('\n')
-
- raise FatalConversionError ()
-
- str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)',
- "fingeringOrientations = #'(up down left)", str)
- str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)',
- "fingeringOrientations = #'(up down right)", str)
-
- return str
-
- conversions.append (((1,9,3), conv,
- """\\acciaccatura misspelling, fingerHorizontalDirection -> fingeringOrientations"""))
-
-
-def conv (str):
- if re.search ('\\figures', str):
- sys.stderr.write ("Warning: attempting automatic \\figures conversion. Check results!");
-
-
- def figures_replace (m):
- s = m.group (1)
- s = re.sub ('<', '@FIGOPEN@',s)
- s = re.sub ('>', '@FIGCLOSE@',s)
- return '\\figures { %s }' % s
-
- str = re.sub (r'\\figures[ \t\n]*{([^}]+)}', figures_replace, str)
- str = re.sub (r'\\<', '@STARTCRESC@', str)
- str = re.sub (r'\\>', '@STARTDECRESC@', str)
- str = re.sub (r'([-^_])>', r'\1@ACCENT@', str)
- str = re.sub (r'<<', '@STARTCHORD@', str)
- str = re.sub (r'>>', '@ENDCHORD@', str)
- str = re.sub (r'>', '@ENDSIMUL@', str)
- str = re.sub (r'<', '@STARTSIMUL@', str)
- str = re.sub ('@STARTDECRESC@', '\\>', str)
- str = re.sub ('@STARTCRESC@', '\\<', str)
- str = re.sub ('@ACCENT@', '>', str)
- str = re.sub ('@ENDCHORD@', '>', str)
- str = re.sub ('@STARTCHORD@', '<', str)
- str = re.sub ('@STARTSIMUL@', '<<', str)
- str = re.sub ('@ENDSIMUL@', '>>', str)
- str = re.sub ('@FIGOPEN@', '<', str)
- str = re.sub ('@FIGCLOSE@', '>', str)
-
- return str
-
-conversions.append (((1,9,4), conv, 'Swap < > and << >>'))
-
-
-def conv (str):
- str = re.sub ('HaraKiriVerticalGroup', 'RemoveEmptyVerticalGroup', str)
-
- return str
-
-conversions.append (((1,9,5), conv, 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup'))
-
-def conv (str):
- if re.search ("ly:get-font", str) :
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "(ly:-get-font")
- sys.stderr.write ('\n')
- sys.stderr.write (FROM_TO \
- % ("(ly:paper-get-font (ly:grob-get-paper foo) .. )",
- "(ly:paper-get-font (ly:grob-get-paper foo) .. )"))
- sys.stderr.write (UPDATE_MANUALLY)
- sys.stderr.write ('\n')
- raise FatalConversionError ()
-
- if re.search ("\\pitch *#", str) :
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "\\pitch")
- sys.stderr.write ('\n')
- sys.stderr.write ("Use Scheme code to construct arbitrary note events.")
- sys.stderr.write ('\n')
-
- raise FatalConversionError ()
-
- return str
-
-
-conversions.append (((1,9,6), conv, 'ly:get-font deprecated.'))
-
-def conv (str):
- def sub_alteration (m):
- alt = m.group (3)
- alt = {
- '-1': 'FLAT',
- '-2': 'DOUBLE-FLAT',
- '0': 'NATURAL',
- '1': 'SHARP',
- '2': 'DOUBLE-SHARP',
- }[alt]
-
- return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2),
- alt)
-
- str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
- sub_alteration, str)
-
-
- str = re.sub ("ly:verbose", "ly:get-option 'verbose", str)
-
- m= re.search ("\\\\outputproperty #([^#]+)[\t\n ]*#'([^ ]+)", str)
- if m:
- sys.stderr.write (\
- r"""\outputproperty found,
-Please hand-edit, using
-
- \applyoutput #(outputproperty-compatibility %s '%s <GROB PROPERTY VALUE>)
-
-as a substitution text.""" % (m.group (1), m.group (2)) )
- raise FatalConversionError ()
-
- if re.search ("ly:(make-pitch|pitch-alteration)", str) \
- or re.search ("keySignature", str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "pitches")
- sys.stderr.write ('\n')
- sys.stderr.write (
-"""The alteration field of Scheme pitches was multiplied by 2
-to support quarter tone accidentals. You must update the following constructs by manually:
-
-* calls of ly:make-pitch and ly:pitch-alteration
-* keySignature settings made with \property
-""")
- raise FatalConversionError ()
-
- return str
-conversions.append (((1,9,7), conv,
- '''use symbolic constants for alterations,
-remove \\outputproperty, move ly:verbose into ly:get-option'''))
-
-
-def conv (str):
- if re.search ("dash-length",str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "dash-length")
- sys.stderr.write ('\n')
- sys.stderr.write (FROM_TO % ("dash-length", "dash-fraction"))
- sys.stderr.write ('\n')
- sys.stderr.write (UPDATE_MANUALLY)
- sys.stderr.write ('\n')
- raise FatalConversionError ()
- return str
-
-conversions.append (((1,9,8), conv, """dash-length -> dash-fraction"""))
-
-
-def conv (str):
- def func(match):
- return "#'font-size = #%d" % (2*string.atoi (match.group (1)))
-
- str =re.sub (r"#'font-relative-size\s*=\s*#\+?([0-9-]+)", func, str)
- str =re.sub (r"#'font-family\s*=\s*#'ancient",
- r"#'font-family = #'music", str)
-
- return str
-
-conversions.append (((2,1,1), conv, """font-relative-size -> font-size"""))
-
-def conv (str):
- str =re.sub (r"ly:get-music-length", "ly:music-length", str)
- return str
-
-conversions.append (((2,1,2), conv, """ly:get-music-length -> ly:music-length"""))
-
-def conv (str):
- str =re.sub (r"\.\s+stz=", ". instr ", str)
- return str
-
-conversions.append (((2,1,3), conv, """stanza -> instrument"""))
-
-def conv (str):
- def func (match):
- c = match.group (1)
- b = match.group (2)
-
- if b == 't':
- if c == 'Score':
- return ''
- else:
- return r" \property %s.melismaBusyProperties \unset" % c
- elif b == 'f':
- return r"\property %s.melismaBusyProperties = #'(melismaBusy)" % c
-
- str = re.sub (r"\\property ([a-zA-Z]+)\s*\.\s*automaticMelismata\s*=\s*##([ft])", func, str)
- return str
-
-conversions.append (((2,1,4), conv, """removal of automaticMelismata; use melismaBusyProperties instead."""))
-
-
-
-def conv (str):
- str =re.sub (r"\\translator\s+([a-zA-Z]+)", r"\\change \1", str)
- return str
+sys.path.insert (0, os.path.join (datadir, 'python'))
-conversions.append (((2,1,7), conv, """\\translator Staff -> \\change Staff"""))
+import lilylib as ly
+import fontextract
+global _;_=ly._
+global re;re = ly.re
-def conv (str):
- str =re.sub (r"\\newaddlyrics", r"\\lyricsto", str)
- return str
+from convertrules import *
-conversions.append (((2,1,10), conv, """\\newaddlyrics -> \\lyricsto"""))
-def conv (str):
- str = re.sub (r'\\include\s*"paper([0-9]+)(-init)?.ly"',
- r"#(set-staff-size \1)", str)
+help_summary = _ (
+'''Update LilyPond input to newer version. By default, update from the
+version taken from the \\version command, to the current LilyPond version.
- def sub_note (match):
- dur = ''
- log = string.atoi (match.group (1))
- dots = string.atoi (match.group (2))
+Examples:
- if log >= 0:
- dur = '%d' % (1 << log)
- else:
- dur = { -1 : 'breve',
- -2 : 'longa',
- -3 : 'maxima'}[log]
-
- dur += ('.' * dots)
-
- return r'\note #"%s" #%s' % (dur, match.group (3))
-
- str = re.sub (r'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
- sub_note, str)
- return str
-
-conversions.append (((2,1,11), conv, """\\include "paper16.ly" -> #(set-staff-size 16)
-\\note #3 #1 #1 -> \\note #"8." #1
-"""))
-
-
-def conv (str):
- str =re.sub (r"OttavaSpanner", r"OttavaBracket", str)
- return str
-
-conversions.append (((2,1,12), conv, """OttavaSpanner -> OttavaBracket"""))
-
-
-def conv (str):
- str =re.sub (r"\(set-staff-size ", r"(set-global-staff-size ", str)
- return str
-
-conversions.append (((2,1,13), conv, """set-staff-size -> set-global-staff-size"""))
-
-def conv (str):
- str =re.sub (r"#'style\s*=\s*#'dotted-line",
- r"#'dash-fraction = #0.0 ", str)
- return str
-
-conversions.append (((2,1,14), conv, """style = dotted -> dash-fraction = 0"""))
-
-def conv (str):
- str =re.sub (r'LyricsVoice\s*\.\s*instrument\s*=\s*("[^"]*")',
- r'LyricsVoice . vocalName = \1', str)
-
- str =re.sub (r'LyricsVoice\s*\.\s*instr\s*=\s*("[^"]*")',
- r'LyricsVoice . vocNam = \1', str)
- return str
-
-conversions.append (((2,1,15), conv, """LyricsVoice . instr(ument) -> vocalName"""))
-
-def conv (str):
- def sub_acc (m):
- d = {
- '4': 'doublesharp',
- '3': 'threeqsharp',
- '2': 'sharp',
- '1': 'semisharp',
- '0': 'natural',
- '-1': 'semiflat',
- '-2': 'flat',
- '-3': 'threeqflat',
- '-4': 'doubleflat'}
- return '\\%s' % d[m.group (1)]
-
- str = re.sub (r'\\musicglyph\s*#"accidentals-([0-9-]+)"',
- sub_acc, str)
- return str
-
-conversions.append (((2,1,16), conv, """\\musicglyph #"accidentals-NUM" -> \\sharp/flat/etc."""))
-
-
-def conv (str):
-
- if re.search (r'\\partcombine', str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "\\partcombine")
- sys.stderr.write ('\n')
- sys.stderr.write (UPDATE_MANUALLY)
- sys.stderr.write ('\n')
- raise FatalConversionError ()
-
- # this rule doesn't really work,
- # too lazy to figure out why.
- str = re.sub (r'\\context\s+Voice\s*=\s*one\s*\\partcombine\s+Voice\s*\\context\s+Thread\s*=\s*one(.*)\s*'
- + r'\\context\s+Thread\s*=\s*two',
- '\\\\newpartcombine\n\\1\n', str)
-
-
- return str
-
-conversions.append (((2,1,17), conv, """\\partcombine syntax change to \\newpartcombine"""))
-
-
-def conv (str):
- str = re.sub (r'\\newpartcombine', r'\\partcombine', str)
- str = re.sub (r'\\autochange\s+Staff', r'\\autochange ', str)
- return str
-
-conversions.append (((2,1,18), conv, """\\newpartcombine -> \\partcombine,
-\\autochange Staff -> \\autochange
-"""))
-
-
-
-
-def conv (str):
- str = re.sub (r'\\include "drumpitch-init.ly"','', str)
- str = re.sub (r'\\pitchnames ','pitchnames = ', str)
- str = re.sub (r'\\chordmodifiers ','chordmodifiers = ', str)
- str = re.sub (r'\bdrums\b\s*=','drumContents = ', str)
- str = re.sub (r'\\drums\b','\\drumContents ', str)
-
-
- if re.search ('drums->paper', str):
- sys.stderr.write ("\nDrum notation found. Check file manually!")
-
- str = re.sub (r"""\\apply\s+#\(drums->paper\s+'([a-z]+)\)""",
- r"""\property DrumStaff.drumStyleTable = #\1-style""",
- str)
-
- if re.search ('Thread', str):
- sys.stderr.write ("\nThread found. Check file manually!\n");
-
- str = re.sub (r"""(\\once\s*)?\\property\s+Thread\s*\.\s*NoteHead\s*"""
- + r"""\\(set|override)\s*#'style\s*=\s*#'harmonic"""
- + r"""\s+([a-z]+[,'=]*)([0-9]*\.*)"""
- ,r"""<\3\\harmonic>\4""", str)
-
- str = re.sub (r"""\\new Thread""", """\context Voice""", str)
- str = re.sub (r"""Thread""", """Voice""", str)
-
- if re.search ('\bLyrics\b', str):
- sys.stderr.write ("\nLyrics found. Check file manually!\n");
-
- str = re.sub (r"""LyricsVoice""", r"""L@ricsVoice""", str)
- str = re.sub (r"""\bLyrics\b""", r"""LyricsVoice""", str)
- str = re.sub (r"""LyricsContext""", r"""LyricsVoiceContext""", str)
- str = re.sub (r"""L@ricsVoice""", r"""LyricsVoice""",str)
-
-
- return str
-
-conversions.append (((2,1,19), conv, """Drum notation changes, Removing \\chordmodifiers, \\notenames.
-Harmonic notes. Thread context removed. Lyrics context removed."""))
-
-def conv (str):
- str = re.sub (r'nonevent-skip', 'skip-music', str)
- return str
-
-conversions.append (((2,1,20), conv, """nonevent-skip -> skip-music""" ))
-
-def conv (str):
- str = re.sub (r'molecule-callback', 'print-function', str)
- str = re.sub (r'brew_molecule', 'print', str)
- str = re.sub (r'brew-new-markup-molecule', 'Text_item::print', str)
- str = re.sub (r'LyricsVoice', 'Lyrics', str)
- str = re.sub (r'tupletInvisible',
- r"TupletBracket \\set #'transparent", str)
-# str = re.sub (r'molecule', 'collage', str)
-#molecule -> collage
- str = re.sub (r"\\property\s+[a-zA-Z]+\s*\.\s*[a-zA-Z]+\s*"
- + r"\\set\s*#'X-extent-callback\s*=\s*#Grob::preset_extent",
- "", str)
-
- return str
-
-conversions.append (((2,1,21), conv, """molecule-callback -> print-function,
-brew_molecule -> print
-brew-new-markup-molecule -> Text_item::print
-LyricsVoice -> Lyrics
-tupletInvisible -> TupletBracket \set #'transparent
-Grob::preset_extent removed.
-""" ))
-
-
-def conv (str):
- str = re.sub (r'(\\property[^=]+)=\s*([-0-9]+)',
- r'\1= #\2', str)
- str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\=]+)\s*\\(set|override)',
- r"\\overrid@ \1.\2 ", str)
- str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*=\s*',
- r'\\s@t \1.\2 = ', str)
- str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\unset',
- r'\\uns@t \1.\2 ', str)
- str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\revert'
- + r"\s*#'([-a-z0-9_]+)",
- r"\\rev@rt \1.\2 #'\3", str)
- str = re.sub (r'Voice\.', '', str)
- str = re.sub (r'Lyrics\.', '', str)
- str = re.sub (r'ChordNames\.', '', str)
-
- str = re.sub ('rev@rt', 'revert',str)
- str = re.sub ('s@t', 'set',str)
- str = re.sub ('overrid@', 'override',str)
-
- str = re.sub ('molecule', 'stencil', str)
- str = re.sub ('Molecule', 'Stencil', str)
- return str
-
-conversions.append (((2,1,22), conv, """new syntax for property settings:
- \\set A.B = #C , \\unset A.B
- \\override A.B #C = #D, \\revert A.B #C
-
-"""))
-
-def conv (str):
- def subst_in_trans (match):
- s = match.group (0)
- s = re.sub (r'\s([a-zA-Z]+)\s*\\override',
- r' \\override \1', s)
- s = re.sub (r'\s([a-zA-Z]+)\s*\\set',
- r' \\override \1', s)
- s = re.sub (r'\s([a-zA-Z]+)\s*\\revert',
- r' \\revert \1', s)
- return s
- str = re.sub (r'\\(translator|with)\s*{[^}]+}', subst_in_trans, str)
-
- def sub_abs (m):
-
- context = m.group ('context')
- d = m.groupdict ()
- if context:
- context = " '%s" % context[:-1] # -1: remove .
- else:
- context = ''
-
- d['context'] = context
-
- return r"""#(override-auto-beam-setting %(prop)s %(num)s %(den)s%(context)s)""" % d
-
- str = re.sub (r"""\\override\s*(?P<context>[a-zA-Z]+\s*\.\s*)?autoBeamSettings"""
- +r"""\s*#(?P<prop>[^=]+)\s*=\s*#\(ly:make-moment\s+(?P<num>\d+)\s+(?P<den>\d)\s*\)""",
- sub_abs, str)
-
- return str
-
-conversions.append (((2,1,23), conv, """Property setting syntax in \\translator{ }"""))
-def conv (str):
- str = re.sub (r'music-list\?', 'ly:music-list?', str)
- str = re.sub (r'\|\s*~', '~ |', str)
- return str
-
-conversions.append (((2,1,24), conv, """music-list? -> ly:music-list?"""))
-
-def conv (str):
- str = re.sub (r'ly:get-spanner-bound', 'ly:spanner-get-bound', str)
- str = re.sub (r'ly:get-extent', 'ly:grob-extent', str)
- str = re.sub (r'ly:get-system', 'ly:grob-system', str)
- str = re.sub (r'ly:get-original', 'ly:grob-original', str)
- str = re.sub (r'ly:get-parent', 'ly:grob-parent', str)
- str = re.sub (r'ly:get-broken-into', 'ly:spanner-broken-into', str)
- str = re.sub (r'Melisma_engraver', 'Melisma_translator', str)
- if re.search ("ly:get-paper-variable", str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "ly:paper-get-variable")
- sys.stderr.write ('\n')
- sys.stderr.write ('use (ly:paper-lookup (ly:grob-paper ))')
- sys.stderr.write ('\n')
- raise FatalConversionError ()
-
- str = re.sub (r'\\defaultAccidentals', "#(set-accidental-style 'default)", str)
- str = re.sub (r'\\voiceAccidentals', "#(set-accidental-style 'voice)", str)
- str = re.sub (r'\\modernAccidentals', "#(set-accidental-style 'modern)", str)
- str = re.sub (r'\\modernCautionaries', "#(set-accidental-style 'modern-cautionary)", str)
- str = re.sub (r'\\modernVoiceAccidental', "#(set-accidental-style 'modern-voice)", str)
- str = re.sub (r'\\modernVoiceCautionaries', "#(set-accidental-style 'modern-voice-cautionary)", str)
- str = re.sub (r'\\pianoAccidentals', "#(set-accidental-style 'piano)", str)
- str = re.sub (r'\\pianoCautionaries', "#(set-accidental-style 'piano-cautionary)", str)
- str = re.sub (r'\\forgetAccidentals', "#(set-accidental-style 'forget)", str)
- str = re.sub (r'\\noResetKey', "#(set-accidental-style 'no-reset)", str)
-
- return str
-
-conversions.append (((2,1,25), conv, """Scheme grob function renaming"""))
-
-
-def conv (str):
- str = re.sub ('ly:set-grob-property!', 'ly:grob-set-property!',str)
- str = re.sub ('ly:set-mus-property!', 'ly:music-set-property!',str)
- str = re.sub ('ly:set-context-property!', 'ly:context-set-property!', str)
- str = re.sub ('ly:get-grob-property', 'ly:grob-property',str)
- str = re.sub ('ly:get-mus-property', 'ly:music-property',str)
- str = re.sub ('ly:get-context-property', 'ly:context-property',str)
-
- return str
-
-conversions.append (((2,1,26), conv, """More Scheme function renaming"""))
-
-def conv (str):
- def subst (m):
- g = string.atoi (m.group (2))
- o = g / 12
- g -= o * 12
- if g < 0:
- g += 12
- o -= 1
-
-
- lower_pitches = filter (lambda x : x <= g, [0, 2, 4, 5, 7, 9, 11, 12])
- s = len (lower_pitches) -1
- a = g - lower_pitches [-1]
-
-
- print s , lower_pitches, g, a, s
- str = 'cdefgab' [s]
- str += ['eses', 'es', '', 'is', 'isis'][a + 2]
- if o < 0:
- str += ',' * (-o - 1)
- elif o >= 0:
- str += "'" * (o + 1)
-
- return '\\transposition %s ' % str
-
-
- str = re.sub (r"\\set ([A-Za-z]+\s*\.\s*)?transposing\s*=\s*#([-0-9]+)",
- subst, str)
- return str
-
-conversions.append (((2,1,27), conv, """property transposing -> tuning"""))
-
-def conv (str):
- str = re.sub (r'make-music-by-name', 'make-music', str)
- str = re.sub (r"\\override\s+.*Arpeggio\s+#.print-function\s+=\s+\\arpeggioBracket", r"\\arpeggioBracket", str)
- return str
-
-conversions.append (((2,1,28), conv,
- """make-music-by-name -> make-music,
-new syntax for setting \\arpeggioBracket"""))
-
-def conv (str):
- str = re.sub (r'\\center([^-])', '\\center-align\\1', str)
- str = re.sub (r'\\translator', '\\context', str)
- return str
-
-conversions.append (((2,1,29), conv,
- '\\center -> \\center-align, \\translator -> \\context'))
-
-
-def conv (str):
- str = re.sub (r'\\threeq(flat|sharp)', r'\\sesqui\1', str)
- str = re.sub (r'ly:stencil-get-extent',
- 'ly:stencil-extent', str)
- str = re.sub (r'ly:translator-find',
- 'ly:context-find', str)
- str = re.sub ('ly:unset-context-property','ly:context-unset-property',
- str)
-
- str = re.sub (r'ly:get-mutable-properties',
- 'ly:mutable-music-properties',str)
- str = re.sub (r'centralCPosition',
- 'middleCPosition',str)
- return str
-
-conversions.append (((2,1,30), conv,
- '''\\threeq{flat,sharp} -> \\sesqui{flat,sharp}
-ly:get-mutable-properties -> ly:mutable-music-properties
-centralCPosition -> middleCPosition
-ly:unset-context-property -> ly:context-unset-property
-ly:translator-find -> ly:context-find
-ly:get-stencil-extent -> ly:stencil-extent
-'''))
-
-
-def conv (str):
- str = re.sub (r'\\alias\s*"?Timing"?', '', str)
- return str
-
-conversions.append (((2,1,31), conv,
- '''remove \\alias Timing'''))
-
-def conv (str):
- str = re.sub (r"(\\set\s+)?(?P<context>(Score\.)?)breakAlignOrder\s*=\s*#'(?P<list>[^\)]+)",
- r"\n\\override \g<context>BreakAlignment #'break-align-orders = "
- + "#(make-vector 3 '\g<list>)", str)
-
- return str
-
-conversions.append (((2,1,33), conv,
- '''breakAlignOrder -> break-align-orders.'''))
-
-def conv (str):
- str = re.sub (r"\(set-paper-size",
- "(set-default-paper-size",str)
- return str
-
-conversions.append (((2,1,34), conv,
- '''set-paper-size -> set-default-paper-size.'''))
-
-def conv (str):
- str = re.sub (r"ly:mutable-music-properties",
- "ly:music-mutable-properties", str)
- return str
-
-conversions.append (((2,1, 36), conv,
- '''ly:mutable-music-properties -> ly:music-mutable-properties'''))
-
-
-
-def conv (str):
- return str
-
-conversions.append (((2, 2, 0), conv,
- '''clean up version. '''))
-
-def conv (str):
- return re.sub (r'\\apply\b', r'\\applymusic', str)
-
-conversions.append (((2, 3, 1), conv,
- '''\\apply -> \\applymusic'''))
-
-def conv (str):
- if re.search ('textheight', str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "textheight")
- sys.stderr.write ('\n')
- sys.stderr.write (UPDATE_MANUALLY)
- sys.stderr.write ('\n')
- sys.stderr.write (
-"""Page layout has been changed, using paper size and margins.
-textheight is no longer used.
-""")
- str = re.sub (r'\\OrchestralScoreContext', '\\Score', str)
- def func(m):
- if m.group(1) not in ['RemoveEmptyStaff',
- 'AncientRemoveEmptyStaffContext',
- 'EasyNotation']:
- return '\\' + m.group (1)
- else:
- return m.group (0)
-
-
- str = re.sub (r'\\([a-zA-Z]+)Context\b', func, str)
- str = re.sub ('ly:paper-lookup', 'ly:output-def-lookup', str)
- return str
-
-conversions.append (((2, 3, 2), conv,
- '''\\FooContext -> \\Foo'''))
-
-def conv (str):
- str = re.sub (r'\\notes\b', '', str)
-
- return str
-
-conversions.append (((2, 3, 4), conv,
- '''remove \\notes'''))
-
-
-
-def conv (str):
- str = re.sub (r'lastpagefill\s*=\s*"?1"', 'raggedlastbottom = ##t', str)
- return str
-
-conversions.append (((2, 3, 6), conv,
- '''lastpagefill -> raggedlastbottom'''))
-
-
-
-def conv (str):
- str = re.sub (r'\\consistsend', '\\consists', str)
- str = re.sub (r'\\lyricsto\s+("?[a-zA-Z]+"?)(\s*\\new Lyrics\s*)?\\lyrics',
- r'\\lyricsto \1 \2', str)
- return str
-
-conversions.append (((2, 3, 8), conv,
- '''remove \\consistsend, strip \\lyrics from \\lyricsto.'''))
-
-def conv (str):
- str = re.sub (r'neo_mensural', 'neomensural', str)
- str = re.sub (r'if-text-padding', 'bound-padding', str)
- return str
-
-conversions.append (((2, 3, 9), conv,
- '''neo_mensural -> neomensural, if-text-padding -> bound-padding'''))
-
-
-
-def conv (str):
- str = re.sub (r'\\addlyrics', r'\\oldaddlyrics', str)
- str = re.sub (r'\\newlyrics', r'\\addlyrics', str)
- if re.search (r"\\override\s*TextSpanner", str):
- sys.stderr.write ("\nWarning: TextSpanner has been split into DynamicTextSpanner and TextSpanner\n")
- return str
-
-conversions.append (((2, 3, 10), conv,
- '''\\addlyrics -> \\oldaddlyrics, \\newlyrics -> \\addlyrics'''))
-
-def conv (str):
- str = re.sub (r'\\setMmRestFermata\s+(R[0-9.*/]*)',
- r'\1^\\fermataMarkup', str)
- return str
-
-conversions.append (((2, 3, 11), conv,
- '''\\setMmRestFermata -> ^\\fermataMarkup'''))
-
-def conv (str):
- str = re.sub (r'\\newpage', r'\\pageBreak', str)
- str = re.sub (r'\\scriptUp', r"""{
- \\override TextScript #'direction = #1
- \\override Script #'direction = #1
-}""", str)
- str = re.sub (r'\\scriptDown', r"""{
- \\override TextScript #'direction = #-1
- \\override Script #'direction = #-1
-}""", str)
- str = re.sub (r'\\scriptBoth', r"""{
- \\revert TextScript #'direction
- \\revert Script #'direction
-}""", str)
- str = re.sub ('soloADue', 'printPartCombineTexts', str)
- str = re.sub (r'\\applymusic\s*#notes-to-clusters',
- '\\makeClusters', str)
-
- str = re.sub (r'pagenumber\s*=', 'firstpagenumber = ', str)
- return str
-
-conversions.append (((2, 3, 12), conv,
- '''\\newpage -> \\pageBreak, junk \\script{up,down,both},
-soloADue -> printPartCombineTexts, #notes-to-clusters -> \\makeClusters
-'''))
-
-
-def conv (str):
- str = re.sub (r'\\chords\b', r'\\chordmode', str)
- str = re.sub (r'\\lyrics\b', r'\\lyricmode', str)
- str = re.sub (r'\\figures\b', r'\\figuremode', str)
- str = re.sub (r'\\notes\b', r'\\notemode', str)
- str = re.sub (r'\\drums\b', r'\\drummode', str)
- str = re.sub (r'\\chordmode\s*\\new ChordNames', r'\\chords', str)
- str = re.sub (r'\\new ChordNames\s*\\chordmode', r'\\chords', str)
- str = re.sub (r'\\new FiguredBass\s*\\figuremode', r'\\figures', str)
- str = re.sub (r'\\figuremode\s*\new FiguredBass', r'\\figures', str)
- str = re.sub (r'\\new DrumStaff\s*\\drummode', r'\\drums', str)
- str = re.sub (r'\\drummode\s*\\new DrumStaff', r'\\drums', str)
-
- return str
-
-conversions.append (((2, 3, 16), conv,
- '''\foo -> \foomode (for chords, notes, etc.)
-fold \new FooContext \foomode into \foo.'''))
-
-def conv (str):
- str = re.sub (r'(slur|stem|phrasingSlur|tie|dynamic|dots|tuplet|arpeggio|)Both', r'\1Neutral', str)
- str = re.sub (r"\\applymusic\s*#\(remove-tag\s*'([a-z-0-9]+)\)",
- r"\\removeWithTag #'\1", str)
- return str
-
-conversions.append (((2, 3, 17), conv,
- '''\foo -> \foomode (for chords, notes, etc.)
-fold \new FooContext \foomode into \foo.'''))
-
-
-def conv (str):
- str = re.sub (r'Text_item', 'Text_interface', str)
- return str
-
-conversions.append (((2, 3, 18),
- conv,
- '''Text_item -> Text_interface''' ))
-
-def conv (str):
- str = re.sub (r'\\paper', r'\\layout', str)
- str = re.sub (r'\\bookpaper', r'\\paper', str)
- if re.search ('paper-set-staff-size', str):
- sys.stderr.write ('''\nWarning: staff size should be changed at top-level
-with
-
- #(set-global-staff-size <STAFF-HEIGHT-IN-POINT>)
-
-''')
-
-
- str = re.sub (r'#\(paper-set-staff-size', '%Use set-global-staff-size at toplevel\n% #(layout-set-staff-size', str)
- return str
-
-conversions.append (((2, 3, 22),
- conv,
- '''paper -> layout
- bookpaper -> paper''' ))
-
-
-def conv (str):
- str = re.sub (r'\\context\s+([a-zA-Z]+)\s*=\s*([a-z]+)\s',
- r'\\context \1 = "\2" ',
- str )
- return str
-
-conversions.append (((2, 3, 23),
- conv,
- '''\context Foo = NOTENAME -> \context Foo = "NOTENAME"'''))
-
-def conv (str):
- def sub(m):
- return regularize_id (m.group (1))
- str = re.sub (r'(maintainer_email|maintainer_web|midi_stuff|gourlay_maxmeasures)',
- sub, str)
- return str
-
-conversions.append (((2, 3, 24),
- conv,
- '''regularize other identifiers.'''))
-
-
-def conv (str):
- return str
-
-conversions.append (((2, 4, 0),
- conv,
- ''))
-
-
-def conv (str):
- str = re.sub (r'\\quote\s+"?([a-zA-Z0-9]+)"?\s+([0-9.*/]+)',
- r'\\quoteDuring #"\1" { \skip \2 }',
- str
- )
- return str
-
-conversions.append (((2, 5, 0),
- conv,
- ''))
-
-
-def conv (str):
- str = re.sub (r'ly:import-module',
- r'ly:module-copy', str)
- return str
-
-conversions.append (((2, 5, 1),
- conv,
- 'ly:import-module -> ly:module-copy'))
-
-def conv (str):
- str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
- r'\\\1 {\2}', str)
- str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
- r'\\\1 {\2}', str)
- str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
- r'\\\1 {\2}', str)
- def get_markup (m):
- s = m.group (0)
- s = re.sub (r'''((\\"|})\s*){''', '\2 \\line {', s)
- return s
- str = re.sub (r'\\markup\s*{([^}]|{[^}]*})*}', get_markup, str)
- return str
-
-conversions.append (((2, 5, 2),
- conv,
- '\markup .. < .. > .. -> \markup .. { .. } ..'))
-
-def conv (str):
- str = re.sub ('ly:find-glyph-by-name', 'ly:font-get-glyph', str)
- str = re.sub ('"(scripts|clefs|accidentals)-', r'"\1.', str)
- str = re.sub ("'hufnagel-do-fa", "'hufnagel.do.fa", str)
- str = re.sub ("'(vaticana|hufnagel|medicaea|petrucci|neomensural|mensural)-", r"'\1.", str)
- return str
-
-conversions.append (((2, 5, 3),
- conv,
- 'ly:find-glyph-by-name -> ly:font-get-glyph, remove - from glyphnames.'))
-
-
-def conv (str):
- str = re.sub (r"\\override\s+(Voice\.)?Slur #'dashed\s*=\s*#\d*(\.\d+)?",
- r"\\slurDashed", str)
- return str
-
-conversions.append (((2, 5, 12),
- conv,
- '\set Slur #\'dashed = #X -> \slurDashed'))
-
-def conv (str):
- input_encoding = 'latin1'
- def func (match):
- encoding = match.group (1)
-
- # FIXME: automatic recoding of other than latin1?
- if encoding == 'latin1':
- return match.group (2)
-
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % ("\\encoding: %s" % encoding))
- sys.stderr.write ('\n')
- sys.stderr.write (_ ("LilyPond source must be UTF-8"))
- sys.stderr.write ('\n')
- if encoding == 'TeX':
- sys.stderr.write (_ ("Try the texstrings backend"))
- sys.stderr.write ('\n')
- else:
- sys.stderr.write ( _("Do something like: %s") % \
- ("recode %s..utf-8 FILE" % encoding))
- sys.stderr.write ('\n')
- sys.stderr.write (_ ("Or save as UTF-8 in your editor"))
- sys.stderr.write ('\n')
- raise FatalConversionError ()
-
- return match.group (0)
-
- str = re.sub (r'\\encoding\s+"?([a-zA-Z0-9]+)"?(\s+)', func, str)
-
- import codecs
- de_ascii = codecs.getdecoder ('ascii')
- de_utf_8 = codecs.getdecoder ('utf_8')
- de_input = codecs.getdecoder (input_encoding)
- en_utf_8 = codecs.getencoder ('utf_8')
- try:
- de_ascii (str)
- # only in python >= 2.3
- # except UnicodeDecodeError:
- except UnicodeError:
- # do not re-recode UTF-8 input
- try:
- de_utf_8 (str)
- #except UnicodeDecodeError:
- except UnicodeError:
- str = en_utf_8 (de_input (str)[0])[0]
-
-
-
- str = re.sub (r"#\(ly:set-point-and-click '[a-z-]+\)", '', str)
- return str
-
-conversions.append (((2, 5, 13),
- conv,
- '\\encoding: smart recode latin1..utf-8. Remove ly:point-and-click'))
-
-
-def conv (str):
- if re.search ("ly:stencil-set-extent!", str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "ly:stencil-set-extent!")
- sys.stderr.write ('\n')
- sys.stderr.write ('use (set! VAR (ly:make-stencil (ly:stencil-expr VAR) X-EXT Y-EXT))\n')
- raise FatalConversionError ()
- if re.search ("ly:stencil-align-to!", str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "ly:stencil-align-to!")
- sys.stderr.write ('\n')
- sys.stderr.write ('use (set! VAR (ly:stencil-aligned-to VAR AXIS DIR))\n')
- raise FatalConversionError ()
- return str
-
-conversions.append (((2, 5, 17),
- conv,
- 'ly:stencil-set-extent! removed'))
-
-def conv (str):
- str = re.sub (r"ly:warn\b", 'ly:warning', str)
- return str
-
-conversions.append (((2, 5, 18),
- conv,
- 'ly:warn -> ly:warning'))
-def conv (str):
- if re.search ("(override-|revert-)auto-beam-setting", str)\
- or re.search ("autoBeamSettings", str):
- sys.stderr.write ('\n')
- sys.stderr.write (NOT_SMART % "auto beam settings")
- sys.stderr.write ('\n')
- sys.stderr.write ('''
-Auto beam settings must now specify each interesting moment in a measure
-explicitely; 1/4 is no longer multiplied to cover moments 1/2 and 3/4 too.
+ convert-ly -e old.ly
+ convert-ly --from=2.3.28 --to 2.5.21 foobar.ly
''')
- sys.stderr.write (UPDATE_MANUALLY)
- sys.stderr.write ('\n')
- raise FatalConversionError ()
- return str
-
-conversions.append (((2, 5, 21),
- conv,
- 'warn about auto beam settings'))
-def conv (str):
- str = re.sub (r"unfoldrepeats", 'unfoldRepeats', str)
- str = re.sub (r"compressmusic", 'compressMusic', str)
- return str
+copyright = ('Jan Nieuwenhuizen <janneke@gnu.org>',
+ 'Han-Wen Nienhuys <hanwen@cs.uu.nl>')
-conversions.append (((2, 5, 25), conv,
+option_definitions = [
+ ('', 'e', 'edit',_('edit in place')),
+ (_('VERSION'), 'f', 'from',
+ _('start from VERSION [default: \\version found in file]')),
+ ('', 'h', 'help',_('print this help')),
+ ('', 'n', 'no-version',_ ('do not add \\version command if missing')),
+ ('','s', 'show-rules', _('print rules [default: --from=0, --to=@TOPLEVEL_VERSION@]')),
+ (_('VERSION'), 't', 'to',_('convert to VERSION [default: @TOPLEVEL_VERSION@]')),
+ ('','v','version',_('print program version"'))
+]
- 'unfoldrepeats -> unfoldRepeats,'
- + 'compressmusic -> compressMusic'))
-
-################################
-# END OF CONVERSIONS
-################################
-
-def get_conversions (from_version, to_version):
- def version_b (v, f = from_version, t = to_version):
- return version_cmp (v[0], f) > 0 and version_cmp (v[0], t) <= 0
- return filter (version_b, conversions)
-
-
-def latest_version ():
- return conversions[-1][0]
-
-def do_conversion (infile, from_version, outfile, to_version):
- conv_list = get_conversions (from_version, to_version)
-
- sys.stderr.write (_ ("Applying conversion: "))
- str = infile.read ()
- last_conversion = ()
- try:
- for x in conv_list:
- sys.stderr.write (tup_to_str (x[0]))
- if x != conv_list[-1]:
- sys.stderr.write (', ')
- str = x[1] (str)
- last_conversion = x[0]
+program_name = os.path.basename (sys.argv[0])
+program_version = '@TOPLEVEL_VERSION@'
- except FatalConversionError:
- sys.stderr.write (_ ("%s: error while converting") \
- % program_name)
- sys.stderr.write ('\n')
- sys.stderr.write (_ ("Aborting"))
- sys.stderr.write ('\n')
- if last_conversion:
- new_ver = '\\version \"%s\"' % tup_to_str (last_conversion)
+add_version = 1
- if re.search (lilypond_version_re_str, str):
- str = re.sub (lilypond_version_re_str,
- '\\%s' % new_ver, str)
- elif add_version:
- str = new_ver + '\n' + str
+def guess_lilypond_version (filename):
+ s = open (filename).read ()
+ m = lilypond_version_re.search (s)
+ if m:
+ return m.group (1)
+ else:
+ return ''
- sys.stderr.write ('\n')
- outfile.write (str)
+class FatalConversionError:
+ pass
- return last_conversion
+conversions = []
class UnknownVersion:
pass
else:
infile = sys.stdin
- if outfile_name:
- outfile = open (outfile_name, 'w')
- else:
- outfile = sys.stdout
- touched = do_conversion (infile, from_version, outfile, to_version)
+ (last, result) = do_conversion (infile.read (), from_version, to_version)
+ infile.close ()
- if infile_name:
- infile.close ()
- if outfile_name:
- outfile.close ()
+ if last:
+ newversion = r'\version "%s"' % tup_to_str (last)
+ if lilypond_version_re.search (result):
+ result = re.sub (lilypond_version_re_str,
+ '\\' + newversion, result)
+ elif add_version:
+ result = newversion + '\n' + result
+
+ error_file.write ('\n')
+
+ if __main__.edit:
+ try:
+ os.remove(infile_name + '~')
+ except:
+ pass
+ os.rename (infile_name, infile_name + '~')
+ outfile = open (infile_name, 'w')
+ else:
+ outfile = sys.stdout
- if __main__.edit and touched:
- try:
- os.remove(infile_name + '~')
- except:
- pass
- os.rename (infile_name, infile_name + '~')
- os.rename (infile_name + '.NEW', infile_name)
+
+ outfile.write (result)
sys.stderr.flush ()
edit = 0
-assume_old = 0
to_version = ()
from_version = ()
outfile_name = ''
show_rules_p = 0
-(options, files) = getopt.getopt (sys.argv[1:], 'ao:f:t:senhv',
- ['no-version', 'version', 'output',
- 'show-rules', 'help', 'edit',
- 'from=', 'to='])
+def do_options ():
+ global from_version, to_version, edit, show_rules_p, add_version
-for opt in options:
- o = opt[0]
- a = opt[1]
- if o == '--help' or o == '-h':
- usage ()
- sys.exit (0)
- elif o == '--version' or o == '-v':
- print_version ()
- sys.exit (0)
- elif o== '--from' or o=='-f':
- from_version = str_to_tuple (a)
- elif o== '--to' or o=='-t':
- to_version = str_to_tuple (a)
- elif o== '--edit' or o == '-e':
- edit = 1
- elif o== '--show-rules' or o == '-s':
- show_rules_p = 1
- elif o == '--output' or o == '-o':
- outfile_name = a
- elif o == '--no-version' or o == '-n':
- add_version = 0
- else:
- print o
- raise getopt.error
+ (sh, long) = ly.getopt_args (option_definitions)
+ try:
+ (options, files) = getopt.getopt (sys.argv[1:], sh, long)
+ except getopt.error, s:
+ sys.stderr.write ('\n')
+ ly.error (_ ("getopt says: `%s'" % s))
+ sys.stderr.write ('\n')
+ ly.help ()
+ ly.exit (2)
+
+ for opt in options:
+ o = opt[0]
+ a = opt[1]
+
+ if o == '--help' or o == '-h':
+ ly.help ()
+ sys.exit (0)
+ elif o == '--version' or o == '-v':
+ ly.identify (sys.stdout)
+ sys.exit (0)
+ elif o== '--from' or o=='-f':
+ from_version = str_to_tuple (a)
+ elif o== '--to' or o=='-t':
+ to_version = str_to_tuple (a)
+ elif o== '--edit' or o == '-e':
+ edit = 1
+ elif o== '--show-rules' or o == '-s':
+ show_rules_p = 1
+ elif o == '--no-version' or o == '-n':
+ add_version = 0
+ else:
+ print o
+ raise getopt.error
-# should parse files[] to read \version?
-if show_rules_p:
- show_rules (sys.stdout)
- sys.exit (0)
+ return files
-identify ()
-if not files:
- usage ()
- sys.exit (2)
+def main ():
+ files = do_options ()
-for f in files:
- if f == '-':
- f = ''
- elif not os.path.isfile (f):
- sys.stderr.write ('\n')
- sys.stderr.write (_ ("can't open file: `%s'") % f)
- sys.stderr.write ('\n')
- if len (files) == 1:
- sys.exit (1)
- continue
- try:
- do_one_file (f)
- except UnknownVersion:
- sys.stderr.write ('\n')
- sys.stderr.write (_ ("%s: can't determine version for `%s'") \
- % (program_name, f))
- sys.stderr.write ('\n')
- if assume_old:
- fv = from_version
- from_version = (0, 0, 0)
+ # should parse files[] to read \version?
+ if show_rules_p:
+ show_rules (sys.stdout, from_version, to_version)
+ sys.exit (0)
+
+ ly.identify (sys.stderr)
+
+ if not files:
+ ly.help ()
+ sys.exit (2)
+
+ for f in files:
+ if f == '-':
+ f = ''
+ elif not os.path.isfile (f):
+ ly.error (_ ("can't open file: `%s'") % f)
+ if len (files) == 1:
+ sys.exit (1)
+ continue
+ try:
do_one_file (f)
- from_version = fv
- else:
- sys.stderr.write (_ ("%s: skipping: `%s'") \
- % (program_name, f))
- pass
+ except UnknownVersion:
+ ly.error (_ ("can't determine version for `%s'. Skipping") % f)
+
+ sys.stderr.write ('\n')
-sys.stderr.write ('\n')
+main ()
# and customize variables below.
# We'll suffer this path initialization stuff as long as we don't install
-# our python packages in <prefix>/lib/pythonX.Y (and don't kludge around
-# it as we do with teTeX on Red Hat Linux: set some environment variables
-# (PYTHONPATH) in `etc/profile').
+# our python packages in <prefix>/lib/pythonX.Y
# If set, LILYPONDPREFIX must take prevalence.
# if datadir is not set, we're doing a build and LILYPONDPREFIX.
+++ /dev/null
-# title top level makefile for FlowerLib
-# file flower/Makefile
-
-# should reinstate versioning if shared libs are enabled.
-
-depth = ..
-
-NAME = ttftool
-MODULE_NAME = ttftool
-SUBDIRS = include
-
-SCRIPTS =
-README_FILES = README
-EXTRA_DIST_FILES = $(README_FILES) $(SCRIPTS)
-STEPMAKE_TEMPLATES = library c po
-
-MODULE_CFLAGS = $(TTFTOOL_ENDIAN)
-
-include $(depth)/make/stepmake.make
-
-
+++ /dev/null
-
-This is the ttfps 0.3 utility by Juliusz Chroboczek,
-
- http://www.pps.jussieu.fr/~jch/software/file/
-
-ttfps is effectively in the public domain, given the copyright notice
-by Juliusz,
-
-
- Copying
- *******
-
- This software is provided with no guarantee, not even of any kind.
-
- Feel free to do whatever you wish with it as long as you don't ask me
- to maintain it.
-
-
+++ /dev/null
-# -*-python-*-
-
-Import ('env', 'src_glob')
-sources = src_glob ('*.c')
-includes = src_glob ('include/*.h')
-outdir = Dir ('.').path
-
-name = 'ttftool'
-e = env.Copy ()
-e.Append (CPPPATH = ['#/flower/include', '#/ttftool/include', outdir],
- # sigh
- CPPDEFINES = ['-D${BYTEORDER}ENDIAN', '-DSMALLENDIAN=LITTLEENDIAN'],)
-if env['static']:
- e.Library (name, sources)
-if not env['static'] or env['shared']:
- e.SharedLibrary (name, sources)
-
-po = env.Command ('lilypond.po', sources + includes, env['pocommand'])
-env.Alias ('po-update', po)
+++ /dev/null
-/* Copyright (c) 1997-1998 by Juliusz Chroboczek */
-
-#define NULL ((void *)0)
-
-/* char *macEncoding[]={ */
-/* ".notdef", NULL, NULL, NULL, NULL, NULL, */
-/* NULL, NULL, NULL, NULL, NULL, NULL, */
-/* NULL, NULL, NULL, NULL, NULL, NULL, */
-/* NULL, NULL, NULL, NULL, NULL, NULL, */
-/* NULL, NULL, NULL, NULL, NULL, NULL, */
-/* NULL, NULL, "space", "exclam", "quotedbl", "numbersign", */
-/* "dollar", "percent", "ampersand", "quoteright", "parenleft", */
-/* "parenright", "asterisk", "plus", "comma", "hyphen", "period", */
-/* "slash", "zero", "one", "two", "three", "four", "five", "six", */
-/* "seven", "eight", "nine", "colon", "semicolon", "less", "equal", */
-/* "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", */
-/* "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", */
-/* "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", */
-/* "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", */
-/* "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", */
-/* "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", */
-/* "tilde", NULL, "Adieresis", "Aring", "Ccedilla", "Eacute", */
-/* "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", */
-/* "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", */
-/* "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", */
-/* "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", */
-/* "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", */
-/* "degree", "cent", "sterling", "section", "bullet", "paragraph", */
-/* "germandbls", "registered", "copyright", "trademark", "acute", */
-/* "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", */
-/* "lessequal", "greaterequal", "yen", "mu", "partialdiff", "Sigma", */
-/* "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", */
-/* "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", */
-/* "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", */
-/* "ellipsis", "space", "Agrave", "Atilde", "Otilde", "OE", "oe", */
-/* "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", */
-/* "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", */
-/* "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", */
-/* "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", */
-/* "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", */
-/* "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", */
-/* "Ocircumflex", NULL, "Ograve", "Uacute", "Ucircumflex", "Ugrave", */
-/* "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", */
-/* "ring", "cedilla", "hungarumlaut", "ogonek", "caron"}; */
-
-char *macGlyphEncoding[] = {
- ".notdef", ".null", "CR", "space", "exclam", "quotedbl", "numbersign",
- "dollar", "percent", "ampersand", "quotesingle", "parenleft",
- "parenright", "asterisk", "plus", "comma", "hyphen", "period",
- "slash", "zero", "one", "two", "three", "four", "five", "six",
- "seven", "eight", "nine", "colon", "semicolon", "less", "equal",
- "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H",
- "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
- "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright",
- "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f",
- "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
- "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright",
- "asciitilde", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde",
- "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex",
- "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave",
- "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex",
- "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis",
- "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger",
- "degree", "cent", "sterling", "section", "bullet", "paragraph",
- "germandbls", "registered", "copyright", "trademark", "acute",
- "dieresis", "notequal", "AE", "Oslash", "infinity", "plusinus",
- "lessequal", "greaterequal", "yen", "mu1", "partialdiff", "summation",
- "product", "pi", "integral", "ordfeminine", "ordmasculine", "Ohm",
- "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical",
- "florin", "approxequal", "increment", "guillemotleft",
- "guillemotright", "ellipsis", "nbspace", "Agrave", "Atilde", "Otilde",
- "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright",
- "quoteleft", "quoteright", "divide", "lozenge", "ydieresis",
- "Ydieresis", "fraction", "currency", "guilsingleft", "guilsingright",
- "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase",
- "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute",
- "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave",
- "Oacute", "Ocircumflex", "applelogo", "Ograve", "Uacute",
- "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde",
- "overscore", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut",
- "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron", "Zcaron",
- "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn",
- "thorn", "minus", "multiply", "onesuperior", "twosuperior",
- "threesuperior", "onehalf", "onequarter", "threequarters", "franc",
- "Gbreve", "gbreve", "Idot", "Scedilla", "scedilla", "Cacute",
- "cacute", "Ccaron", "ccaron", "dmacron"
-};
-
-char *adobeStandardEncoding[] = {
- ".notdef", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- "space", "exclam", "quotedbl", "numbersign", "dollar", "percent",
- "ampersand", "quoteright",
- "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period",
- "slash",
- "zero", "one", "two", "three", "four", "five", "six", "seven",
- "eight", "nine", "colon", "semicolon", "less", "equal", "greater",
- "question",
- "at", "A", "B", "C", "D", "E", "F", "G",
- "H", "I", "J", "K", "L", "M", "N", "O",
- "P", "Q", "R", "S", "T", "U", "V", "W",
- "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum",
- "underscore",
- "quoteleft", "a", "b", "c", "d", "e", "f", "g",
- "h", "i", "j", "k", "l", "m", "n", "o",
- "p", "q", "r", "s", "t", "u", "v", "w",
- "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, "exclamdown", "cent", "sterling", "fraction", "yen", "florin",
- "section",
- "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft",
- "guilsinglright", "fi", "fl",
- NULL, "endash", "dagger", "daggerdbl", "periodcentered", NULL, "paragraph",
- "bullet",
- "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright",
- "ellipsis", "perthousand", NULL, "questiondown",
- NULL, "grave", "acute", "circumflex", "tilde", "macron", "breve",
- "dotaccent",
- "dieresis", NULL, "ring", "cedilla", NULL, "hungarumlaut", "ogonek",
- "caron",
- "emdash", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, "AE", NULL, "ordfeminine", NULL, NULL, NULL, NULL,
- "Lslash", "Oslash", "OE", "ordmasculine", NULL, NULL, NULL, NULL,
- NULL, "ae", NULL, NULL, NULL, "dotlessi", NULL, NULL,
- "lslash", "oslash", "oe", "germandbls", NULL, NULL, NULL, NULL
-};
+++ /dev/null
-# ttftool/lib/include/Makefile
-
-depth = ../..
-
-STEPMAKE_TEMPLATES=c
-
-include $(depth)/make/stepmake.make
-
-
+++ /dev/null
-/* Copyright (c) 1997-1998 by Juliusz Chroboczek */
-
-struct TableDirectoryEntry *readDirectory (FILE *fd, struct OffsetTable *ot);
-char **readNamingTable (FILE *fd);
-void readHeadTable (FILE *fd, struct HeadTable *ht);
-int readPostTable (FILE *fd, int nglyphs,
- struct PostTable *pt, struct GlyphName **gnt);
-int readMaxpTable (FILE *fd);
-void *readLocaTable (FILE *fd, int nglyphs, int format);
-struct Box *readGlyfTable (FILE *fd, int nglyphs, int format, void *loca);
-longHorMetric *readHmtxTable (FILE *fd, int nummetrics);
-struct HheaTable *readHheaTable (FILE *fd);
-int readKernTable (FILE *fd, int **nke, struct KernEntry0 ***ke);
-
-void printPSFont (void * out, struct HeadTable *ht,
- char **strings, int nglyphs, int postType,
- struct PostTable *pt, struct GlyphName *gnt, FILE *fd);
-
-void printPSHeader (void * out, struct HeadTable *ht,
- char **strings, struct PostTable *pt);
-void printPSData (void * out, FILE *fd);
-void printPSTrailer (void * out, int nglyphs,
- int postType, struct GlyphName *gnt);
-
-void printAFM (FILE * afm, struct HeadTable *ht,
- char **strings, int nglyphs, int postType,
- struct PostTable *pt, struct GlyphName *gnt,
- struct Box *glyf, struct HheaTable *hhea, longHorMetric * hmtx,
- int nkern, int *nke, struct KernEntry0 **ke);
-void printAFMHeader (FILE * afm, struct HeadTable *ht,
- char **strings, struct PostTable *pt);
-void printAFMMetrics (FILE * afm, struct HeadTable *ht,
- int nglyphs, int postType, struct GlyphName *gnt,
- struct Box *bbox,
- struct HheaTable *hhea, longHorMetric * hmtx);
-void printOneAFMMetric (FILE * afm,
- int index, int code, char *name,
- struct HeadTable *ht,
- struct Box *bbox,
- struct HheaTable *hhea, longHorMetric * hmtx);
-void printAFMKerning (FILE * afm, struct HeadTable *ht,
- int postType, struct GlyphName *gnt,
- int nkern, int *nke, struct KernEntry0 **ke);
-
-extern char *macGlyphEncoding[];
-extern char *adobeStandardEncoding[];
-
-void *mymalloc (size_t size);
-void *mycalloc (size_t nelem, size_t elsize);
-void *myrealloc (void *ptr, size_t size);
-void ttf_error (char *string);
-void syserror (char *string);
-ssize_t surely_read (FILE *fildes, void *buf, size_t nbyte);
-char *unistrncpy (char *dst, char *str, size_t length);
-void fputpss (char *s, void * stream);
-void surely_lseek (FILE *fildes, off_t offset, int whence);
-unsigned hash (char *string);
-struct hashtable *make_hashtable (int size);
-int puthash (struct hashtable *t, char *key, int value);
-int gethash (struct hashtable *t, char *key);
-
-#ifdef TEST_TTFTOOL
-#define lily_cookie_fclose fclose
-#define lily_cookie_fprintf fprintf
-#define lily_cookie_putc fputc
-#else
-#include "file-cookie.hh"
-#endif
+++ /dev/null
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
- void create_type42 (char const *, void *);
- extern int ttf_verbosity;
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/* Copyright (c) 1997-1998 by Juliusz Chroboczek */
-
-
-typedef unsigned char BYTE;
-typedef signed char CHAR;
-typedef unsigned short USHORT;
-typedef short SHORT;
-typedef unsigned long ULONG;
-typedef long LONG;
-
-/* Endianness conversions */
-#ifdef SMALLENDIAN
-#define H(x) ((SHORT)((((SHORT)(x))&0xFF)<<8)+(((USHORT)(x))>>8))
-#define UH(x) ((USHORT)((((USHORT)(x))&0xFF)<<8)+(((USHORT)(x))>>8))
-#define L(x) ((LONG)(((LONG)UH((x)&0xFFFF))<<16)+UH(((ULONG)(x))>>16))
-#define UL(x) ((ULONG)(((ULONG)UH((x)&0xFFFF))<<16)+UH(((ULONG)(x))>>16))
-#else
-#define H(x) ((SHORT)x)
-#define UH(x) ((USHORT)x)
-#define L(x) ((LONG)x)
-#define UL(x) ((ULONG)x)
-#endif
-
-#define FIX_H(x) x=H(x)
-#define FIX_UH(x) x=UH(x)
-#define FIX_L(x) x=L(x)
-#define FIX_UL(x) x=UL(x)
-
-/* We are assuming that the compiler will not pad the following
- * structures; note that their members are intrinsically properly
- * aligned. This will probably break on some machines. */
-
-typedef struct
-{
- SHORT mantissa;
- USHORT fraction;
-} Fixed;
-
-#define FIX_Fixed(x) {(x).mantissa=H((x).mantissa); (x).fraction=UH((x).fraction);}
-
-typedef struct
-{
- BYTE data[8];
-} longDateTime;
-
-typedef USHORT uFWord;
-typedef SHORT FWord;
-typedef USHORT F2Dot14;
-
-#define MAKE_ULONG(a,b,c,d) ((ULONG)(((ULONG)(a)<<24)|((b)<<16)|((c)<<8)|(d)))
-
-/*------------------------------------------------------------*/
-
-struct OffsetTable
-{
- Fixed version;
- USHORT numTables;
- USHORT searchRange;
- USHORT entrySelector;
- USHORT rangeShift;
-};
-#define FIX_OffsetTable(x) \
- {FIX_Fixed((x).version);\
- FIX_UH((x).numTables);\
- FIX_UH((x).searchRange);\
- FIX_UH((x).entrySelector);}
-
-struct TableDirectoryEntry
-{
- ULONG tag;
- ULONG checkSum;
- ULONG offset;
- ULONG length;
-};
-#define FIX_TableDirectoryEntry(x) \
- {FIX_UL((x).tag); FIX_UL((x).checkSum);\
- FIX_UL((x).offset); FIX_UL((x).length);}
-
-/*------------------------------------------------------------*/
-
-struct HeadTable
-{
- Fixed version;
- Fixed fontRevision;
- ULONG checkSumAdjustment;
- ULONG magicNumber;
- USHORT flags;
- USHORT unitsPerEm;
- longDateTime created;
- longDateTime modified;
- FWord xMin;
- FWord yMin;
- FWord xMax;
- FWord yMax;
- USHORT macStyle;
- USHORT lowestRecPPEM;
- SHORT fontDirectionHint;
- SHORT indexToLocFormat;
- SHORT glyphDataFormat;
-};
-#define FIX_HeadTable(x) \
- {FIX_Fixed((x).version); FIX_Fixed((x).fontRevision);\
- FIX_UL((x).checkSumAdjustment); FIX_UL((x).magicNumber);\
- FIX_UH((x).flags); FIX_UH((x).unitsPerEm);\
- FIX_UH((x).xMin); FIX_UH((x).yMin); FIX_UH((x).xMax); FIX_UH((x).yMax);\
- FIX_UH((x).macStyle); FIX_UH((x).lowestRecPPEM);\
- FIX_H((x).fontDirectionHint); FIX_H((x).indexToLocFormat);\
- FIX_H((x).glyphDataFormat);}
-
-
-/*------------------------------------------------------------*/
-
-struct NameRecord
-{
- USHORT platformID;
- USHORT encodingID;
- USHORT languageID;
- USHORT nameID;
- USHORT length;
- USHORT offset;
-};
-#define FIX_NameRecord(x) \
- {FIX_UH((x).platformID); FIX_UH((x).encodingID); FIX_UH((x).languageID);\
- FIX_UH((x).nameID); FIX_UH((x).length); FIX_UH((x).offset);}
-
-
-
-/*------------------------------------------------------------*/
-
-struct PostTable
-{
- Fixed formatType;
- Fixed italicAngle;
- FWord underlinePosition;
- FWord underlineThickness;
- ULONG isFixedPitch;
- ULONG minMemType42;
- ULONG maxMemType42;
- ULONG minMemType1;
- ULONG maxMemType1;
-};
-#define FIX_PostTable(x) \
- {FIX_Fixed((x).formatType); FIX_Fixed((x).italicAngle);\
- FIX_H((x).underlinePosition); FIX_H((x).underlineThickness);\
- FIX_UL((x).isFixedPitch);\
- FIX_UL((x).minMemType42); FIX_UL((x).maxMemType42);\
- FIX_UL((x).minMemType1); FIX_UL((x).maxMemType1); }
-
-struct GlyphName
-{
- int type;
- union
- {
- int index;
- char *name;
- } name;
-};
-
-/*-----------------------------------------------------------------*/
-struct HheaTable
-{
- Fixed version;
- FWord Ascender;
- FWord Descender;
- FWord LineGap;
- uFWord advanceWidthMax;
- FWord minLeftSideBearing;
- FWord minRightSideBearing;
- FWord xMaxExtent;
- SHORT caretSlopeRise;
- SHORT caretSlopeRun;
- SHORT reserved[5];
- SHORT metricDataFormat;
- USHORT numberOfHMetrics;
-};
-#define FIX_HheaTable(x) \
- {FIX_Fixed((x).version); FIX_H((x).Ascender); FIX_H((x).Descender); FIX_H((x).LineGap);\
- FIX_UH((x).advanceWidthMax);\
- FIX_H((x).minLeftSideBearing); FIX_H((x).minRightSideBearing);\
- FIX_H((x).xMaxExtent); FIX_H((x).caretSlopeRise); FIX_H((x).caretSlopeRun);\
- FIX_H((x).metricDataFormat); FIX_UH((x).numberOfHMetrics);}
-
-struct Box
-{
- FWord xMin;
- FWord yMin;
- FWord xMax;
- FWord yMax;
-};
-#define FIX_Box(x) {FIX_H((x).xMin); FIX_H((x).yMin); FIX_H((x).xMax); FIX_H((x).yMax);}
-
-typedef struct
-{
- uFWord advanceWidth;
- FWord lsb;
-} longHorMetric;
-#define FIX_longHorMetric(x) {FIX_UH((x).advanceWidth); FIX_H((x).lsb);}
-
-/*------------------------------------------------------------*/
-struct KernTable
-{
- USHORT version;
- USHORT nTables;
-};
-#define FIX_KernTable(x) {FIX_UH((x).version); FIX_UH((x).nTables);}
-
-struct KernSubTableHeader
-{
- USHORT version;
- USHORT length;
- USHORT coverage;
-};
-#define FIX_KernSubTableHeader(x) \
- {FIX_UH((x).version); FIX_UH((x).length); FIX_UH((x).coverage);}
-
-
-#define kernHorizontal 0x0001
-#define kernMinimum 0x0002
-#define kernCrossStream 0x0004
-#define kernOverride 0x0008
-#define kernFormat(coverage) ((coverage)>>8)
-
-struct KernSubTable0
-{
- USHORT nPairs;
- USHORT searchRange;
- USHORT entrySelector;
- USHORT rangeShift;
-};
-
-#define FIX_KernSubTable0(x) \
- {FIX_UH((x).nPairs); FIX_UH((x).searchRange);\
- FIX_UH((x).entrySelector); FIX_UH((x).rangeShift);}
-
-struct KernEntry0
-{
- USHORT left;
- USHORT right;
- FWord value;
-};
-#define FIX_KernEntry0(x) \
- {FIX_UH((x).left); FIX_UH((x).right); FIX_H((x).value);}
-
-
-/*------------------------------------------------------------*/
-/* Hashtables */
-
-struct hashtable_entry
-{
- char *key;
- int value;
-};
-
-struct hashtable_bucket
-{
- int size;
- int nentries;
- struct hashtable_entry *entries;
-};
-
-struct hashtable
-{
- int size;
- struct hashtable_bucket **buckets;
-};
+++ /dev/null
-/* Copyright (c) 1997-1998 by Juliusz Chroboczek */
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "types.h"
-#include "proto.h"
-#include "ttftool.h"
-
-struct TableDirectoryEntry *
-readDirectory (FILE *fd, struct OffsetTable *ot)
-{
- unsigned n;
- int i;
-
- struct TableDirectoryEntry *td;
-
- surely_read (fd, ot, sizeof (struct OffsetTable));
- FIX_OffsetTable (*ot);
- if (ttf_verbosity >= 2)
- fprintf (stderr, "%d tables\n", ot->numTables);
-
- n = sizeof (struct TableDirectoryEntry) * ot->numTables;
- td = mymalloc (n);
- surely_read (fd, td, n);
- for (i = 0; i < ot->numTables; i++)
- FIX_TableDirectoryEntry (td[i]);
- return td;
-}
-
-char **
-readNamingTable (FILE *fd)
-{
- USHORT format;
- USHORT nrecords;
- off_t position;
- USHORT offset;
- int i, index, maxIndex;
- struct NameRecord *records;
- char *data;
- char **strings;
-
- position = ftell (fd);
-
- surely_read (fd, &format, sizeof (USHORT));
- FIX_UH (format);
- if (format != 0)
- ttf_error ("Format should be 0\n");
-
- surely_read (fd, &nrecords, sizeof (USHORT));
- FIX_UH (nrecords);
- surely_read (fd, &offset, sizeof (USHORT));
- FIX_UH (offset);
- records = mymalloc (nrecords * sizeof (struct NameRecord));
- surely_read (fd, records, nrecords * sizeof (struct NameRecord));
-
- for (i = 0, maxIndex = -1; i < nrecords; i++)
- {
- FIX_NameRecord (records[i]);
- index = records[i].offset + records[i].length;
- maxIndex = maxIndex > index ? maxIndex : index;
- }
- data = mymalloc (maxIndex);
- surely_lseek (fd, position + offset, SEEK_SET);
- surely_read (fd, data, maxIndex);
-
- strings = mymalloc (8 * sizeof (char *));
- for (i = 0; i < 8; i++)
- strings[i] = NULL;
-
- for (i = 0; i < nrecords; i++)
- {
- if
- ((records[i].platformID == 3 && /* Microsoft */
- records[i].encodingID == 1 && /* UGL */
- records[i].languageID == 0x0409 && /* US English */
- records[i].nameID <= 7))
- {
- strings[records[i].nameID] = mymalloc (records[i].length / 2 + 1);
- unistrncpy (strings[records[i].nameID],
- data + records[i].offset, records[i].length);
- if (ttf_verbosity >= 2)
- fprintf (stderr, "%d: %s\n", records[i].nameID,
- strings[records[i].nameID]);
- }
- }
-
-
- for (i = 0; i < nrecords; i++)
- {
- int id = records[i].nameID;
- if (records[i].platformID == 1 && /* Apple */
- records[i].encodingID == 0 && /* 8bit */
- id <= 7 &&
- !strings[id]
- )
- {
- strings[id] = mymalloc (records[i].length + 1);
- strncpy (strings[id],
- data + records[i].offset, records[i].length);
- strings[id][records[i].length] = 0;
- if (ttf_verbosity >= 2)
- fprintf (stderr, "%d: %s\n", records[i].nameID,
- strings[records[i].nameID]);
- }
- }
-
- free (records);
- free (data);
- return strings;
-}
-
-int
-readMaxpTable (FILE *fd)
-{
- struct
- {
- Fixed version;
- USHORT nglyphs;
- } data;
- surely_read (fd, &data, sizeof (data));
- FIX_Fixed (data.version);
- FIX_UH (data.nglyphs);
- if (ttf_verbosity >= 2)
- fprintf (stderr, " version %d.%u\n",
- data.version.mantissa, data.version.fraction);
- return data.nglyphs;
-}
-
-void
-readHeadTable (FILE *fd, struct HeadTable *ht)
-{
- surely_read (fd, ht, sizeof (struct HeadTable));
- FIX_HeadTable (*ht);
- if (ttf_verbosity >= 2)
- {
- fprintf (stderr, " version %d.%d\n",
- ht->version.mantissa, ht->version.fraction);
- fprintf (stderr, " font revision %d.%d\n",
- ht->fontRevision.mantissa, ht->fontRevision.fraction);
- }
- if (ht->magicNumber != 0x5F0F3CF5)
- ttf_error ("Bad magic number");
- if (ttf_verbosity >= 2)
- fprintf (stderr, " %d units per Em\n", ht->unitsPerEm);
-}
-
-int
-readPostTable (FILE *fd, int nglyphs, struct PostTable *pt,
- struct GlyphName **gt)
-{
- USHORT nglyphspost;
- USHORT *glyphNameIndex;
- struct GlyphName *glyphNames;
- char **glyphNamesTemp;
- int i, maxIndex;
- CHAR c;
-
- surely_read (fd, pt, sizeof (struct PostTable));
- FIX_PostTable (*pt);
- if (ttf_verbosity >= 2)
- fprintf (stderr, " format type %d.%u\n",
- pt->formatType.mantissa, pt->formatType.fraction);
-
- switch (pt->formatType.mantissa)
- {
- case 1:
- return 1; /* MacGlyphEncoding */
- case 2:
- if (pt->formatType.fraction != 0)
- ttf_error ("Unsupported `post' table format");
- surely_read (fd, &nglyphspost, sizeof (USHORT));
- FIX_UH (nglyphspost);
- if (nglyphspost != nglyphs)
- ttf_error ("Inconsistency between `maxp' and `nglyphs' tables!");
- if (ttf_verbosity >= 2)
- fprintf (stderr, " %d glyphs\n", nglyphs);
- glyphNameIndex = mymalloc (sizeof (USHORT) * nglyphs);
- surely_read (fd, glyphNameIndex, sizeof (USHORT) * nglyphs);
- glyphNames = mymalloc (sizeof (struct GlyphName) * nglyphs);
- for (i = 0, maxIndex = -1; i < nglyphs; i++)
- {
- FIX_UH (glyphNameIndex[i]);
- if (glyphNameIndex[i] < 258)
- {
- glyphNames[i].type = 0;
- glyphNames[i].name.index = glyphNameIndex[i];
- }
- else
- {
- int index;
- glyphNames[i].type = 1;
- index = glyphNameIndex[i] - 258;
- glyphNames[i].name.index = index;
- maxIndex = maxIndex > index ? maxIndex : index;
- }
- }
- free (glyphNameIndex);
-
- i = 0;
- glyphNamesTemp = mymalloc (sizeof (char *) * (maxIndex + 1));
- while (i <= maxIndex)
- {
- surely_read (fd, &c, 1);
- glyphNamesTemp[i] = mymalloc (c + 1);
- surely_read (fd, glyphNamesTemp[i], c);
- glyphNamesTemp[i][c] = '\0';
- if (ttf_verbosity >= 3)
- fprintf (stderr, " %d: %s\n", i, glyphNamesTemp[i]);
- i++;
- }
- for (i = 0; i < nglyphs; i++)
- if (glyphNames[i].type == 1)
- glyphNames[i].name.name = glyphNamesTemp[glyphNames[i].name.index];
- free (glyphNamesTemp);
- *gt = glyphNames;
- return 2;
- case 3:
- return 3; /* no name table */
- default:
- return 0;
- }
- /*NOTREACHED*/}
-
-void *
-readLocaTable (FILE *fd, int nglyphs, int format)
-{
- int i;
- switch (format)
- {
- case 0:
- {
- USHORT *offsets;
- offsets = mymalloc ((nglyphs + 1) * sizeof (USHORT));
- surely_read (fd, offsets, (nglyphs + 1) * sizeof (USHORT));
- for (i = 0; i <= nglyphs; i++)
- FIX_UH (offsets[i]);
- return offsets;
- }
- /*NOTREACHED*/ case 1:
- {
- ULONG *offsets;
- offsets = mymalloc ((nglyphs + 1) * sizeof (ULONG));
- surely_read (fd, offsets, (nglyphs + 1) * sizeof (ULONG));
- for (i = 0; i <= nglyphs; i++)
- FIX_UL (offsets[i]);
- return offsets;
- }
- /*NOTREACHED*/ default:
- ttf_error ("Unknown `loca' table format");
- /*NOTREACHED*/}
- /*NOTREACHED*/}
-
-struct Box *
-readGlyfTable (FILE *fd, int nglyphs, int format, void *loca)
-{
- int i;
- struct Box *bbox;
- off_t base, offset;
-
- base = ftell (fd);
-
- bbox = mymalloc (nglyphs * sizeof (struct Box));
- for (i = 0; i < nglyphs; i++)
- {
- if (format == 0)
- offset = 2 * ((USHORT *) loca)[i];
- else
- offset = ((ULONG *) loca)[i];
- surely_lseek (fd, base + offset + sizeof (SHORT), SEEK_SET);
- surely_read (fd, bbox + i, sizeof (struct Box));
- FIX_Box (bbox[i]);
- }
- return bbox;
-}
-
-longHorMetric *
-readHmtxTable (FILE *fd, int nummetrics)
-{
- longHorMetric *metrics;
- int i;
-
- metrics = mymalloc (nummetrics * sizeof (longHorMetric));
- surely_read (fd, metrics, nummetrics * sizeof (longHorMetric));
- for (i = 0; i < nummetrics; i++)
- {
- FIX_longHorMetric (metrics[i]);
- }
- return metrics;
-}
-
-struct HheaTable *
-readHheaTable (FILE *fd)
-{
- struct HheaTable *hhea;
- hhea = mymalloc (sizeof (struct HheaTable));
- surely_read (fd, hhea, sizeof (struct HheaTable));
- FIX_HheaTable (*hhea);
- if (ttf_verbosity >= 2)
- fprintf (stderr, " version %d.%u\n",
- hhea->version.mantissa, hhea->version.fraction);
- if (hhea->metricDataFormat != 0)
- ttf_error ("Unknown metric data format");
- return hhea;
-}
-
-int
-readKernTable (FILE *fd, int **nkep, struct KernEntry0 ***kep)
-{
- struct KernTable kt;
- struct KernSubTableHeader ksth;
- struct KernSubTable0 kst;
- int i, j;
- int *nke;
- struct KernEntry0 **ke;
-
- surely_read (fd, &kt, sizeof (struct KernTable));
- FIX_KernTable (kt);
- if (ttf_verbosity >= 2)
- {
- fprintf (stderr, " version %d\n", kt.version);
- fprintf (stderr, " %d subtables\n", kt.nTables);
- }
- nke = mymalloc (kt.nTables * sizeof (int));
- ke = mymalloc (kt.nTables * sizeof (struct KernEntry0 *));
-
- for (i = 0; i < kt.nTables; i++)
- {
- surely_read (fd, &ksth, sizeof (struct KernSubTableHeader));
- FIX_KernSubTableHeader (ksth);
- if (ttf_verbosity >= 2)
- fprintf (stderr, " analyzing subtable %d, version %d... ",
- i, ksth.version);
- if ((ksth.coverage & kernHorizontal) &&
- !(ksth.coverage & kernMinimum) &&
- !(ksth.coverage & kernCrossStream) &&
- (kernFormat (ksth.coverage) == 0))
- {
- surely_read (fd, &kst, sizeof (struct KernSubTable0));
- FIX_KernSubTable0 (kst);
- if (ttf_verbosity >= 2)
- fprintf (stderr, "reading %d entries.\n", kst.nPairs);
- nke[i] = kst.nPairs;
- ke[i] = mymalloc (kst.nPairs * sizeof (struct KernEntry0));
- surely_read (fd, ke[i], kst.nPairs * sizeof (struct KernEntry0));
- for (j = 0; j < kst.nPairs; j++)
- FIX_KernEntry0 (ke[i][j]);
- }
- else
- {
- if (ttf_verbosity >= 2)
- fprintf (stderr, "skipping.\n");
- surely_lseek (fd, ksth.length - sizeof (struct KernSubTableHeader),
- SEEK_CUR);
- }
- }
- *nkep = nke;
- *kep = ke;
- return kt.nTables;
-}
+++ /dev/null
-/* Copyright (c) 1997-1998 by Juliusz Chroboczek */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include "types.h"
-#include "proto.h"
-
-#include "ttftool.h"
-
-#define CHUNKSIZE 65534
-
-#define NAMEOF(i) \
- ((i)==0?\
- ".notdef":\
- ((postType==2)?\
- ((gnt[i].type==0)?\
- (gnt[i].name.index==0?NULL:macGlyphEncoding[gnt[i].name.index]):\
- gnt[i].name.name):\
- ((i)<258?macGlyphEncoding[i]:NULL)))
-
-
-void
-printPSFont (void *out, struct HeadTable *ht,
- char **strings, int nglyphs, int postType,
- struct PostTable *pt, struct GlyphName *gnt, FILE *fd)
-{
- printPSHeader (out, ht, strings, pt);
- printPSData (out, fd);
- printPSTrailer (out, nglyphs, postType, gnt);
-}
-
-void
-printPSHeader (void *out, struct HeadTable *ht,
- char **strings, struct PostTable *pt)
-{
- lily_cookie_fprintf (out, "%%!PS-TrueTypeFont\n");
- if (pt->maxMemType42)
- lily_cookie_fprintf (out, "%%%%VMUsage: %ld %ld\n", pt->minMemType42,
- pt->maxMemType42);
- lily_cookie_fprintf (out, "%d dict begin\n", 11);
- lily_cookie_fprintf (out, "/FontName /%s def\n", strings[6] ? strings[6] : "Unknown");
- lily_cookie_fprintf (out, "/Encoding StandardEncoding def\n");
- lily_cookie_fprintf (out, "/PaintType 0 def\n/FontMatrix [1 0 0 1 0 0] def\n");
- lily_cookie_fprintf (out, "/FontBBox [%ld %ld %ld %ld] def\n",
- ht->xMin * 1000L / ht->unitsPerEm,
- ht->yMin * 1000L / ht->unitsPerEm,
- ht->xMax * 1000L / ht->unitsPerEm,
- ht->yMax * 1000L / ht->unitsPerEm);
- lily_cookie_fprintf (out, "/FontType 42 def\n");
- lily_cookie_fprintf (out, "/FontInfo 8 dict dup begin\n");
- lily_cookie_fprintf (out, "/version (%d.%d) def\n",
- ht->fontRevision.mantissa, ht->fontRevision.fraction);
- if (strings[0])
- {
- lily_cookie_fprintf (out, "/Notice (");
- fputpss (strings[0], out);
- lily_cookie_fprintf (out, ") def\n");
- }
- if (strings[4])
- {
- lily_cookie_fprintf (out, "/FullName (");
- fputpss (strings[4], out);
- lily_cookie_fprintf (out, ") def\n");
- }
- if (strings[1])
- {
- lily_cookie_fprintf (out, "/FamilyName (");
- fputpss (strings[1], out);
- lily_cookie_fprintf (out, ") def\n");
- }
- lily_cookie_fprintf (out, "/isFixedPitch %s def\n",
- pt->isFixedPitch ? "true" : "false");
- lily_cookie_fprintf (out, "/UnderlinePosition %ld def\n",
- pt->underlinePosition * 1000L / ht->unitsPerEm);
- lily_cookie_fprintf (out, "/UnderlineThickness %ld def\n",
- pt->underlineThickness * 1000L / ht->unitsPerEm);
- lily_cookie_fprintf (out, "end readonly def\n");
-}
-
-void
-printPSData (void *out, FILE *fd)
-{
- static char xdigits[] = "0123456789ABCDEF";
-
- unsigned char *buffer;
- int i, j;
-
- surely_lseek (fd, 0, SEEK_SET);
-
- buffer = mymalloc (CHUNKSIZE);
-
- lily_cookie_fprintf (out, "/sfnts [");
- for (;;)
- {
- i = fread (buffer, 1, CHUNKSIZE, fd);
- if (i == 0)
- break;
- lily_cookie_fprintf (out, "\n<");
- for (j = 0; j < i; j++)
- {
- if (j != 0 && j % 36 == 0)
- lily_cookie_putc ('\n', out);
- /* lily_cookie_fprintf (out,"%02X",(int)buffer[j]) is too slow */
- lily_cookie_putc (xdigits[(buffer[j] & 0xF0) >> 4], out);
- lily_cookie_putc (xdigits[buffer[j] & 0x0F], out);
- }
- lily_cookie_fprintf (out, "00>"); /* Adobe bug? */
- if (i < CHUNKSIZE)
- break;
- }
- lily_cookie_fprintf (out, "\n] def\n");
- free (buffer);
-}
-
-void
-printPSTrailer (void *out, int nglyphs, int postType, struct GlyphName *gnt)
-{
- int i, n;
- char *name;
-
- lily_cookie_fprintf (out, "/CharStrings %d dict dup begin\n", nglyphs);
- switch (postType)
- {
- case 2:
- for (n = i = 0; i < nglyphs; i++)
- {
- if (n != 0 && n % 4 == 0)
- lily_cookie_fprintf (out, "\n");
- name = NAMEOF (i);
- if (name)
- {
- lily_cookie_fprintf (out, "/%s %d def ", name, i);
- n++;
- }
- }
- break;
- default:
- if (postType != 1)
- {
- if (ttf_verbosity > -2)
- fprintf (stderr,
- "No glyph name table; assuming MacGlyphEncoding\n");
- }
- for (i = 0; i < 258 && i < nglyphs; i++)
- {
- lily_cookie_fprintf (out, "/%s %d def ", macGlyphEncoding[i], i);
- if (i != 0 && i % 4 == 0)
- lily_cookie_fprintf (out, "\n");
- }
- break;
- }
- lily_cookie_fprintf (out, "end readonly def\n");
- lily_cookie_fprintf (out, "FontName currentdict end definefont pop\n");
-}
+++ /dev/null
-#ifdef TEST_TTFTOOL
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-
-#include "ttftool.h"
-
-
-main (int argc, char **argv)
-{
- FILE *in, *out;
- if (argc != 3)
- {
- fprintf (stderr, "%s input.ttf output.pfa", argv[0]);
- exit (2);
- }
-
- out = fopen (argv[2], "w");
- assert(out);
- create_type42 (argv[1], (void*) out);
-}
-
-#endif
+++ /dev/null
-/* Copyright (c) 1997-1998 by Juliusz Chroboczek */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include "types.h"
-#include "proto.h"
-
-
-static void endianness_test (void);
-static void usage (char *);
-
-int ttf_verbosity = 0;
-
-void
-create_type42 (const char *infile, void *out)
-{
- FILE *fd = 0;
- int i;
- struct OffsetTable ot;
- struct HeadTable *ht;
- struct PostTable *pt;
- struct TableDirectoryEntry *td;
- void *loca = NULL;
- struct HheaTable *hhea = NULL;
- struct Box *bbox = NULL;
- longHorMetric *hmtx = NULL;
- char **strings = NULL;
- struct GlyphName *gnt = NULL;
- struct KernEntry0 **ke;
- int *nke;
- int nglyphs, postType, nkern;
- off_t headOff = 0, maxpOff = 0, postOff = 0, nameOff = 0,
- locaOff = 0, glyfOff = 0, hheaOff = 0, hmtxOff = 0, kernOff = 0;
-
- extern char *optarg;
- extern int optind;
- int c;
-
- endianness_test ();
-
- if ((fd = fopen (infile, "rb")) == NULL)
- {
- syserror ("Error opening input file");
- }
-
- td = readDirectory (fd, &ot);
- if (ttf_verbosity >= 2)
- fprintf (stderr, "True type version %d.%u\n",
- ot.version.mantissa, ot.version.fraction);
-
- for (i = 0; i < ot.numTables; i++)
- {
- if (ttf_verbosity >= 2)
- fprintf (stderr, "Found `%c%c%c%c' table\n",
- (char) (td[i].tag >> 24),
- (char) (td[i].tag >> 16) & 255,
- (char) (td[i].tag >> 8) & 255, (char) td[i].tag & 255);
- switch (td[i].tag)
- {
- case MAKE_ULONG ('m', 'a', 'x', 'p'):
- maxpOff = td[i].offset;
- break;
- case MAKE_ULONG ('h', 'e', 'a', 'd'):
- headOff = td[i].offset;
- break;
- case MAKE_ULONG ('p', 'o', 's', 't'):
- postOff = td[i].offset;
- break;
- case MAKE_ULONG ('n', 'a', 'm', 'e'):
- nameOff = td[i].offset;
- break;
- case MAKE_ULONG ('l', 'o', 'c', 'a'):
- locaOff = td[i].offset;
- break;
- case MAKE_ULONG ('g', 'l', 'y', 'f'):
- glyfOff = td[i].offset;
- break;
- case MAKE_ULONG ('h', 'h', 'e', 'a'):
- hheaOff = td[i].offset;
- break;
- case MAKE_ULONG ('h', 'm', 't', 'x'):
- hmtxOff = td[i].offset;
- break;
- case MAKE_ULONG ('k', 'e', 'r', 'n'):
- kernOff = td[i].offset;
- break;
- }
- }
- if (maxpOff == 0 || headOff == 0 || postOff == 0 || nameOff == 0)
- ttf_error ("Incomplete TTF file\n");
-
- if (ttf_verbosity >= 1)
- fprintf (stderr, "Processing `maxp' table\n");
- surely_lseek (fd, maxpOff, SEEK_SET);
- nglyphs = readMaxpTable (fd);
- if (ttf_verbosity >= 1)
- fprintf (stderr, " %d glyphs\n", nglyphs);
-
- if (ttf_verbosity >= 1)
- fprintf (stderr, "Processing `head' table\n");
- surely_lseek (fd, headOff, SEEK_SET);
- ht = mymalloc (sizeof (struct HeadTable));
- readHeadTable (fd, ht);
-
- if (ttf_verbosity >= 1)
- fprintf (stderr, "Processing `post' table\n");
- surely_lseek (fd, postOff, SEEK_SET);
- pt = mymalloc (sizeof (struct PostTable));
- postType = readPostTable (fd, nglyphs, pt, &gnt);
-
- if (ttf_verbosity >= 1)
- fprintf (stderr, "Processing `name' table\n");
- surely_lseek (fd, nameOff, SEEK_SET);
- strings = readNamingTable (fd);
-
- if (ttf_verbosity >= 1)
- fprintf (stderr, "Generating PS file\n");
- printPSFont (out, ht, strings, nglyphs, postType, pt, gnt, fd);
- lily_cookie_fclose (out);
- if (ttf_verbosity >= 1)
- fprintf (stderr, "Done.\n");
- fclose (fd);
-}
-
-
-static void
-endianness_test ()
-{
- union
- {
- BYTE b[4];
- ULONG l;
- } x;
- ULONG v;
-
- x.b[0] = 1;
- x.b[1] = 2;
- x.b[2] = 3;
- x.b[3] = 4;
-
- v = UL (x.l);
-
- if (v != (((((1 << 8) + 2) << 8) + 3) << 8) + 4)
- {
- fprintf (stderr, "Code badly compiled for this architecture\n");
- fprintf (stderr, "Please set SMALLENDIAN and recompile\n");
- exit (2);
- }
-}
+++ /dev/null
-/* Copyright (c) 1997-1998 by Juliusz Chroboczek */
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include "types.h"
-#include "proto.h"
-#include "ttftool.h"
-
-
-void *
-mymalloc (size_t size)
-{
- void *p;
- if ((p = malloc (size)) == NULL)
- ttf_error ("Unable to allocate memory\n");
- return p;
-}
-
-void *
-mycalloc (size_t nelem, size_t elsize)
-{
- void *p;
- if ((p = calloc (nelem, elsize)) == NULL)
- ttf_error ("Unable to allocate memory\n");
- return p;
-}
-
-void
-ttf_error (char *string)
-{
- fprintf (stderr, "TTF tool: %s\n", string);
- exit (3);
- /*NOTREACHED*/
-}
-
-void
-syserror (char *string)
-{
- char *sys_err = strerror (errno);
- fprintf (stderr, "TTF tool: %s (%s)\n",
- string,
- sys_err);
- exit (3);
-}
-
-void *
-myrealloc (void *ptr, size_t size)
-{
- void *p;
- if ((p = realloc (ptr, size)) == NULL)
- ttf_error ("Unable to allocate memory\n");
- return p;
-}
-
-void
-show_fpos (int fd)
-{
- off_t here = lseek (fd, 0, SEEK_CUR);
- off_t end = lseek (fd, 0, SEEK_END);
- fprintf (stderr, "here %d end %d", here, end);
- lseek (fd, here, SEEK_SET);
-}
-
-void
-surely_lseek (FILE *fildes, off_t offset, int whence)
-{
- if (ttf_verbosity >= 3)
- fprintf (stderr, "Seeking to %d %d\n", whence, offset);
-
- off_t result;
- if ((result = fseek (fildes, (long) offset, whence)) < 0)
- {
- char s[100];
- sprintf (s, "Cannot seek");
- syserror (s);
- }
-}
-
-ssize_t
-surely_read (FILE *fildes, void *buf, size_t nbyte)
-{
- if (ttf_verbosity >= 3)
- fprintf (stderr, "Reading %d bytes\n", nbyte);
- if (nbyte == 0)
- return 0;
-
- int items = fread (buf, nbyte, 1, fildes);
- return nbyte;
-}
-
-char *
-unistrncpy (char *dst, char *str, size_t length)
-{
- int i, j;
-
- for (i = j = 0; i < length; i += 2)
- if (str[i] == 0)
- dst[j++] = str[i + 1];
- dst[j] = '\0';
- return dst;
-}
-
-void
-fputpss (char *s, void *stream)
-{
- while (*s)
- {
- if ((*s & 0200) == 0 && *s >= 040 && *s != '(' && *s != ')')
- lily_cookie_putc (*s, stream);
- else
- lily_cookie_fprintf (stream, "\\%03o", (unsigned char) *s);
- s++;
- }
-}
-
-/* Hashtables */
-
-unsigned
-hash (char *string)
-{
- int i;
- unsigned u = 0;
- for (i = 0; string[i] != '\0'; i++)
- u = (u << 2) + string[i];
- return u;
-}
-
-struct hashtable *
-make_hashtable (int size)
-{
- struct hashtable *t;
-
- t = mymalloc (sizeof (struct hashtable));
- t->size = size;
- t->buckets = mycalloc (size, sizeof (struct hashtable_bucket *));
-
- return t;
-}
-
-int
-puthash (struct hashtable *t, char *key, int value)
-{
- int i;
-
- i = hash (key) % t->size;
-
- if (t->buckets[i] == 0)
- {
- t->buckets[i] = mymalloc (sizeof (struct hashtable_bucket));
- t->buckets[i]->entries = mymalloc (4 * sizeof (struct hashtable_entry));
- t->buckets[i]->size = 4;
- t->buckets[i]->nentries = 0;
- }
-
- if (t->buckets[i]->nentries >= t->buckets[i]->size)
- {
- t->buckets[i]->entries = myrealloc (t->buckets[i]->entries,
- t->buckets[i]->size * 2 *
- sizeof (struct hashtable_entry));
- t->buckets[i]->size *= 2;
- }
-
- t->buckets[i]->entries[t->buckets[i]->nentries].key = key;
- t->buckets[i]->entries[t->buckets[i]->nentries].value = value;
- t->buckets[i]->nentries++;
-
- return value;
-}
-
-int
-gethash (struct hashtable *t, char *key)
-{
- int i, j;
-
- i = hash (key) % t->size;
- if (t->buckets[i])
- for (j = 0; j < t->buckets[i]->nentries; j++)
- if (!strcmp (key, t->buckets[i]->entries[j].key))
- return t->buckets[i]->entries[j].value;
- return -1;
-}