From 7975e9693bbb16fd4417d7fd5017c0b31f2f2ad1 Mon Sep 17 00:00:00 2001 From: Thomas Morley Date: Wed, 2 Oct 2013 23:31:50 +0200 Subject: [PATCH] Making flat flags available Issue 3591 The markup-command 'note-ny-number' and the relvant regression- tests are extended, too. The sippet 'using-alternative-flag-styles.ly' from Documentation/snippets/new/ isn't changed for now, will be tackled in a follow up. --- input/regression/flags-straight.ly | 8 ++++++-- input/regression/markup-note-styles.ly | 9 +++++++++ input/regression/markup-note.ly | 1 + scm/define-markup-commands.scm | 22 +++++++++++++++------- scm/flag-styles.scm | 21 ++++++++++++++++----- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/input/regression/flags-straight.ly b/input/regression/flags-straight.ly index 80eb28c7f6..7e96536e6a 100644 --- a/input/regression/flags-straight.ly +++ b/input/regression/flags-straight.ly @@ -6,7 +6,7 @@ % test notes, which will be shown in different styles: -testnotes = { \autoBeamOff c'8 d'16 c'32 d'64 \acciaccatura {c'8} d'64 +testnotes = { \autoBeamOff c'8 d'16 c'32 d'64 \acciaccatura {c'8} d'64 c''8 d''16 c''32 d''64 \acciaccatura {\stemDown c''8 \stemNeutral} d''64 } { @@ -19,9 +19,13 @@ testnotes = { \autoBeamOff c'8 d'16 c'32 d'64 \acciaccatura {c'8} d'64 \mark "old straight (large angles)" \override Flag.stencil = #old-straight-flag \testnotes + + \mark "flat" + \override Flag.stencil = #flat-flag + \testnotes % % \mark "custom slant" -% % Custom straight flag. The parameters are: +% % Custom straight flag. The parameters are: % % flag thickness and spacing % % up-flag angle and length % % down-flag angle and length diff --git a/input/regression/markup-note-styles.ly b/input/regression/markup-note-styles.ly index 224eaf69d0..f5fbc9b60d 100644 --- a/input/regression/markup-note-styles.ly +++ b/input/regression/markup-note-styles.ly @@ -61,3 +61,12 @@ all note head styles and straight flags." \show-note-styles #'(default) } } + +\markup { + \column { + \combine \null \vspace #1 + \underline "Flat-flag:" + \override #'(flag-style . flat-flag) + \show-note-styles #'(default) + } +} diff --git a/input/regression/markup-note.ly b/input/regression/markup-note.ly index 307336799b..c600fab42f 100644 --- a/input/regression/markup-note.ly +++ b/input/regression/markup-note.ly @@ -58,6 +58,7 @@ mrkp = \override #'(style . mensural) \mrkp \override #'(flag-style . modern-straight-flag) \mrkp \override #'(flag-style . old-straight-flag) \mrkp + \override #'(flag-style . flat-flag) \mrkp } } \override NoteHead.style = #'triangle diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 6de7c9a8f4..9e5528f5bb 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -3319,8 +3319,8 @@ A feta brace in point size @var{size}, rotated 180 degrees. Construct a note symbol, with stem and flag. By using fractional values for @var{dir}, longer or shorter stems can be obtained. Supports all note-head-styles. -Supported flag-styles are @code{default}, @code{old-straight-flag} and -@code{modern-straight-flag}. +Supported flag-styles are @code{default}, @code{old-straight-flag}, +@code{modern-straight-flag} and @code{flat-flag}. @lilypond[verbatim,quote] \\markup { @@ -3381,7 +3381,9 @@ Supported flag-styles are @code{default}, @code{old-straight-flag} and (raw-length (if stem-up upflag-length downflag-length)) (angle (if stem-up upflag-angle downflag-angle)) (flag-length (+ (* raw-length factor) half-stem-thickness)) - (flag-end (polar->rectangular flag-length angle)) + (flag-end (if (= angle 0) + (cons flag-length (* half-stem-thickness dir)) + (polar->rectangular flag-length angle))) (thickness (* flag-thickness factor)) (thickness-offset (cons 0 (* -1 thickness dir))) (spacing (* -1 flag-spacing factor dir)) @@ -3389,9 +3391,11 @@ Supported flag-styles are @code{default}, @code{old-straight-flag} and ;; The points of a round-filled-polygon need to be given in ;; clockwise order, otherwise the polygon will be enlarged by ;; blot-size*2! - (points (if stem-up (list start flag-end - (offset-add flag-end thickness-offset) - (offset-add start thickness-offset)) + (points (if stem-up + (list start + flag-end + (offset-add flag-end thickness-offset) + (offset-add start thickness-offset)) (list start (offset-add start thickness-offset) (offset-add flag-end thickness-offset) @@ -3456,10 +3460,12 @@ Supported flag-styles are @code{default}, @code{old-straight-flag} and ;; Straight-flags. Values taken from /scm/flag-style.scm (modern-straight-flag (straight-flag-mrkp 0.55 1 -18 1.1 22 1.2 dir)) (old-straight-flag (straight-flag-mrkp 0.55 1 -45 1.2 45 1.4 dir)) + (flat-flag (straight-flag-mrkp 0.55 1.0 0 1.0 0 1.0 dir)) ;; Calculate a corrective to avoid a gap between ;; straight-flags and the stem. (flag-style-Y-corr (if (or (eq? flag-style 'modern-straight-flag) - (eq? flag-style 'old-straight-flag)) + (eq? flag-style 'old-straight-flag) + (eq? flag-style 'flat-flag)) (/ blot 10 (* -1 dir)) 0)) (flaggl (and (> log 2) @@ -3468,6 +3474,8 @@ Supported flag-styles are @code{default}, @code{old-straight-flag} and modern-straight-flag) ((eq? flag-style 'old-straight-flag) old-straight-flag) + ((eq? flag-style 'flat-flag) + flat-flag) (else (ly:font-get-glyph font (format #f (if ancient-flags? diff --git a/scm/flag-styles.scm b/scm/flag-styles.scm index c8fea1ae5d..59495ba40b 100644 --- a/scm/flag-styles.scm +++ b/scm/flag-styles.scm @@ -16,7 +16,8 @@ ;;;; along with LilyPond. If not, see . ;;;; This file implements different flag styles in Scheme / GUILE, most -;;;; notably the old-straight-flag and the modern-straight-flag styles. +;;;; notably the old-straight-flag, the modern-straight-flag and the flat-flag +;;;; styles. (define-public (no-flag grob) @@ -80,16 +81,22 @@ All lengths are scaled according to the font size of the note." (raw-length (if stem-up upflag-length downflag-length)) (angle (if stem-up upflag-angle downflag-angle)) (flag-length (+ (* raw-length factor) half-stem-thickness)) - (flag-end (polar->rectangular flag-length angle)) + ;; For flat flags the points to create the stencil using + ;; ly:round-filled-polygon need to be different concerning flag-end + (flag-end (if (= angle 0) + (cons flag-length (* half-stem-thickness dir)) + (polar->rectangular flag-length angle))) (thickness (* flag-thickness factor)) (thickness-offset (cons 0 (* -1 thickness dir))) (spacing (* -1 flag-spacing factor dir )) (start (cons (- half-stem-thickness) (* half-stem-thickness dir))) ;; The points of a round-filled-polygon need to be given in clockwise ;; order, otherwise the polygon will be enlarged by blot-size*2! - (points (if stem-up (list start flag-end - (offset-add flag-end thickness-offset) - (offset-add start thickness-offset)) + (points (if stem-up + (list start + flag-end + (offset-add flag-end thickness-offset) + (offset-add start thickness-offset)) (list start (offset-add start thickness-offset) (offset-add flag-end thickness-offset) @@ -118,6 +125,10 @@ of Bach, etc." flags are both 45 degrees." ((straight-flag 0.55 1 -45 1.2 45 1.4) grob)) +(define-public (flat-flag grob) + "Flat flag style. The angles of the flags are both 0 degrees" + ((straight-flag 0.55 1.0 0 1.0 0 1.0) grob)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Flags created from feta glyphs (normal and mensural flags) -- 2.39.2