Engrave window: bar numbers, and two silent LilyPond faults
A system can now be given the measure it starts at, in a First bar field beside key and time. Per slice, since it is the one thing about a replacement that cannot be inherited from the song. Bar numbering is a Score property, so it is set once on the first staff, and made visible only at a line beginning — that vector is fussy: #(#f #t #t) also prints a number mid-system and #(#f #t #f) prints the second bar's rather than the first's. It travels in the bundle's engraving object as `bar`. Two things LilyPond 2.24 was quietly refusing to draw: `\bar ":|"` and the other old repeat names produce nothing at all — no error, no warning, exit status 0, just a missing repeat that you find on the tablet. Every book and forum answer still uses them, so translate them to the modern spellings. `\clef treble_8` unquoted is not an octavated clef either. It parses as a plain treble plus a stray "8" markup that lands under the first note, and the staff then reads an octave off — a tenor line engraved at soprano pitch. Quote it. The source pane, which is where either of those would have been visible, is now a collapsed section at the bottom rather than a permanent slab. It uses the panel's own disclosure helper, lifted out of Editor so both can call it.
This commit is contained in:
@@ -52,6 +52,39 @@ def _scan_pdf(path: Path) -> None:
|
||||
|
||||
|
||||
def main() -> int:
|
||||
# Bar aliases are string work, so they are checked whether or not LilyPond
|
||||
# is installed. The old repeat names draw nothing at all in 2.24 — silently,
|
||||
# which is how a missing repeat reaches a tablet.
|
||||
aliased = lilypond.generate(
|
||||
Replacement(voices=[Voice("treble", 'c4 d \\bar ":|" e f \\bar "|:" g', "")]), "c", "4/4"
|
||||
)
|
||||
assert '\\bar ":|."' in aliased and '\\bar ".|:"' in aliased, aliased
|
||||
kept = lilypond.generate(
|
||||
Replacement(voices=[Voice("treble", 'c4 \\bar "|." d', "")]), "c", "4/4"
|
||||
)
|
||||
assert '\\bar "|."' in kept, "a name LilyPond still knows is left alone"
|
||||
|
||||
# An octavated clef name must be quoted. Unquoted, `\clef treble_8` is a
|
||||
# plain treble with a stray "8" markup under the first note, an octave off.
|
||||
tenor = lilypond.generate(
|
||||
Replacement(voices=[Voice("treble_8", "c4 d", "")]), "c", "4/4"
|
||||
)
|
||||
assert '\\clef "treble_8"' in tenor, tenor
|
||||
|
||||
# A bar number is set once, on the first staff, since it is a Score
|
||||
# property, and is visible only at a line beginning — one number above the
|
||||
# first bar, as a printed score numbers its systems.
|
||||
numbered = lilypond.generate(
|
||||
Replacement(voices=[Voice("treble", "c4 d", ""), Voice("bass", "c4 d", "")], bar=33),
|
||||
"c",
|
||||
"4/4",
|
||||
)
|
||||
assert numbered.count("currentBarNumber = #33") == 1, numbered
|
||||
assert "break-visibility = #'#(#f #f #t)" in numbered
|
||||
assert "currentBarNumber" not in lilypond.generate(
|
||||
Replacement(voices=[Voice("treble", "c4 d", "")]), "c", "4/4"
|
||||
), "an unnumbered system prints no number"
|
||||
|
||||
if not lilypond.available():
|
||||
print("ok (skipped: LilyPond not installed)")
|
||||
return 0
|
||||
@@ -138,6 +171,7 @@ def main() -> int:
|
||||
assert page.replacements[second] is SATB
|
||||
|
||||
# Round-trip, including the song-level engraving defaults.
|
||||
SATB.bar = 33
|
||||
project.key, project.time, project.clefs = "aes", "3/4", ["treble", "bass"]
|
||||
saved = project.save()
|
||||
reloaded = Project.load(saved)
|
||||
@@ -146,6 +180,7 @@ def main() -> int:
|
||||
assert restored is not None
|
||||
assert [v.clef for v in restored.voices] == ["treble", "bass"]
|
||||
assert restored.voices[0].lyrics == "la la la la la la"
|
||||
assert restored.bar == 33, "the slice's bar number survives a save"
|
||||
assert reloaded.pages[0].replacements[first] is None
|
||||
|
||||
source.close()
|
||||
|
||||
Reference in New Issue
Block a user