humdrum-tools / verovio-humdrum-viewer

Verovio Humdrum Viewer
http://verovio.humdrum.org
36 stars 9 forks source link

Add space before single-character accented character #853

Closed craigsapp closed 9 months ago

craigsapp commented 9 months ago

Verovio starts syllables to the left of notes, causing single-letter syllables to look strange. Currently the humdrum-to-MEI converter automatically adds a non-breaking space before the single-letter syllable to make the syllable to be closer to centered on the note instead.

For accented characters this is complicate to detect a single-character syllable, (1) because HTML entitites are not single character themselves such as è, and (2) the UTF-8 version has multiple bytes for a single character, such as è.

Apply the extra space to both such cases.

Test example:

Screenshot 2023-10-02 at 11 06 45

View in VHV

Current conversion into MEI:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="5.0">
 <meiHead>
  <fileDesc>
   <titleStmt>
    <title />
   </titleStmt>
   <pubStmt />
  </fileDesc>
  <encodingDesc>
   <appInfo>
    <application isodate="2023-10-02T11:07:21" version="4.1.0-dev-dc0ce11">
     <name>Verovio</name>
     <p>Transcoded from Humdrum</p>
    </application>
   </appInfo>
  </encodingDesc>
  <workList>
   <work>
    <title />
   </work>
  </workList>
 </meiHead>
 <music>
  <body>
   <mdiv xml:id="mwcd1bm">
    <score xml:id="s1q4v2f0">
     <scoreDef xml:id="s17efbn3">
      <staffGrp xml:id="sm91ff3">
       <staffDef xml:id="staffdef-L1F1" n="1" lines="5">
        <clef xml:id="c1ifhawq" shape="G" line="2" />
        <meterSig xml:id="metersig-L2F1" count="4" unit="4" />
       </staffDef>
      </staffGrp>
     </scoreDef>
     <section xml:id="section-L1F1">
      <measure xml:id="measure-L1">
       <staff xml:id="staff-L1F1" n="1">
        <layer xml:id="layer-L1F1N1" n="1">
         <rest xml:id="rest-L4F1" dur="4" />
         <note xml:id="note-L5F1" dur="4" oct="4" pname="e" accid.ges="n">
          <verse xml:id="verse-L5F2" n="1">
           <syl xml:id="syl-L5F2"> e</syl>
          </verse>
         </note>
        </layer>
       </staff>
      </measure>
      <measure xml:id="measure-L6">
       <staff xml:id="staff-L6F1N1" n="1">
        <layer xml:id="layer-L6F1N1" n="1">
         <rest xml:id="rest-L7F1" dur="4" />
         <note xml:id="note-L8F1" dur="4" oct="4" pname="f" accid.ges="n">
          <verse xml:id="verse-L8F2" n="1">
           <syl xml:id="syl-L8F2">è</syl>
          </verse>
         </note>
        </layer>
       </staff>
      </measure>
      <measure xml:id="measure-L9">
       <staff xml:id="staff-L9F1N1" n="1">
        <layer xml:id="layer-L9F1N1" n="1">
         <rest xml:id="rest-L10F1" dur="4" />
         <note xml:id="note-L11F1" dur="4" oct="4" pname="g" accid.ges="n">
          <verse xml:id="verse-L11F2" n="1">
           <syl xml:id="syl-L11F2">è</syl>
          </verse>
         </note>
        </layer>
       </staff>
      </measure>
     </section>
    </score>
   </mdiv>
  </body>
 </music>
</mei>

Note that the e has a (non-breaking) space (c2 a0) before it in the conversion.

craigsapp commented 9 months ago

Implemented with commit https://github.com/rism-digital/verovio/commit/1ee7d3ec43029ea0586ceaeb9af20bc1de8da410

Now renders as:

Screenshot 2023-10-02 at 18 53 21

MEI translation:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="5.0">
 <meiHead>
  <fileDesc>
   <titleStmt>
    <title />
   </titleStmt>
   <pubStmt />
  </fileDesc>
  <encodingDesc>
   <appInfo>
    <application isodate="2023-10-02T18:54:53" version="4.1.0-dev-ef1868d-dirty">
     <name>Verovio</name>
     <p>Transcoded from Humdrum</p>
    </application>
   </appInfo>
  </encodingDesc>
  <workList>
   <work>
    <title />
   </work>
  </workList>
 </meiHead>
 <music>
  <body>
   <mdiv xml:id="m19vxkzk">
    <score xml:id="sohepj0">
     <scoreDef xml:id="s18cudo9">
      <staffGrp xml:id="s1p60x1s">
       <staffDef xml:id="staffdef-L1F1" n="1" lines="5">
        <clef xml:id="c8g87wm" shape="G" line="2" />
        <meterSig xml:id="metersig-L2F1" count="4" unit="4" />
       </staffDef>
      </staffGrp>
     </scoreDef>
     <section xml:id="section-L1F1">
      <measure xml:id="measure-L1">
       <staff xml:id="staff-L1F1" n="1">
        <layer xml:id="layer-L1F1N1" n="1">
         <rest xml:id="rest-L4F1" dur="4" />
         <note xml:id="note-L5F1" dur="4" oct="4" pname="e" accid.ges="n">
          <verse xml:id="verse-L5F2" n="1">
           <syl xml:id="syl-L5F2"> e</syl>
          </verse>
         </note>
        </layer>
       </staff>
      </measure>
      <measure xml:id="measure-L6">
       <staff xml:id="staff-L6F1N1" n="1">
        <layer xml:id="layer-L6F1N1" n="1">
         <rest xml:id="rest-L7F1" dur="4" />
         <note xml:id="note-L8F1" dur="4" oct="4" pname="f" accid.ges="n">
          <verse xml:id="verse-L8F2" n="1">
           <syl xml:id="syl-L8F2"> è</syl>
          </verse>
         </note>
        </layer>
       </staff>
      </measure>
      <measure xml:id="measure-L9">
       <staff xml:id="staff-L9F1N1" n="1">
        <layer xml:id="layer-L9F1N1" n="1">
         <rest xml:id="rest-L10F1" dur="4" />
         <note xml:id="note-L11F1" dur="4" oct="4" pname="g" accid.ges="n">
          <verse xml:id="verse-L11F2" n="1">
           <syl xml:id="syl-L11F2"> è</syl>
          </verse>
         </note>
        </layer>
       </staff>
      </measure>
     </section>
    </score>
   </mdiv>
  </body>
 </music>
</mei>