Skip to content

Commit

Permalink
Fix cast off of ligatures
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Nov 11, 2024
1 parent 666e951 commit 810a786
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/vrv/horizontalaligner.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class Alignment : public Object {
*/
std::string LogDebugTreeMsg() override
{
return StringFormat("%d %s", this->GetXRel(), this->GetTime().ToString().c_str());
return StringFormat("%d %f", this->GetXRel(), this->GetTime().ToDouble());
}

//----------------//
Expand Down
6 changes: 5 additions & 1 deletion src/alignfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,12 @@ FunctorCode AlignHorizontallyFunctor::VisitLayerElement(LayerElement *layerEleme
return FUNCTOR_CONTINUE;
}
}
// A ligature gets a default alignment in order to allow mensural cast-off
else if (layerElement->Is(LIGATURE)) {
// Nothing to do
}
// We do not align these (container). Any other?
else if (layerElement->Is({ BEAM, LIGATURE, FTREM, TUPLET })) {
else if (layerElement->Is({ BEAM, FTREM, TUPLET })) {
Fraction duration = layerElement->GetSameAsContentAlignmentDuration(m_currentParams, true, m_notationType);
m_time = m_time + duration;
return FUNCTOR_CONTINUE;
Expand Down
12 changes: 10 additions & 2 deletions src/convertfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "ending.h"
#include "fermata.h"
#include "layer.h"
#include "ligature.h"
#include "mdiv.h"
#include "mrest.h"
#include "page.h"
Expand Down Expand Up @@ -267,12 +268,19 @@ bool ConvertToCastOffMensuralFunctor::IsValidBreakPoint(const Alignment *alignme
// Not all layers have an alignment and we cannot break here
if (alignment->GetChildCount() != nbLayers) return false;

const bool ligatureAsBracket = m_doc->GetOptions()->m_ligatureAsBracket.GetValue();

for (const Object *child : alignment->GetChildren()) {
for (const Object *refChild : child->GetChildren()) {
// Do not break within editorial markup
if (refChild->GetFirstAncestorInRange(EDITORIAL_ELEMENT, EDITORIAL_ELEMENT_max)) return false;
// Do not break within a ligature
if (refChild->GetFirstAncestor(LIGATURE)) return false;
// Do not break within a ligature when rendered as bracket - (notes in it will have a different aligner
// execpt for the first one)
if (ligatureAsBracket && refChild->GetFirstAncestor(LIGATURE)) {
const Ligature *ligature = vrv_cast<const Ligature *>(refChild->GetFirstAncestor(LIGATURE));
assert(ligature);
if (ligature->GetAlignment() != alignment) return false;
}
}
// When we have more than one neume in a syllable, every neume has its own alignment.
// Only the first one, which is shared with the syllable, is a valid break point
Expand Down

0 comments on commit 810a786

Please sign in to comment.