Skip to content

Commit

Permalink
Introduce dynamics cutouts
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-spa committed Jul 25, 2024
1 parent 65370e8 commit d61051f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/engraving/dom/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

#include "barline.h"
#include "box.h"
#include "dynamic.h"
#include "instrumentname.h"
#include "measure.h"
#include "mscore.h"
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit d61051f

Please sign in to comment.