Skip to content

Commit 728ade9

Browse files
rettinghauslpugin
andauthored
Add import of symbols (#4292)
* handle symbols * improve mixed words with coda * update changelog * Update CHANGELOG.md Co-authored-by: Laurent Pugin <lxpugin@gmail.com> --------- Co-authored-by: Laurent Pugin <lxpugin@gmail.com>
1 parent e6699d7 commit 728ade9

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Support for `stageDir`
66
* Support for ASCL custom tuning (MusicXML import and MIDI output)
77
* Improved key signature changes in sections with restart
8-
* Improved MusicXML importer (`@vgrp`, fingering)
8+
* Improved MusicXML importer (`@vgrp`, `fingering`, `symbol`)
99
* Option `--mensural-responsive-view` multi-valued ("auto|none|selection")
1010

1111
## [6.0.1] – 2026-01-29

src/iomusxml.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -691,12 +691,6 @@ std::string MusicXmlInput::GetWordsOrDynamicsText(const pugi::xml_node node) con
691691
}
692692
return dynamStr;
693693
}
694-
if (IsElement(node, "coda")) {
695-
return "\xF0\x9D\x84\x8C";
696-
}
697-
if (IsElement(node, "segno")) {
698-
return "\xF0\x9D\x84\x8B";
699-
}
700694
return std::string();
701695
}
702696

@@ -708,12 +702,29 @@ void MusicXmlInput::TextRendition(const pugi::xpath_node_set words, ControlEleme
708702
std::string textStr = GetWordsOrDynamicsText(textNode);
709703
std::string textColor = textNode.attribute("color").as_string();
710704
Object *textParent = element;
711-
if (textNode.attribute("xml:lang") || textNode.attribute("xml:space") || textNode.attribute("color")
705+
if (!std::strncmp(textNode.name(), "symbol", 6)) {
706+
Symbol *symbol = new Symbol();
707+
symbol->SetGlyphAuth("smufl");
708+
symbol->SetColor(textColor);
709+
symbol->SetGlyphName(textNode.text().as_string());
710+
element->AddChild(symbol);
711+
continue;
712+
}
713+
else if (!std::strncmp(textNode.name(), "coda", 4) || !std::strncmp(textNode.name(), "segno", 5)) {
714+
// for cases we have coda/segno and text in one direction
715+
Symbol *symbol = new Symbol();
716+
symbol->SetGlyphAuth("smufl");
717+
symbol->SetColor(textColor);
718+
symbol->SetGlyphName(textNode.name());
719+
element->AddChild(symbol);
720+
continue;
721+
}
722+
else if (textNode.attribute("xml:lang") || textNode.attribute("xml:space") || textNode.attribute("color")
712723
|| textNode.attribute("halign") || textNode.attribute("font-family") || textNode.attribute("font-style")
713724
|| textNode.attribute("font-weight") || textNode.attribute("enclosure")) {
714725
Rend *rend = new Rend();
715726
rend->SetLang(textNode.attribute("xml:lang").as_string());
716-
rend->SetColor(textNode.attribute("color").as_string());
727+
rend->SetColor(textColor);
717728
rend->SetHalign(
718729
rend->AttHorizontalAlign::StrToHorizontalalignment(textNode.attribute("halign").as_string()));
719730
rend->SetSpace(textNode.attribute("xml:space").as_string());
@@ -2362,7 +2373,8 @@ void MusicXmlInput::ReadMusicXmlDirection(
23622373
// Directive
23632374
int defaultY = 0; // y position attribute, only for directives and dynamics
23642375
if (containsWords && !containsTempo && !containsDynamics) {
2365-
pugi::xpath_node_set words = node.select_nodes("direction-type/*[self::words or self::coda or self::segno]");
2376+
pugi::xpath_node_set words
2377+
= node.select_nodes("direction-type/*[self::words or self::symbol or self::coda or self::segno]");
23662378
defaultY = words.first().node().attribute("default-y").as_int();
23672379
defaultY = (defaultY * 10) + words.first().node().attribute("relative-y").as_int();
23682380
std::string wordStr = words.first().node().text().as_string();

0 commit comments

Comments
 (0)