From 55ec0f8222ec4e95a30a59276c992de2f5bf935d Mon Sep 17 00:00:00 2001 From: Craig Stuart Sapp Date: Mon, 22 Jan 2024 22:49:38 -0800 Subject: [PATCH] Partial implementation for issue https://github.com/humdrum-tools/verovio-humdrum-viewer/issues/869 --- src/iohumdrum.cpp | 50 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/iohumdrum.cpp b/src/iohumdrum.cpp index 96ed8b17f2f..244f208158a 100644 --- a/src/iohumdrum.cpp +++ b/src/iohumdrum.cpp @@ -17987,10 +17987,23 @@ bool HumdrumInput::setLabelContent(Label *label, const std::string &name) bool HumdrumInput::setTempoContent(Tempo *tempo, const std::string &text) { + + Rend *rend = NULL; hum::HumRegex hre; + if (hre.search(text, "\\\\n")) { + // Insert text into if an will be added + rend = new Rend(); + tempo->AddChild(rend); + } + if (!hre.search(text, "(.*)\\[([^=\\]]*)\\]\\s*=\\s*(\\d+.*)")) { // no musical characters to unescape - addTextElement(tempo, text); + if (rend) { + addTextElement(rend, text); + } + else { + addTextElement(tempo, text); + } return true; } std::string first = hre.getMatch(1); @@ -18004,7 +18017,12 @@ bool HumdrumInput::setTempoContent(Tempo *tempo, const std::string &text) // to separate parenthesis and notehead: first += " "; } - addTextElement(tempo, first); + if (rend) { + addTextElement(rend, first); + } + else { + addTextElement(tempo, first); + } } // Add the musical symbols, adding a space between them @@ -18018,10 +18036,20 @@ bool HumdrumInput::setTempoContent(Tempo *tempo, const std::string &text) if (counter) { // Add a space element between music symbols. if (name == "metAugmentationDot") { - addTextElement(tempo, m_textAugmentationDotSpacer); + if (rend) { + addTextElement(rend, m_textAugmentationDotSpacer); + } + else { + addTextElement(tempo, m_textAugmentationDotSpacer); + } } else { - addTextElement(tempo, m_textSmuflSpacer); + if (rend) { + addTextElement(rend, m_textSmuflSpacer); + } + else { + addTextElement(tempo, m_textSmuflSpacer); + } } } ++counter; @@ -18029,12 +18057,22 @@ bool HumdrumInput::setTempoContent(Tempo *tempo, const std::string &text) Symbol *symbol = new Symbol(); setSmuflContent(symbol, name); setFontsize(symbol, name, ""); - tempo->AddChild(symbol); + if (rend) { + rend->AddChild(symbol); + } + else { + tempo->AddChild(symbol); + } } // Force spaces around equals sign: third = m_textSmuflSpacer + "=" + m_textSmuflSpacer + third; - addTextElement(tempo, third); + if (rend) { + addTextElement(rend, third); + } + else { + addTextElement(tempo, third); + } return true; }