From 1c7aa062c6cec594b68479b240db33399f80f4e6 Mon Sep 17 00:00:00 2001 From: Thomas Morley Date: Wed, 27 Jul 2016 11:46:55 +0200 Subject: [PATCH] Issue 4931 make deadNote work with other font-settings In case the current (text-)font does not contain a cross-glyph, font-name is set temporary to '(), and font-family to feta. If feta is replaced with another font without glyphs for cross-style note-heads, it will still fail, though. The regtest dead-notes.ly is altered accordingly. Also, ly-syntax is used where possible. palmMute and harmonic are not affected by this patch and still work nicely. --- input/regression/dead-notes.ly | 63 ++++++++++++++++++++++++---------- ly/property-init.ly | 44 +++++++++++++++++------- 2 files changed, 75 insertions(+), 32 deletions(-) diff --git a/input/regression/dead-notes.ly b/input/regression/dead-notes.ly index 62e94fdb8e..9096803201 100644 --- a/input/regression/dead-notes.ly +++ b/input/regression/dead-notes.ly @@ -1,7 +1,8 @@ -\version "2.16.0" +\version "2.19.46" \header{ texidoc = "Muted notes (also called dead notes) are supported - within normal staves and tablature." + within normal staves and tablature. They are printed + correctly, even if another font for TabNoteHead is used. " } mynotes = \relative c,, { @@ -15,25 +16,49 @@ mynotes = \relative c,, { \bar "|." } -\context StaffGroup << - \context Staff { - \context Voice { % Warning: explicit voice instantiation is required - % to have deadNotesOff work properly - % when deadNotesOn comes at the beginning - % of the piece - \clef "bass_8" - \mynotes +\score { + \new StaffGroup << + \new Staff { + \new Voice { % Warning: explicit voice instantiation is required + % to have deadNotesOff work properly + % when deadNotesOn comes at the beginning + % of the piece + \clef "bass_8" + \mynotes + } } - } - \context TabStaff { - \context TabVoice { % Warning: explicit voice instantiation is - % required to have deadNotesOff work properly - % when deadNotesOn comes at the beginning - % of the piece - \set TabStaff.stringTunings = #bass-tuning - \mynotes + \new TabStaff + \with { + instrumentName = \markup \tiny "default-font" + }{ + \new TabVoice { % Warning: explicit voice instantiation is + % required to have deadNotesOff work properly + % when deadNotesOn comes at the beginning + % of the piece + \mynotes + } + } + \new TabStaff + \with { + \override TabNoteHead.font-name = #"Luxi Mono" + instrumentName = + \markup \tiny \center-column { "TabNoteHead-" "font:" "Luxi Mono" } + }{ + \new TabVoice { % Warning: explicit voice instantiation is + % required to have deadNotesOff work properly + % when deadNotesOn comes at the beginning + % of the piece + \mynotes + } + } + >> + \layout { + indent = 20 + \context { + \TabStaff + stringTunings = #bass-tuning } } ->> +} diff --git a/ly/property-init.ly b/ly/property-init.ly index 85adb52bb0..4923420ffe 100644 --- a/ly/property-init.ly +++ b/ly/property-init.ly @@ -8,11 +8,10 @@ %% common definition for all note head styles reverting %% (palm mute, harmonics, dead notes, ...) -defaultNoteHeads = -#(define-music-function () () - (_i "Revert to the default note head style.") - (context-spec-music - (revert-head-style '(NoteHead TabNoteHead)) 'Bottom)) +defaultNoteHeads = { + \revert NoteHead.style + \revert TabNoteHead.style +} accidentalStyle = #(define-music-function @@ -748,17 +747,36 @@ allowVoltaHook = %% x notes -xNotesOn = -#(define-music-function () () - (_i "Set the default note head style to a cross-shaped style.") - (context-spec-music - (override-head-style '(TabNoteHead NoteHead) 'cross) 'Bottom)) +#(define (cross-style grob) +;; Returns the symbol 'cross to set the 'style-property for (Tab-)NoteHead. +;; If the current text-font doesn't contain the glyph set 'font-name to '() +;; and 'font-family to 'feta. +;; If 'feta is replaced by another music-font without cross-style-glyphs +;; note-head.cc throws a warning and no visual output happens. + (let* ((layout (ly:grob-layout grob)) + (props (ly:grob-alist-chain grob)) + (font (ly:paper-get-font layout props)) + (font-unknown? (string=? (ly:font-name font) "unknown"))) + (if font-unknown? + (begin + (ly:grob-set-property! grob 'font-name '()) + (ly:grob-set-property! grob 'font-family 'feta))) + 'cross)) + +%% Set the default note head style to a cross-shaped style. +xNotesOn = { + \temporary \override NoteHead.style = #cross-style + \temporary \override TabNoteHead.style = #cross-style +} + xNotesOff = \defaultNoteHeads + xNote = #(define-music-function (note) (ly:music?) - (_i "Print @var{note} with a cross-shaped note head.") - (style-note-heads '(TabNoteHead NoteHead) 'cross note)) - + (_i "Print @var{note} with a cross-shaped note head.") + (if (eq? (ly:music-property note 'name) 'NoteEvent) + #{ \tweak style #cross-style $note #} + #{ \xNotesOn $note \xNotesOff #})) %% dead notes (these need to come after "x notes") -- 2.39.2