Skip to content

Commit a35a16d

Browse files
committed
'Musical symbols scale' option
1 parent 3d8c538 commit a35a16d

File tree

18 files changed

+256
-35
lines changed

18 files changed

+256
-35
lines changed

src/engraving/dom/mscore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ static constexpr double SPATIUM20 = 5.0 * (DPI / 72.0);
7373
static constexpr double DPMM = DPI / INCH;
7474

7575
// NOTE: the Smufl default is actually 20pt. We use 10 for historical reasons
76-
// and back-compatibility, but this will be multiplied x2 during dynamic layout.
77-
static constexpr double DYNAMICS_DEFAULT_FONT_SIZE = 10.0;
76+
// and back-compatibility, but this will be multiplied x2 during layout.
77+
static constexpr double MUSICAL_SYMBOLS_DEFAULT_FONT_SIZE = 10.0;
7878

7979
static constexpr int MAX_STAVES = 4;
8080

src/engraving/dom/ottava.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ OttavaSegment::OttavaSegment(Ottava* sp, System* parent)
6767
: TextLineBaseSegment(ElementType::OTTAVA_SEGMENT, sp, parent, ElementFlag::MOVABLE | ElementFlag::ON_STAFF)
6868
{
6969
m_text->setTextStyleType(TextStyleType::OTTAVA);
70+
m_endText->setTextStyleType(TextStyleType::OTTAVA);
7071
}
7172

7273
//---------------------------------------------------------

src/engraving/dom/pedal.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "measure.h"
2727
#include "score.h"
2828
#include "system.h"
29+
#include "text.h"
2930

3031
#include "log.h"
3132

@@ -65,6 +66,17 @@ const String Pedal::STAR_SYMBOL = u"<sym>keyboardPedalUp</sym>";
6566
PedalSegment::PedalSegment(Pedal* sp, System* parent)
6667
: TextLineBaseSegment(ElementType::PEDAL_SEGMENT, sp, parent, ElementFlag::MOVABLE | ElementFlag::ON_STAFF)
6768
{
69+
m_text->setTextStyleType(TextStyleType::PEDAL);
70+
m_endText->setTextStyleType(TextStyleType::PEDAL);
71+
}
72+
73+
//---------------------------------------------------------
74+
// propertyDelegate
75+
//---------------------------------------------------------
76+
77+
EngravingItem* PedalSegment::propertyDelegate(Pid pid)
78+
{
79+
return TextLineBaseSegment::propertyDelegate(pid);
6880
}
6981

7082
//---------------------------------------------------------

src/engraving/dom/pedal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class PedalSegment final : public TextLineBaseSegment
4545
PedalSegment* clone() const override { return new PedalSegment(*this); }
4646
Pedal* pedal() const { return toPedal(spanner()); }
4747

48+
EngravingItem* propertyDelegate(Pid) override;
49+
4850
friend class Pedal;
4951
};
5052

src/engraving/dom/property.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ static constexpr PropertyMetaData propertyList[] = {
312312
{ Pid::FRAME_FG_COLOR, false, "frameFgColor", P_TYPE::COLOR, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "frame foreground color") },
313313
{ Pid::FRAME_BG_COLOR, false, "frameBgColor", P_TYPE::COLOR, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "frame background color") },
314314
{ Pid::SIZE_SPATIUM_DEPENDENT, false, "sizeIsSpatiumDependent",P_TYPE::BOOL, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "spatium dependent size") },
315+
{ Pid::MUSICAL_SYMBOLS_SCALE, false, "musicalSymbolsScale", P_TYPE::REAL, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "musical symbols scale") },
315316
{ Pid::TEXT_SIZE_SPATIUM_DEPENDENT, false, "textSizeIsSpatiumDependent", P_TYPE::BOOL, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "spatium dependent text size") },
316317
{ Pid::ALIGN, false, "align", P_TYPE::ALIGN, PropertyGroup::POSITION, DUMMY_QT_TR_NOOP("propertyName", "align") },
317318
{ Pid::TEXT_SCRIPT_ALIGN, false, "align", P_TYPE::INT, PropertyGroup::POSITION, DUMMY_QT_TR_NOOP("propertyName", "text script align") },

src/engraving/dom/property.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ enum class Pid {
322322

323323
FRAME_BG_COLOR,
324324
SIZE_SPATIUM_DEPENDENT,
325+
MUSICAL_SYMBOLS_SCALE,
325326
TEXT_SIZE_SPATIUM_DEPENDENT, // for text component of textLine items
326327
ALIGN,
327328
TEXT_SCRIPT_ALIGN,

src/engraving/dom/textbase.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -872,15 +872,28 @@ mu::draw::Font TextFragment::font(const TextBase* t) const
872872
draw::Font::Type fontType = draw::Font::Type::Unknown;
873873
if (format.fontFamily() == "ScoreText") {
874874
if (t->isDynamic() || t->textStyleType() == TextStyleType::OTTAVA || t->textStyleType() == TextStyleType::HARP_PEDAL_DIAGRAM
875-
|| t->isStringTunings()) {
875+
|| t->textStyleType() == TextStyleType::TUPLET || t->textStyleType() == TextStyleType::PEDAL || t->isStringTunings()) {
876876
std::string fontName = engravingFonts()->fontByName(t->style().styleSt(Sid::MusicalSymbolFont).toStdString())->family();
877877
family = String::fromStdString(fontName);
878878
fontType = draw::Font::Type::MusicSymbol;
879-
if (t->isDynamic()) {
880-
m = DYNAMICS_DEFAULT_FONT_SIZE * t->getProperty(Pid::DYNAMICS_SIZE).toDouble() * spatiumScaling;
881-
if (t->style().styleB(Sid::dynamicsOverrideFont)) {
882-
std::string fontName2 = engravingFonts()->fontByName(t->style().styleSt(Sid::dynamicsFont).toStdString())->family();
883-
family = String::fromStdString(fontName2);
879+
if (!t->isStringTunings()) {
880+
m = MUSICAL_SYMBOLS_DEFAULT_FONT_SIZE;
881+
if (t->isDynamic()) {
882+
m *= t->getProperty(Pid::DYNAMICS_SIZE).toDouble() * spatiumScaling;
883+
if (t->style().styleB(Sid::dynamicsOverrideFont)) {
884+
std::string fontName2 = engravingFonts()->fontByName(t->style().styleSt(Sid::dynamicsFont).toStdString())->family();
885+
family = String::fromStdString(fontName2);
886+
}
887+
} else {
888+
for (const auto& a : *textStyle(t->textStyleType())) {
889+
if (a.type == TextStylePropertyType::MusicalSymbolsScale) {
890+
m *= t->style().styleD(a.sid);
891+
if (t->sizeIsSpatiumDependent()) {
892+
m *= spatiumScaling;
893+
}
894+
break;
895+
}
896+
}
884897
}
885898
}
886899
// We use a default font size of 10pt for historical reasons,

src/engraving/rendering/dev/tupletlayout.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ void TupletLayout::layout(Tuplet* item, LayoutContext& ctx)
5454
//
5555
// create tuplet number if necessary
5656
//
57+
const MStyle& style = ctx.conf().style();
5758
double _spatium = item->spatium();
5859
if (item->numberType() != TupletNumberType::NO_TEXT) {
5960
if (item->number() == nullptr) {
@@ -71,10 +72,21 @@ void TupletLayout::layout(Tuplet* item, LayoutContext& ctx)
7172
item->number()->setPropertyFlags(Pid::FONT_SIZE, item->propertyFlags(Pid::FONT_SIZE));
7273
item->number()->setPropertyFlags(Pid::FONT_STYLE, item->propertyFlags(Pid::FONT_STYLE));
7374
item->number()->setPropertyFlags(Pid::ALIGN, item->propertyFlags(Pid::ALIGN));
74-
if (item->numberType() == TupletNumberType::SHOW_NUMBER) {
75-
item->number()->setXmlText(String(u"%1").arg(item->ratio().numerator()));
75+
76+
String numberString = (item->numberType() == TupletNumberType::SHOW_NUMBER)
77+
? String(u"%1").arg(item->ratio().numerator())
78+
: String(u"%1:%2").arg(item->ratio().numerator(), item->ratio().denominator());
79+
if (style.styleB(Sid::tupletUseSymbols)) {
80+
String smuflNum = String(u"");
81+
for (size_t i = 0; i < numberString.size(); ++i) {
82+
smuflNum.append(u"<sym>tuplet");
83+
smuflNum.append(numberString.at(i).unicode());
84+
smuflNum.append(u"</sym>");
85+
}
86+
smuflNum.replace(String(u":"), String(u"Colon"));
87+
item->number()->setXmlText(smuflNum);
7688
} else {
77-
item->number()->setXmlText(String(u"%1:%2").arg(item->ratio().numerator(), item->ratio().denominator()));
89+
item->number()->setXmlText(numberString);
7890
}
7991

8092
item->setIsSmall(true);
@@ -84,7 +96,7 @@ void TupletLayout::layout(Tuplet* item, LayoutContext& ctx)
8496
break;
8597
}
8698
}
87-
item->number()->mutldata()->setMag(item->isSmall() ? ctx.conf().styleD(Sid::smallNoteMag) : 1.0);
99+
item->number()->mutldata()->setMag(item->isSmall() ? style.styleD(Sid::smallNoteMag) : 1.0);
88100
} else {
89101
if (item->number()) {
90102
if (item->number()->selected()) {
@@ -150,7 +162,6 @@ void TupletLayout::layout(Tuplet* item, LayoutContext& ctx)
150162
//
151163
// calculate bracket start and end point p1 p2
152164
//
153-
const MStyle& style = ctx.conf().style();
154165
double maxSlope = style.styleD(Sid::tupletMaxSlope);
155166
bool outOfStaff = style.styleB(Sid::tupletOufOfStaff);
156167
double vHeadDistance = style.styleMM(Sid::tupletVHeadDistance) * item->mag();

src/engraving/style/styledef.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,10 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
271271
{ Sid::pedalDashGapLen, "pedalDashGapLen", 4.0 },
272272
{ Sid::pedalHookHeight, "pedalHookHeight", Spatium(-1.2) },
273273
{ Sid::pedalFontFace, "pedalFontFace", "Edwin" },
274-
{ Sid::pedalFontSize, "pedalFontSize", 12.0 },
274+
{ Sid::pedalFontSize, "pedalFontSize", 10.0 },
275275
{ Sid::pedalLineSpacing, "pedalLineSpacing", 1.0 },
276276
{ Sid::pedalFontSpatiumDependent, "pedalFontSpatiumDependent", true },
277+
{ Sid::pedalMusicalSymbolsScale, "pedalMusicalSymbolsScale", 1.0 }, // percentage of the standard size
277278
{ Sid::pedalFontStyle, "pedalFontStyle", int(FontStyle::Normal) },
278279
{ Sid::pedalColor, "pedalColor", Color::BLACK },
279280
{ Sid::pedalTextAlign, "pedalTextAlign", Align(AlignH::LEFT, AlignV::BASELINE) },
@@ -285,7 +286,8 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
285286
{ Sid::pedalFrameBgColor, "pedalFrameBgColor", Color::transparent },
286287
{ Sid::pedalText, "pedalText", String(u"<sym>keyboardPedalPed</sym>") },
287288
{ Sid::pedalHookText, "pedalHookText", String() },
288-
{ Sid::pedalContinueText, "pedalContinueText", String(u"(<sym>keyboardPedalPed</sym>)") },
289+
{ Sid::pedalContinueText, "pedalContinueText",
290+
String(u"<sym>keyboardPedalParensLeft</sym><sym>keyboardPedalPed</sym><sym>keyboardPedalParensRight</sym>") },
289291
{ Sid::pedalContinueHookText, "pedalContinueHookText", String() },
290292
{ Sid::pedalEndText, "pedalEndText", String() },
291293
{ Sid::pedalRosetteEndText, "pedalRosetteEndText", String(u"<sym>keyboardPedalUp</sym>") },
@@ -583,6 +585,7 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
583585
{ Sid::ottavaFontSize, "ottavaFontSize", 10.0 },
584586
{ Sid::ottavaLineSpacing, "ottavaLineSpacing", 1.0 },
585587
{ Sid::ottavaFontSpatiumDependent, "ottavaFontSpatiumDependent", true },
588+
{ Sid::ottavaMusicalSymbolsScale, "ottavaMusicalSymbolsScale", 1.0 }, // percentage of the standard size
586589
{ Sid::ottavaFontStyle, "ottavaFontStyle", int(FontStyle::Normal) },
587590
{ Sid::ottavaColor, "ottavaColor", PropertyValue::fromValue(Color::BLACK) },
588591
{ Sid::ottavaTextAlignAbove, "ottavaTextAlignAbove", Align(AlignH::LEFT, AlignV::TOP) },
@@ -625,9 +628,11 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
625628
{ Sid::tupletFontSize, "tupletFontSize", 9.0 },
626629
{ Sid::tupletLineSpacing, "tupletLineSpacing", 1.0 },
627630
{ Sid::tupletFontSpatiumDependent, "tupletFontSpatiumDependent", true },
631+
{ Sid::tupletMusicalSymbolsScale, "tupletMusicalSymbolsScale", 1.0 }, // percentage of the standard size
628632
{ Sid::tupletFontStyle, "tupletFontStyle", int(FontStyle::Italic) },
629633
{ Sid::tupletColor, "tupletColor", PropertyValue::fromValue(Color::BLACK) },
630634
{ Sid::tupletAlign, "tupletAlign", Align(AlignH::HCENTER, AlignV::VCENTER) },
635+
{ Sid::tupletUseSymbols, "tupletUseSymbols", false },
631636
{ Sid::tupletBracketHookHeight, "tupletBracketHookHeight", Spatium(0.75) },
632637
{ Sid::tupletOffset, "tupletOffset", PointF() },
633638
{ Sid::tupletFrameType, "tupletFrameType", int(FrameType::NO_FRAME) },
@@ -831,6 +836,7 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
831836
{ Sid::harpPedalDiagramFontSize, "harpPedalDiagramFontSize", 10.0 },
832837
{ Sid::harpPedalDiagramLineSpacing, "harpPedalDiagramLineSpacing", 1.0 },
833838
{ Sid::harpPedalDiagramFontSpatiumDependent, "harpPedalDiagramFontSpatiumDependent", true },
839+
{ Sid::harpPedalDiagramMusicalSymbolsScale, "harpPedalDiagramMusicalSymbolsScale", 1.0 }, // percentage of the standard size
834840
{ Sid::harpPedalDiagramFontStyle, "harpPedalDiagramFontStyle", int(FontStyle::Normal) },
835841
{ Sid::harpPedalDiagramColor, "harpPedalDiagramColor", PropertyValue::fromValue(Color::BLACK) },
836842
{ Sid::harpPedalDiagramAlign, "harpPedalDiagramAlign", Align(AlignH::HCENTER, AlignV::VCENTER) },
@@ -1609,6 +1615,8 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
16091615

16101616
{ Sid::chordlineThickness, "chordlineThickness", Spatium(0.16) },
16111617

1618+
{ Sid::dummyMusicalSymbolsScale, "dummyMusicalSymbolsScale", 1.0 },
1619+
16121620
{ Sid::autoplaceEnabled, "autoplaceEnabled", true },
16131621
{ Sid::defaultsVersion, "defaultsVersion", Constants::MSC_VERSION }
16141622
} };

src/engraving/style/styledef.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ enum class Sid {
288288
pedalFontSize,
289289
pedalLineSpacing,
290290
pedalFontSpatiumDependent,
291+
pedalMusicalSymbolsScale,
291292
pedalFontStyle,
292293
pedalColor,
293294
pedalTextAlign,
@@ -593,6 +594,7 @@ enum class Sid {
593594
ottavaFontSize,
594595
ottavaLineSpacing,
595596
ottavaFontSpatiumDependent,
597+
ottavaMusicalSymbolsScale,
596598
ottavaFontStyle,
597599
ottavaColor,
598600
ottavaTextAlignAbove,
@@ -636,9 +638,11 @@ enum class Sid {
636638
tupletFontSize,
637639
tupletLineSpacing,
638640
tupletFontSpatiumDependent,
641+
tupletMusicalSymbolsScale,
639642
tupletFontStyle,
640643
tupletColor,
641644
tupletAlign,
645+
tupletUseSymbols,
642646
tupletBracketHookHeight,
643647
tupletOffset,
644648
tupletFrameType,
@@ -843,6 +847,7 @@ enum class Sid {
843847
harpPedalDiagramFontSize,
844848
harpPedalDiagramLineSpacing,
845849
harpPedalDiagramFontSpatiumDependent,
850+
harpPedalDiagramMusicalSymbolsScale,
846851
harpPedalDiagramFontStyle,
847852
harpPedalDiagramColor,
848853
harpPedalDiagramAlign,
@@ -1617,6 +1622,8 @@ enum class Sid {
16171622

16181623
chordlineThickness,
16191624

1625+
dummyMusicalSymbolsScale,
1626+
16201627
autoplaceEnabled,
16211628
defaultsVersion,
16221629

0 commit comments

Comments
 (0)