--- /dev/null
+\version "2.15.21"
+\header {
+ texidoc = "This regtest makes sure that footnote numbers are laid out
+in the correct vertical order.
+"
+}
+
+#(define (make-footnote-numbering-assertion-function n)
+ (lambda (x)
+ (if (not (= n x))
+ (ly:error (_ "Expecting number ~a, got ~a") n x))))
+
+#(define (simultaneous-footnote-numbering-assertion-function x y)
+ (lambda (grob)
+ (let ((n (if (grob::has-interface (ly:grob-parent grob Y)
+ 'beam-interface)
+ x
+ y)))
+ (lambda (x)
+ (if (not (= n x))
+ (ly:error (_ "Expecting number ~a, got ~a") n x))))))
+
+\paper {
+ reset-footnotes-on-new-page = ##f
+}
+
+#(set-default-paper-size "a6")
+\book {
+ \score {
+ <<
+ \new Staff \relative c' {
+ d4 e
+ \once \override FootnoteItem #'numbering-assertion-function =
+ #(lambda (grob) (make-footnote-numbering-assertion-function 0))
+ < f a-\autoFootnote #'(1 . -1) \markup { n } c >
+ \once \override FootnoteSpanner #'numbering-assertion-function =
+ #(simultaneous-footnote-numbering-assertion-function 2 4)
+ \autoFootnoteGrob #'Beam #'(1 . 1) \markup { o }
+ \autoFootnoteGrob #'Hairpin #'(1 . 1) \markup { p }
+ a8\< [ b c d ] a4 b c\f |
+ d a b c |\break
+ d,4 e
+ \once \override FootnoteItem #'numbering-assertion-function =
+ #(lambda (grob) (make-footnote-numbering-assertion-function 6))
+ < f a-\autoFootnote #'(1 . -1) \markup { n } c >
+ \once \override FootnoteSpanner #'numbering-assertion-function =
+ #(simultaneous-footnote-numbering-assertion-function 8 10)
+ \autoFootnoteGrob #'Beam #'(1 . 1) \markup { o }
+ \autoFootnoteGrob #'Hairpin #'(1 . 1) \markup { p }
+ a8\< [ b c d ] a4 b c |
+ d a b c\f |\pageBreak
+ d,4 e
+ \once \override FootnoteItem #'numbering-assertion-function =
+ #(lambda (grob) (make-footnote-numbering-assertion-function 12))
+ < f a-\autoFootnote #'(1 . -1) \markup { n } c >
+ \once \override FootnoteSpanner #'numbering-assertion-function =
+ #(simultaneous-footnote-numbering-assertion-function 14 16)
+ \autoFootnoteGrob #'Beam #'(1 . 1) \markup { o }
+ \autoFootnoteGrob #'Hairpin #'(1 . 1) \markup { p }
+ a8\< [ b c d ] a4 b c |
+ d a b c\! |\break
+ }
+ \new Staff \relative c' {
+ d4 e
+ \once \override FootnoteItem #'numbering-assertion-function =
+ #(lambda (grob) (make-footnote-numbering-assertion-function 1))
+ < f a-\autoFootnote #'(1 . -1) \markup { n } c >
+ \once \override FootnoteSpanner #'numbering-assertion-function =
+ #(simultaneous-footnote-numbering-assertion-function 3 5)
+ \autoFootnoteGrob #'Beam #'(1 . 1) \markup { o }
+ \autoFootnoteGrob #'Hairpin #'(1 . 1) \markup { p }
+ a8\< [ b c d ] a4 b c\f |
+ d a b c |\break
+ d,4 e
+ \once \override FootnoteItem #'numbering-assertion-function =
+ #(lambda (grob) (make-footnote-numbering-assertion-function 7))
+ < f a-\autoFootnote #'(1 . -1) \markup { n } c >
+ \once \override FootnoteSpanner #'numbering-assertion-function =
+ #(simultaneous-footnote-numbering-assertion-function 9 11)
+ \autoFootnoteGrob #'Beam #'(1 . 1) \markup { o }
+ \autoFootnoteGrob #'Hairpin #'(1 . 1) \markup { p }
+ a8\< [ b c d ] a4 b c |
+ d a b c\f |\pageBreak
+ d,4 e
+ \once \override FootnoteItem #'numbering-assertion-function =
+ #(lambda (grob) (make-footnote-numbering-assertion-function 13))
+ < f a-\autoFootnote #'(1 . -1) \markup { n } c >
+ \once \override FootnoteSpanner #'numbering-assertion-function =
+ #(simultaneous-footnote-numbering-assertion-function 15 17)
+ \autoFootnoteGrob #'Beam #'(1 . 1) \markup { o }
+ \autoFootnoteGrob #'Hairpin #'(1 . 1) \markup { p }
+ a8\< [ b c d ] a4 b c |
+ d a b c\! |\break
+ }
+ >>
+ }
+}
-\version "2.15.7"
+\version "2.15.21"
\header {
texidoc = "This is an example of automatic footnote numbering
where the number is not reset on each page. It uses the default
"
}
+#(define (make-footnote-numbering-assertion-function n)
+ (lambda (x)
+ (if (not (= n x))
+ (ly:error (_ "Expecting number ~a, got ~a") n x))))
+
+#(define (simultaneous-footnote-numbering-assertion-function x y)
+ (lambda (grob)
+ (let ((n (if (grob::has-interface (ly:grob-parent grob Y)
+ 'beam-interface)
+ x
+ y)))
+ (lambda (x)
+ (if (not (= n x))
+ (ly:error (_ "Expecting number ~a, got ~a") n x))))))
+
\paper {
reset-footnotes-on-new-page = ##f
}
\markup { h i }
\relative c' {
-\autoFootnoteGrob #'NoteHead #'(1 . -1) \markup { j }
-a b c d }
+ \once \override FootnoteItem #'numbering-assertion-function =
+ #(lambda (grob) (make-footnote-numbering-assertion-function 3))
+ \autoFootnoteGrob #'NoteHead #'(1 . -1) \markup { j }
+ a b c d
+}
\pageBreak
\relative c' {
d4 e
+ \once \override FootnoteItem #'numbering-assertion-function =
+ #(lambda (grob) (make-footnote-numbering-assertion-function 5))
< f a-\autoFootnote #'(1 . -1) \markup { n } c >
+ \once \override FootnoteSpanner #'numbering-assertion-function =
+ #(simultaneous-footnote-numbering-assertion-function 6 7)
\autoFootnoteGrob #'Beam #'(1 . 1) \markup { o }
\autoFootnoteGrob #'Hairpin #'(1 . 1) \markup { p }
a8\< [ b c d ] a4 b c |
static bool read_spacing_spec (SCM spec, Real *dest, SCM sym);
static bool is_spaceable (Grob *g);
static SCM get_details (Grob *g);
+ static vector<Grob *> get_footnote_grobs (SCM lines);
static vsize get_footnote_count (SCM lines);
static SCM get_footnotes_from_lines (SCM lines);
static void add_footnotes_to_lines (SCM lines, int counter, Paper_book *pb);
Returns the number of footntoes associated with a given line.
*/
-vsize
-Page_layout_problem::get_footnote_count (SCM lines)
+vector<Grob *>
+Page_layout_problem::get_footnote_grobs (SCM lines)
{
- vsize fn_count = 0;
+ vector<Grob *> footnotes;
for (SCM s = lines; scm_is_pair (s); s = scm_cdr (s))
{
if (Grob *g = unsmob_grob (scm_car (s)))
programming_error ("got a grob for footnotes that wasn't a System");
continue;
}
- fn_count += sys->num_footnotes ();
+ extract_grob_set (sys, "footnotes-after-line-breaking", footnote_grobs);
+ footnotes.insert (footnotes.end (), footnote_grobs.begin (), footnote_grobs.end ());
}
else if (Prob *p = unsmob_prob (scm_car (s)))
{
if (stencils == SCM_EOL)
continue;
for (SCM st = stencils; scm_is_pair (st); st = scm_cdr (st))
- fn_count++;
+ footnotes.push_back (0);
}
}
- return fn_count;
+ return footnotes;
+}
+
+vsize
+Page_layout_problem::get_footnote_count (SCM lines)
+{
+ vector<Grob *> notes = get_footnote_grobs (lines);
+ return notes.size ();
}
SCM
Real padding = robust_scm2double (paper->c_variable ("footnote-padding"), 0.0);
Real number_raise = robust_scm2double (paper->c_variable ("footnote-number-raise"), 0.0);
- vsize fn_count = get_footnote_count (lines);
+ vector<Grob *> fn_grobs = get_footnote_grobs (lines);
+ vsize fn_count = fn_grobs.size ();
// now, make the footnote stencils with the numbering function
SCM numbers = SCM_EOL;
vector<Stencil *> footnote_number_stencils; // Holds translated versions of the stencilized numbering markups.
for (vsize i = 0; i < fn_count; i++)
{
+ if (fn_grobs[i])
+ {
+ SCM assertion_function = fn_grobs[i]->get_property ("numbering-assertion-function");
+ if (ly_is_procedure (assertion_function))
+ (void) scm_call_1 (assertion_function, scm_from_int (counter));
+ }
SCM markup = scm_call_1 (numbering_function, scm_from_int (counter));
Stencil *s = unsmob_stencil (Text_interface::interpret_markup (layout, props, markup));
if (!s)
(ly:add-interface
'footnote-interface
"Make a footnote."
- '(automatically-numbered footnote footnote-text))
+ '(automatically-numbered
+ footnote
+ footnote-text
+ numbering-assertion-function))
(ly:add-interface
'footnote-spanner-interface
(note-collision ,ly:grob? "The @code{NoteCollision} object of a
dot column.")
+ (numbering-assertion-function ,scheme? "The function used to assert
+that footnotes are receiving correct automatic numbers.")
(positioning-done ,boolean? "Used to signal that a positioning element
did its job. This ensures that a positioning is only done once.")