From d61051fb28daecae01ae356c6ecdbcfcfcaf16be Mon Sep 17 00:00:00 2001 From: Michele Spagnolo Date: Thu, 25 Jul 2024 14:24:01 +0200 Subject: [PATCH] Introduce dynamics cutouts --- src/engraving/dom/textbase.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/engraving/dom/textbase.cpp b/src/engraving/dom/textbase.cpp index b1da7a2480696..2ba19e23bb76e 100644 --- a/src/engraving/dom/textbase.cpp +++ b/src/engraving/dom/textbase.cpp @@ -44,6 +44,7 @@ #include "barline.h" #include "box.h" +#include "dynamic.h" #include "instrumentname.h" #include "measure.h" #include "mscore.h" @@ -1058,7 +1059,8 @@ void TextBlock::layout(const TextBase* t) for (auto fi = m_fragments.begin(); fi != m_fragments.end(); ++fi) { TextFragment& f = *fi; f.pos.setX(x); - FontMetrics fm(f.font(t)); + Font fragmentFont = f.font(t); + FontMetrics fm(fragmentFont); if (f.format.valign() != VerticalAlignment::AlignNormal) { double voffset = fm.xHeight() / subScriptSize; // use original height if (f.format.valign() == VerticalAlignment::AlignSubScript) { @@ -1077,8 +1079,13 @@ void TextBlock::layout(const TextBase* t) const double w = fm.width(f.text); x += w; } - - m_shape.add(fm.tightBoundingRect(f.text).translated(f.pos), t); + if (t->isDynamic() && fragmentFont.type() == Font::Type::MusicSymbol) { + const Dynamic* dyn = toDynamic(t); + SymId symId = TConv::symId(dyn->dynamicType()); + m_shape.add(dyn->symShapeWithCutouts(symId).translated(f.pos)); + } else { + m_shape.add(fm.tightBoundingRect(f.text).translated(f.pos), t); + } Font font = f.font(t); if (font.type() == Font::Type::MusicSymbol || font.type() == Font::Type::MusicSymbolText) { // SEMI-HACK: Music fonts can have huge linespacing because of tall symbols, so instead of using the