From c7acad264e49f23e333dd66a0e1d50005c630068 Mon Sep 17 00:00:00 2001 From: Thomas Morley Date: Fri, 31 Jul 2015 21:12:06 +0200 Subject: [PATCH] Let fret-diagram scale markups to fit into dots Issue 4531 Follow up to issue 4120. Also adding - documentation - a new regtest --- Documentation/notation/fretted-strings.itely | 24 +++++++++++-- .../regression/fretdiagram-markup-in-dots.ly | 31 ++++++++++++++++ scm/fret-diagrams.scm | 35 ++++++++++++++++--- 3 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 input/regression/fretdiagram-markup-in-dots.ly diff --git a/Documentation/notation/fretted-strings.itely b/Documentation/notation/fretted-strings.itely index 1ce12cd706..7e2d18725b 100644 --- a/Documentation/notation/fretted-strings.itely +++ b/Documentation/notation/fretted-strings.itely @@ -1022,12 +1022,14 @@ capo will be the lowest fret in the fret diagram. Fingering indication dots can be colored as well as parenthesized; the parenthesis's color can also be altered independently. +Markups can be placed into the dots as well. + @c \override is necessary to make fingering visible @lilypond[quote, verbatim] << \new ChordNames { \chordmode { - f1 g c c + f1 g c c b } } \new Staff { @@ -1063,7 +1065,7 @@ the parenthesis's color can also be altered independently. (place-fret 2 5 3) ) } - \override Voice.TextScript.size = 1.5 + \override Voice.TextScript.size = 1.4 1^\markup { \fret-diagram-verbose #'( (place-fret 6 3 1 red parenthesized default-paren-color) @@ -1074,6 +1076,24 @@ the parenthesis's color can also be altered independently. (place-fret 1 3 1 inverted) ) } + \override Voice.TextScript.size = 1.5 + 1^\markup { + \override #'(fret-diagram-details . ((finger-code . in-dot))) + \fret-diagram-verbose #`( + (place-fret 5 2 1) + (place-fret 4 4 "fis" red) + (place-fret 3 4 "b" red) + (place-fret + 2 4 + ,#{ \markup + \concat { + \vcenter "d" + \fontsize #-5 + \musicglyph #"accidentals.sharp"} #} + red) + (place-fret 1 2 1) + ) + } } >> @end lilypond diff --git a/input/regression/fretdiagram-markup-in-dots.ly b/input/regression/fretdiagram-markup-in-dots.ly new file mode 100644 index 0000000000..c93470e07d --- /dev/null +++ b/input/regression/fretdiagram-markup-in-dots.ly @@ -0,0 +1,31 @@ + +\version "2.19.25" + +\header { + texidoc="Markups can be put into the dots of a fret-diagram. Those markups +are scaled automatically to fit into the dots. +" +} + +myFretDiagram = +\markup + \fret-diagram-verbose #`( + (place-fret 6 1 + ,(markup + #:concat ( + #:vcenter "e" + #:fontsize -5 + #:musicglyph "accidentals.sharp"))) + (place-fret 5 2 "aisis") + (place-fret 4 3 3) + (place-fret 3 1 "g#") + (place-fret 2 2 2) + (place-fret 1 3 ,#{ \markup \score { { \clef "G_8" g'1 } } #})) + + +\markup + \override #'(fret-diagram-details . ((finger-code . in-dot))) { + \myFretDiagram + \override #'(size . 5) \myFretDiagram + \override #'(size . 10) \myFretDiagram +} diff --git a/scm/fret-diagrams.scm b/scm/fret-diagrams.scm index 5b6580d650..041d180c04 100644 --- a/scm/fret-diagrams.scm +++ b/scm/fret-diagrams.scm @@ -672,10 +672,37 @@ fret-diagram overall parameters." ((or (eq? finger '())(eq? finger-code 'none)) positioned-dot) ((eq? finger-code 'in-dot) - (let ((finger-label - (centered-stencil - (sans-serif-stencil - layout props dot-label-font-mag finger)))) + (let* ((finger-stil + (if (not (null? finger)) + (sans-serif-stencil + layout props dot-label-font-mag finger) + empty-stencil)) + (finger-stil-length + (interval-length (ly:stencil-extent finger-stil X))) + (finger-stil-height + (interval-length (ly:stencil-extent finger-stil Y))) + (dot-stencil-radius + (/ (interval-length (ly:stencil-extent dot-stencil Y)) + 2)) + (scale-factor + (/ dot-stencil-radius + ;; Calculate the radius of the circle through the + ;; corners of the box containing the finger-stil. + ;; Give it a little padding. The value, (* 2 th), + ;; is my choice + (+ + (sqrt + (+ (expt (/ finger-stil-length 2) 2) + (expt (/ finger-stil-height 2) 2))) + (* 2 th)))) + (finger-label + (centered-stencil + (ly:stencil-scale + (sans-serif-stencil + layout props + dot-label-font-mag + finger) + scale-factor scale-factor)))) (ly:stencil-translate (ly:stencil-add final-dot-stencil -- 2.39.2