2015-09-02 20:17 GMT+02:00 tisimst <
address@hidden>:
> David,
>
> On 8/31/2015 5:55 AM, David Stephen Grant [via Lilypond] wrote:
>
> Hi all,
> I'm using Abraham's Profondo font, but having some trouble with
> TupletBrackets.
>
> I would like to indicate the duration of some feathered beamed groups with a
> TupletBracket showing the total duration. The following simplified code
> works fine with the default font, but the symbol in the first bracket
> doesn't print when I switch to Profondo. I also get the error: warning:
> Found infinity or nan in output. Substituting 0.0
>
> \version "2.19.25"
> \include "profondo.ily"
> {
> \override TupletBracket.padding = #1.5
> \override TupletBracket.bracket-visibility = ##t
>
> \once \override TupletNumber.text = \markup { \note #"4" #UP }
> \tuplet 5/8 { a'16 a' a' a' a' }
>
>
> \revert Staff.TupletNumber.font-name
> \once \override TupletNumber.text = \markup { \note #"4" #UP }
> \tuplet 5/8 { a'16 a' a' a' a' }
>
> \override Staff.TupletNumber.font-name = #"ProfondoTupletNumbers"
> \tuplet 5/8 { a'16 a' a' a' a' }
> }
>
> As most TupletBrackets should be using the Profondo tuplet number font I
> thought about reverting to the default for these brackets, but ideally I
> would prefer not to have to remember to turn Profondo back on afterwards as
> in the above code.
>
> Any ideas?
>
>
> I've been thinking about this since you first sent it and it is starting to
> drive me crazy! I've poured over the code that creates the \note stencil and
> I can't find anything that would cause it to go crazy like this. The only
> font it even refers to is the music font, so I don't know why the \markup
> has a hard time with it. In the example you show (not sure if you are doing
> anything more complex in the actual score), the \markup doesn't use any text
> from ProfondoTupletNumbers at all when it draws the \note, so I have to
> assume the error is caused by the \markup command itself, though I haven't
> been able to prove that yet.
>
> One way around this (at least to make it less of a typing hassle) is to
> remove the \override from the \layout block and instead encapsulate it in
> variables so you can use them on-the-fly, like this:
>
> %%%%%%%%%%%%%
>
> profondoTupletNumeralsOn = \override Staff.TupletNumber.font-name =
> #"ProfondoTupletNumbers"
> profondoTupletNumeralsOff = \revert Staff.TupletNumber.font-name
>
> %%%%%%%%%%%%%
>
> It's probably more than you want to do, but this might be the best thing to
> do for the time being. Do you use the \note function in your tuplet markings
> a lot?
>
> Best,
> Abraham
Hi,
I did some research on this topic, focusing on \note-by-number, which is called in \note.
I've found that \note-by-number is _always_ disturbed, if _any_ font-name is set. But \musicglyph not, for _every_ font-name-setting.
The difference seems to be that \musicglyph clears font-name, setting it to #f.
\note-by-number does not.
Coding the same in \note-by-number seems to solve the issue. This needs more testing, though, and _if_ it's the way to go, should be done in \rest-by-number as well.
Code-examples:
\version "2.19.26"
%% The following _always_ works
%%{
\markup {
\typewriter #"\\musicglyph #\"noteheads.s0\""
\musicglyph #"noteheads.s0"
}
\markup {
\typewriter "\\note #\"8.\" #UP"
\note #"8." #UP
\typewriter #"\\note #\"1.\" #UP"
\note #"1." #UP
}
%}
%% The following _never_ works, regardless which font-name is specified.
%%{
\markup
\override #'(font-name . "Times New Roman")
{
\typewriter #"\\musicglyph #\"noteheads.s0\""
\musicglyph #"noteheads.s0"
}
\markup
\override #'(font-name . "Times New Roman")
{
\typewriter "\\note #\"8.\" #UP"
\note #"8." #UP
\typewriter #"\\note #\"1.\" #UP"
\note #"1." #UP
}
%}
%%%% And the following bug can be observed (not related to the current topic,
%%%% I think), was ok with 2.18.2:
%%{
\markup \override #'(font-name . "Times New Roman") "\\<==what?"
%}
Replacing note-by-number in define-markup-commands.scm with the code below seems to solve the issue (changes between the semicolon-lines) and the reported problem with other fonts like profondo, etc
Please test.
(define-markup-command (note-by-number layout props log dot-count dir)
(number? number? number?)
#:category music
#:properties ((font-size 0)
(flag-style '())
(style '()))
"
@cindex notes within text by log and dot-count
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},
@code{modern-straight-flag} and @code{flat-flag}.
@lilypond[verbatim,quote]
\\markup {
\\note-by-number #3 #0 #DOWN
\\hspace #2
\\note-by-number #1 #2 #0.8
}
@end lilypond"
(define (get-glyph-name-candidates dir log style)
(map (lambda (dir-name)
(format #f "noteheads.~a~a" dir-name
(if (and (symbol? style)
(not (equal? 'default style)))
(select-head-glyph style (min log 2))
(min log 2))))
(list (if (= dir UP) "u" "d")
"s")))
(define (get-glyph-name font cands)
(if (null? cands)
""
(if (ly:stencil-empty? (ly:font-get-glyph font (car cands)))
(get-glyph-name font (cdr cands))
(car cands))))
(define (buildflags flag-stencil remain curr-stencil spacing)
;; Function to recursively create a stencil with @code{remain} flags
;; from the single-flag stencil @code{curr-stencil}, which is already
;; translated to the position of the previous flag position.
;;
;; Copy and paste from /scm/flag-styles.scm
(if (> remain 0)
(let* ((translated-stencil
(ly:stencil-translate-axis curr-stencil spacing Y))
(new-stencil (ly:stencil-add flag-stencil translated-stencil)))
(buildflags new-stencil (- remain 1) translated-stencil spacing))
flag-stencil))
(define (straight-flag-mrkp flag-thickness flag-spacing
upflag-angle upflag-length
downflag-angle downflag-length
dir)
;; Create a stencil for a straight flag. address@hidden and
;; @var{flag-spacing} are given in staff spaces, @var{upflag-angle} and
;; @var{downflag-angle} are given in degrees, and @var{upflag-length} and
;; @var{downflag-length} are given in staff spaces.
;;
;; All lengths are scaled according to the font size of the note.
;;
;; From /scm/flag-styles.scm, modified to fit here.
(let* ((stem-up (> dir 0))
;; scale with the note size
(factor (magstep font-size))
(stem-thickness (* factor 0.1))
(line-thickness (ly:output-def-lookup layout 'line-thickness))
(half-stem-thickness (/ (* stem-thickness line-thickness) 2))
(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 (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)))
(points (list start
flag-end
(offset-add flag-end thickness-offset)
(offset-add start thickness-offset)))
(stencil (ly:round-filled-polygon points half-stem-thickness))
;; Log for 1/8 is 3, so we need to subtract 3
(flag-stencil (buildflags stencil (- log 3) stencil spacing)))
flag-stencil))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(let* (;(font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
; props)))
(font (ly:paper-get-font layout
(cons '((font-encoding . fetaMusic)
(font-name . #f))
props)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(size-factor (magstep font-size))
(blot (ly:output-def-lookup layout 'blot-diameter))
(head-glyph-name
(let ((result (get-glyph-name font
(get-glyph-name-candidates
(sign dir) log style))))
(if (string-null? result)
;; If no glyph name can be found, select default heads.
;; Though this usually means an unsupported style has been
;; chosen, it also prevents unrelated 'style settings from
;; other grobs (e.g., TextSpanner and TimeSignature) leaking
;; into markup.
(get-glyph-name font
(get-glyph-name-candidates
(sign dir) log 'default))
result)))
(head-glyph (ly:font-get-glyph font head-glyph-name))
(ancient-flags? (or (eq? style 'mensural) (eq? style 'neomensural)))
(attach-indices (ly:note-head::stem-attachment font head-glyph-name))
(stem-length (* size-factor (max 3 (- log 1))))
;; With ancient-flags we want a tighter stem
(stem-thickness (* size-factor (if ancient-flags? 0.1 0.13)))
(stemy (* dir stem-length))
(attach-off (cons (interval-index
(ly:stencil-extent head-glyph X)
(* (sign dir) (car attach-indices)))
;; fixme, this is inconsistent between X & Y.
(* (sign dir)
(interval-index
(ly:stencil-extent head-glyph Y)
(cdr attach-indices)))))
;; For a tighter stem (with ancient-flags) the stem-width has to be
;; adjusted.
(stem-X-corr (if ancient-flags? (* 0.5 dir stem-thickness) 0))
(stem-glyph (and (> log 0)
(ly:round-filled-box
(ordered-cons (+ stem-X-corr (car attach-off))
(+ stem-X-corr (car attach-off)
(* (- (sign dir)) stem-thickness)))
(cons (min stemy (cdr attach-off))
(max stemy (cdr attach-off)))
(/ stem-thickness 3))))
(dot (ly:font-get-glyph font "dots.dot"))
(dotwid (interval-length (ly:stencil-extent dot X)))
(dots (and (> dot-count 0)
(apply ly:stencil-add
(map (lambda (x)
(ly:stencil-translate-axis
dot (* 2 x dotwid) X))
(iota dot-count)))))
;; 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 'flat-flag))
(/ blot 10 (* -1 dir))
0))
(flaggl (and (> log 2)
(ly:stencil-translate
(cond ((eq? flag-style 'modern-straight-flag)
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?
"flags.mensural~a2~a"
"flags.~a~a")
(if (> dir 0) "u" "d")
log))))
(cons (+ (car attach-off)
;; For tighter stems (with ancient-flags) the
;; flag has to be adjusted different.
(if (and (not ancient-flags?) (< dir 0))
stem-thickness
0))
(+ stemy flag-style-Y-corr))))))
;; If there is a flag on an upstem and the stem is short, move the dots
;; to avoid the flag. 16th notes get a special case because their flags
;; hang lower than any other flags.
;; Not with ancient flags or straight-flags.
(if (and dots (> dir 0) (> log 2)
(or (eq? flag-style 'default) (null? flag-style))
(not ancient-flags?)
(or (< dir 1.15) (and (= log 4) (< dir 1.3))))
(set! dots (ly:stencil-translate-axis dots 0.5 X)))
(if flaggl
(set! stem-glyph (ly:stencil-add flaggl stem-glyph)))
(if (ly:stencil? stem-glyph)
(set! stem-glyph (ly:stencil-add stem-glyph head-glyph))
(set! stem-glyph head-glyph))
(if (ly:stencil? dots)
(set! stem-glyph
(ly:stencil-add
(ly:stencil-translate-axis
dots
(+ (cdr (ly:stencil-extent head-glyph X)) dotwid)
X)
stem-glyph)))
stem-glyph))
HTH,
Harm