From ae3f96419e0d166b13fe2ffff148539bde3afead Mon Sep 17 00:00:00 2001 From: hanwen Date: Mon, 22 Mar 2004 14:03:12 +0000 Subject: [PATCH] * scripts/lilypond-book.py (is_derived_class): use numbers iso. booleans. * python/lilylib.py (make_ps_images): add margin to PS images. * scripts/lilypond-book.py (is_derived_class): new function. Take class arg iso. object. (to_eps): make a non EPS file if EPS contains %%Pages. Workaround for bug in GS/dvips. * scm/define-markup-commands.scm: remove split around-space hack. --- ChangeLog | 7 +++++ Documentation/user/changing-defaults.itely | 33 ++++++++++++++++++++++ buildscripts/mf-to-table.py | 31 +++++++++----------- lily/axis-group-interface.cc | 2 +- lily/key-engraver.cc | 15 +++++----- ly/engraver-init.ly | 5 ++-- python/lilylib.py | 6 +++- scm/define-context-properties.scm | 16 ++++++----- scm/define-markup-commands.scm | 6 ++++ scripts/lilypond-book.py | 23 +++++++++++++-- 10 files changed, 105 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index dae37a15dc..d9ebd8cfaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,14 @@ 2004-03-22 Han-Wen Nienhuys + * scripts/lilypond-book.py (is_derived_class): use numbers + iso. booleans. + + * python/lilylib.py (make_ps_images): add margin to PS images. + * scripts/lilypond-book.py (is_derived_class): new function. Take class arg iso. object. + (to_eps): make a non EPS file if EPS contains %%Pages. Workaround + for bug in GS/dvips. * lily/text-item.cc (interpret_markup): idem. diff --git a/Documentation/user/changing-defaults.itely b/Documentation/user/changing-defaults.itely index 7940601ef3..16f32d9afd 100644 --- a/Documentation/user/changing-defaults.itely +++ b/Documentation/user/changing-defaults.itely @@ -665,6 +665,39 @@ and/or crashes. @node Defining context defaults @subsection Defining context defaults +The adjustments of the previous chapters can also be entered separate +from the music, in the @code{\paper} block, + +@example + \paper { + @dots{} + \context @{ + \StaffContext + + \set fontSize = #-2 + \override Stem #'thickness + \remove "Time_signature_engraver" + @} + @} +@end example + +This +@example + \StaffContext +@end example + +@noindent +takes the existing definition @context{Staff}, and adds +changes some settings, + +@example + \set fontSize = #-2 + \override Stem #'thickness + \remove "Time_signature_engraver" +@end example + + + Context properties can be set as defaults, within the @code{\paper} block. For example, diff --git a/buildscripts/mf-to-table.py b/buildscripts/mf-to-table.py index 1818062972..b78ed88b6b 100644 --- a/buildscripts/mf-to-table.py +++ b/buildscripts/mf-to-table.py @@ -160,8 +160,8 @@ def write_fontlist (file, global_info, charmetrics): file.write (r""" %% LilyPond file to list all font symbols and the corresponding names %% Automatically generated by mf-to-table.py -\score{\notes{\fatText\time %d/4 -""" % per_line) +\score{ \lyrics \new Lyrics { \time %d/8 +""" % (2*per_line+1)) count = 0 for m in charmetrics: @@ -177,29 +177,26 @@ def write_fontlist (file, global_info, charmetrics): ## prevent TeX from interpreting "--" as long dash: tex_string=re.sub('--','-{}-', tex_string) - file.write (' s^\\markup { \\musicglyph #"%s" "%s" }\n' % (scm_string, tex_string)) + file.write (' \\markup { \\raise #0.75 \\vcenter \\musicglyph #"%s" " %s" } 4 \n' % (scm_string, tex_string)) if (count % 3) ==0: - file.write (' \\break\n') + file.write ('\skip 8 \\break\n') file.write (r""" } \paper{ - interscoreline=1 + interscoreline = 1.0 + indent = 0.0 \cm \context { - \ScoreContext - \remove "Bar_number_engraver" - \override TextScript #'extra-X-extent = #'(-1 . 1) - } - \context { - \StaffContext - \remove "Clef_engraver" - \remove "Key_engraver" - \remove "Time_signature_engraver" - \remove "Staff_symbol_engraver" + \LyricsContext + \override SeparationItem #'padding = #2 minimumVerticalExtent = ##f } - } -} + \context { + \ScoreContext + \remove "Bar_number_engraver" + } + } + } """) def write_deps (file, deps, targets): diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index eab8127652..40ea7ca721 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -122,4 +122,4 @@ Axis_group_interface::get_children (Grob*me) ADD_INTERFACE (Axis_group_interface, "axis-group-interface", "An object that groups other layout objects.", - "axes"); + "axes elements"); diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index f0b63cab21..a4e2dbe220 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -28,8 +28,8 @@ class Key_engraver : public Engraver { void create_key (bool); - void read_ev (Key_change_ev const * r); - Key_change_ev * key_ev_; + void read_ev (Music const * r); + Music * key_ev_; Item * item_; public: @@ -69,8 +69,8 @@ Key_engraver::create_key (bool def) item_->set_property ("c0-position", get_property ("middleCPosition")); - // todo: put this in basic props. - item_->set_property ("old-accidentals", get_property ("lastKeySignature")); + if (to_boolean (get_property ("printKeyCancellation"))) + item_->set_property ("old-accidentals", get_property ("lastKeySignature")); item_->set_property ("new-accidentals", get_property ("keySignature")); announce_grob (item_, key_ev_ ? key_ev_->self_scm () : SCM_EOL); @@ -88,7 +88,6 @@ Key_engraver::create_key (bool def) bool Key_engraver::try_music (Music * ev) { - // if (Key_change_ev *kc = dynamic_cast (ev)) if (ev->is_mus_type ("key-change-event")) { if (!key_ev_) @@ -96,7 +95,7 @@ Key_engraver::try_music (Music * ev) /* do this only once, just to be on the safe side. */ - key_ev_ = dynamic_cast (ev); // UGH. + key_ev_ = ev; read_ev (key_ev_); } @@ -146,7 +145,7 @@ Key_engraver::stop_translation_timestep () void -Key_engraver::read_ev (Key_change_ev const * r) +Key_engraver::read_ev (Music const * r) { SCM p = r->get_property ("pitch-alist"); if (!gh_pair_p (p)) @@ -199,5 +198,5 @@ ENTER_DESCRIPTION (Key_engraver, /* creats*/ "KeySignature", /* accepts */ "key-change-event", /* acks */ "bar-line-interface clef-interface", -/* reads */ "keySignature lastKeySignature explicitKeySignatureVisibility createKeyOnClefChange keyAccidentalOrder keySignature", +/* reads */ "keySignature printKeyCancellation lastKeySignature explicitKeySignatureVisibility createKeyOnClefChange keyAccidentalOrder keySignature", /* write */ "lastKeySignature tonic keySignature"); diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index faee7c5eb0..05fe54c186 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -24,7 +24,7 @@ % with empty ones. \consists "Font_size_engraver" - + \consists "Volta_engraver" \consists "Separating_line_group_engraver" \consists "Dot_column_engraver" @@ -47,7 +47,7 @@ extraVerticalExtent = ##f verticalExtent = ##f localKeySignature = #'() - + % explicitly set instrument, so we don't get % weird effects when doing instrument names for % piano staves @@ -485,6 +485,7 @@ AncientRemoveEmptyStaffContext = \context { autoAccidentals = #'(Staff (same-octave . 0)) autoCautionaries = #'() + printKeyCancellation = ##t keyAccidentalOrder = #`( (6 . ,FLAT) (2 . ,FLAT) (5 . ,FLAT ) (1 . ,FLAT) (4 . ,FLAT) (0 . ,FLAT) (3 . ,FLAT) (3 . ,SHARP) (0 . ,SHARP) (4 . ,SHARP) (1 . ,SHARP) (5 . ,SHARP) (2 . ,SHARP) (6 . ,SHARP) diff --git a/python/lilylib.py b/python/lilylib.py index ba339854bc..7bac5a445f 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -462,7 +462,11 @@ def make_ps_images (ps_name, resolution = 90): output_file = re.sub (r'\.e?ps', '.png', ps_name) - margin = 0 + + # need to have margin, otherwise edges of letters will + # be cropped off. + + margin = 3 fo = open (trans_ps, 'w') fo.write ('%d %d translate\n' % (-bbox[0] + margin, -bbox[1] + margin)) diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index 3509616f82..85d6b926bc 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -260,12 +260,6 @@ markup. Called with 2 arguments, event and context.") selects the highest string with a fret at least @var{minimumFret}") (minimumVerticalExtent ,number-pair? "minimum vertical extent, same format as @var{verticalExtent}") - (recordEventSequence ,procedure? "When -@internalsref{Recording_group_engraver} is in this context, then upon -termination of the context, this function is called with current -context and a list of music objects. The list of contains entries -with start times, music objects and whether they are processed in this -context.") (ottavation ,string? "If set, the text for an ottava spanner. Changing this creates a new text spanner. ") (pedalSustainStrings ,list? "List of string to print for @@ -278,10 +272,18 @@ pedal.") sustain pedals: @code{text}, @code{bracket} or @code{mixed} (both).") (pedalUnaCordaStyle ,symbol? "see @code{pedalSustainStyle}.") (pedalSostenutoStyle ,symbol? "see @code{pedalSustainStyle}.") + (printKeyCancellation ,boolean? "Print restoration alterations before a key signature change. ") (printOctaveNames ,boolean? "Print octave marks for the NoteNames context.") + (recordEventSequence ,procedure? "When +@internalsref{Recording_group_engraver} is in this context, then upon +termination of the context, this function is called with current +context and a list of music objects. The list of contains entries +with start times, music objects and whether they are processed in this +context.") + + (rehearsalMark ,integer? "The last rehearsal mark printed.") (repeatCommands ,list? "This property is read to find any command of the form @code{(volta . @var{x})}, where @var{x} is a string or @code{#f}") - (restNumberThreshold ,number? "If a multimeasure rest takes less than this number of measures, no number is printed. ") diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index e504cef998..95f4aaa26b 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -240,6 +240,12 @@ of the @code{#'direction} layout property." (cmols (map (lambda (x) (ly:stencil-align-to! x X CENTER)) mols))) (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) mols))) +(def-markup-command (vcenter paper props arg) (markup?) + "Align @code{arg} to its center. " + (let* ((mol (interpret-markup paper props arg))) + (ly:stencil-align-to! mol Y CENTER) + mol)) + (def-markup-command (right-align paper props arg) (markup?) (let* ((m (interpret-markup paper props arg))) (ly:stencil-align-to! m X RIGHT) diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 216f7c4cb4..622396b8b0 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -391,6 +391,23 @@ def to_eps (file): ly.system ('dvips -Ppdf -u+lilypond.map -E -o %s.eps %s' \ % (file, file)) + + # check if it really is EPS. + # Otherwise music glyphs disappear from 2nd and following pages. + + # TODO: should run dvips -pp -E per page, then we get proper + # cropping as well. + + f = open ('%s.eps' % file) + for x in range(0,10) : + if re.search ("^%%Pages: ", f.readline ()): + + # make non EPS. + ly.system ('dvips -Ppdf -u+lilypond.map -o %s.eps %s' \ + % (file, file)) + break + + def find_file (name): for i in include_path: full = os.path.join (i, name) @@ -720,11 +737,11 @@ def run_filter (s): def is_derived_class (cl, baseclass): if cl == baseclass: - return True + return 0 for b in cl.__bases__: if is_derived_class (b, baseclass): - return True - return False + return 1 + return 0 def process_snippets (cmd, snippets): -- 2.39.2