Merge pull request #1286 from MarcSabatella/32391-lyric-center

fix #32391: center lyrics under whole notes
This commit is contained in:
Nicolas Froment 2014-09-11 10:09:22 +02:00
commit 516d0376c1
7 changed files with 26 additions and 7 deletions

View file

@ -224,13 +224,30 @@ void Lyrics::layout1()
int line = ll->indexOf(this);
qreal y = lh * line + point(score()->styleS(StyleIdx::lyricsDistance));
qreal x = 0.0;
//
// left align if syllable has a number or is a melisma
// left align if syllable has a number or is a melisma or is first syllable of hyphenated word
//
if (_ticks == 0 && (textStyle().align() & AlignmentFlags::HCENTER) && !_verseNumber)
x += symWidth(SymId::noteheadBlack) * .5;
else if (_ticks || ((textStyle().align() & AlignmentFlags::HCENTER) && _verseNumber))
x += width() * .5;
ChordRest* cr = chordRest();
qreal maxWidth;
if (cr->type() == Element::Type::CHORD)
maxWidth = static_cast<Chord*>(cr)->maxHeadWidth();
else
maxWidth = cr->width(); // TODO: exclude ledger line for multivoice rest?
qreal nominalWidth = symWidth(SymId::noteheadBlack);
bool hyphenatedMelisma = false;
if (_syllabic == Syllabic::BEGIN || _syllabic == Syllabic::MIDDLE) {
// hyphenated syllables representing melismas need to be left aligned
// detecting this means finding next CR on same track and checking for existence of lyric in same verse
Segment* s = cr->segment()->next1();
ChordRest* ncr = s ? s->nextChordRest(cr->track()) : nullptr;
if (ncr && !ncr->lyrics(_no))
hyphenatedMelisma = true;
}
if (_ticks == 0 && !hyphenatedMelisma && (textStyle().align() & AlignmentFlags::HCENTER) && !_verseNumber)
x += nominalWidth * .5 - cr->x();
else if (_ticks || hyphenatedMelisma || ((textStyle().align() & AlignmentFlags::HCENTER) && _verseNumber))
x += (width() + nominalWidth - maxWidth) * .5 - cr->x();
rxpos() += x;
rypos() += y;
if (_verseNumber) {

View file

@ -35,7 +35,8 @@ else
accidental-1 accidental-2 accidental-3 accidental-4 accidental-5\
accidental-6 accidental-7 accidental-8 accidental-9\
tie-1 tie-2 grace-1 grace-2 grace-3 harmony-1 harmony-2 harmony-3 harmony-4 beams-1 beams-2\
user-offset-1 user-offset-2 chord-space-1 tablature-1 image-1"
user-offset-1 user-offset-2 chord-space-1 tablature-1 image-1\
lyrics-1 lyrics-2"
fi
DPI=130

View file

@ -16,7 +16,8 @@ set SRC=mmrest-1,bravura-mmrest,gonville-mmrest,mmrest-2,mmrest-4,mmrest-5,mmres
accidental-1,accidental-2,accidental-3,accidental-4,accidental-5, ^
accidental-6,accidental-7,accidental-8,accidental-9, ^
tie-1,tie-2,grace-1,grace-2,grace-3,harmony-1,harmony-2,harmony-3,harmony-4,beams-1,beams-2, ^
user-offset-1,user-offset-2,chord-space-1,tablature-1,image-1
user-offset-1,user-offset-2,chord-space-1,tablature-1,image-1, ^
lyrics-1,lyrics-2
set MSCORE=..\win32install\bin\mscore.exe
set DPI=130

BIN
vtest/lyrics-1-ref.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

BIN
vtest/lyrics-1.mscz Normal file

Binary file not shown.

BIN
vtest/lyrics-2-ref.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
vtest/lyrics-2.mscz Normal file

Binary file not shown.