From fad8b981f17e1a84704df9bfda39b949c9974400 Mon Sep 17 00:00:00 2001 From: Nils Date: Tue, 11 Oct 2022 00:11:17 +0200 Subject: [PATCH] Wrap long text in Lilypond subtext with automatic linebreaks. --- CHANGELOG | 2 +- engine/lilypond.py | 4 +++- engine/resources/lilypondTemplates/default.ly | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 312f9fa..fc3bbb7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,7 +8,7 @@ External contributors notice at the end of the line: (LastName, FirstName / nick ## 2022-10-15 2.2.2 Empty blocks with explicit minimum tick duration will not be deleted anymore by "Delete All Empty Blocks" command. Add option to use current block duration when entering a minimum duration in block properties GUI - +Wrap long text in Lilypond subtext with automatic linebreaks. ## 2022-08-15 2.2.1 "Flip the page" earlier during live playback, showing the last measure (or so) twice diff --git a/engine/lilypond.py b/engine/lilypond.py index 1fded31..5039d84 100644 --- a/engine/lilypond.py +++ b/engine/lilypond.py @@ -84,6 +84,7 @@ def lilyfy(string): if string.startswith("\\markup"): return string #trust the user + string = string.replace('\\n', '\n') #replace the user newline with actual one string = string.replace('"', '\\"') return string @@ -132,7 +133,8 @@ def fromTemplate(session, data, meta, tempoStaff): templateString = templateString.replace("%$$GLOBAL-STAFF-SIZE$$", str(meta["global-staff-size"])) templateString = templateString.replace("%$$FILENAME$$", session.sessionPrefix) templateString = templateString.replace("%$$HEADER$$", processMeta(meta)) - templateString = templateString.replace("%$$SUBTEXT$$", '"' + lilyfy(meta["subtext"]) + '"') + #templateString = templateString.replace("%$$SUBTEXT$$", '"' + lilyfy(meta["subtext"]) + '"') + templateString = templateString.replace("%$$SUBTEXT$$", lilyfy(meta["subtext"]) ) voicesString, structureString = processData(data) templateString = templateString.replace("%$$VOICES$$", voicesString) templateString = templateString.replace("%$$STRUCTURE$$", structureString) diff --git a/engine/resources/lilypondTemplates/default.ly b/engine/resources/lilypondTemplates/default.ly index 9e15f28..5651934 100644 --- a/engine/resources/lilypondTemplates/default.ly +++ b/engine/resources/lilypondTemplates/default.ly @@ -107,8 +107,12 @@ tempoStaff = { %$$TEMPOSTAFF$$ } >>} + \markup{ - %\column { - %$$SUBTEXT$$ - %} + \vspace #2 + \column { + \wordwrap { + %$$SUBTEXT$$ + } + } }