[MusicXML import] justify="right" on direction words is ignored, so right-aligned text runs off the page

Open
#35,844 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, xml
Domain
desktop

Research direction

Start by opening the supplied right-justified-words.musicxml in MuseScore and trace how MusicXML direction words are imported, focusing on how justify="right" is handled when halign is absent. Compare the imported alignment and anchor behavior with the left-justified example; done means right-justified text ends at its anchor and the measure 2 example stays on the page.

Written by the indexing model from the issue text.

Description

community MusicXML
Issue type

Import/export issue

Description with steps to reproduce

<words justify="right"> in a <direction> is imported as left-aligned text that starts at the anchor and extends to the right. Text that the exporting program right-aligned at the end of a measure therefore starts at the barline and runs past the right edge of the page.

  1. Open right-justified-words.musicxml.
  2. Compare the three texts.

Actual:

  • "LEFT-justified text at beat 1" starts at beat 1, as expected;
  • "RIGHT-justified text at beat 3" also starts at beat 3 and extends to the right;
  • in measure 2, the right-justified text with default-x="300" and <offset>4</offset> (end of the measure) starts at the final barline and runs off the page.

Expected: with justify="right" (and so halign="right", which the MusicXML specification derives from justify when halign is absent) the text should end at its anchor, extending to the left.

This matters for Finale exports: Finale writes right-aligned text, such as composer credits for later sections of a piece, this way. In a collection of 981 hymns exported from Finale v27, 188 files contain 915 such texts; the ones we opened in MuseScore all ran off the right edge.

Supporting files, videos and screenshots

Minimal test file, made up for this report. Save it as right-justified-words.musicxml and open it in MuseScore Studio.

right-justified-words.musicxml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="4.0">
  <part-list>
    <score-part id="P1"><part-name>Voice</part-name></score-part>
  </part-list>
  <part id="P1">
    <measure number="1">
      <attributes><divisions>1</divisions><key><fifths>0</fifths></key><time><beats>4</beats><beat-type>4</beat-type></time><clef><sign>G</sign><line>2</line></clef></attributes>
      <direction placement="above">
        <direction-type><words justify="left">LEFT-justified text at beat 1</words></direction-type>
      </direction>
      <note><pitch><step>C</step><octave>5</octave></pitch><duration>2</duration><type>half</type></note>
      <direction placement="below">
        <direction-type><words justify="right">RIGHT-justified text at beat 3</words></direction-type>
      </direction>
      <note><pitch><step>D</step><octave>5</octave></pitch><duration>2</duration><type>half</type></note>
    </measure>
    <measure number="2">
      <direction placement="above">
        <direction-type><words justify="right" default-x="300">RIGHT-justified, default-x 300, offset to the end of the measure</words></direction-type>
        <offset>4</offset>
      </direction>
      <note><pitch><step>E</step><octave>5</octave></pitch><duration>4</duration><type>whole</type></note>
      <barline location="right"><bar-style>light-heavy</bar-style></barline>
    </measure>
  </part>
</score-partwise>
In which versions of MuseScore Studio is this issue present?

4.7.7

Regression

I was unable to check

Operating system

Windows 11 Pro

Additional context

Workaround: remove the <offset> and default-x, set the text left-aligned and move it to the start of the section it labels.

Dominant language
C++
Stars
15.5k
Forks
3.5k
Avg merge
2d 19h
Merged PRs (30d)
124

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from musescore/MuseScore

All issues in musescore/MuseScore

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.