Skip to content

Commit 2eceb22

Browse files
committed
'Musical symbols scale' option
1 parent 0e9df9c commit 2eceb22

File tree

15 files changed

+187
-29
lines changed

15 files changed

+187
-29
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
@@ -311,6 +311,7 @@ static constexpr PropertyMetaData propertyList[] = {
311311
{ Pid::FRAME_FG_COLOR, false, "frameFgColor", P_TYPE::COLOR, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "frame foreground color") },
312312
{ Pid::FRAME_BG_COLOR, false, "frameBgColor", P_TYPE::COLOR, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "frame background color") },
313313
{ Pid::SIZE_SPATIUM_DEPENDENT, false, "sizeIsSpatiumDependent",P_TYPE::BOOL, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "spatium dependent size") },
314+
{ Pid::MUSICAL_SYMBOLS_SCALE, false, "musicalSymbolsScale", P_TYPE::REAL, PropertyGroup::TEXT, DUMMY_QT_TR_NOOP("propertyName", "musical symbols scale") },
314315
{ Pid::TEXT_SIZE_SPATIUM_DEPENDENT, false, "textSizeIsSpatiumDependent", P_TYPE::BOOL, PropertyGroup::APPEARANCE, DUMMY_QT_TR_NOOP("propertyName", "spatium dependent text size") },
315316
{ Pid::ALIGN, false, "align", P_TYPE::ALIGN, PropertyGroup::POSITION, DUMMY_QT_TR_NOOP("propertyName", "align") },
316317
{ 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
@@ -321,6 +321,7 @@ enum class Pid {
321321

322322
FRAME_BG_COLOR,
323323
SIZE_SPATIUM_DEPENDENT,
324+
MUSICAL_SYMBOLS_SCALE,
324325
TEXT_SIZE_SPATIUM_DEPENDENT, // for text component of textLine items
325326
ALIGN,
326327
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/style.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,25 @@ void MStyle::read(XmlReader& e, compat::ReadChordListHook* readChordListHook)
371371
if (pedContText != "") {
372372
set(Sid::pedalText, pedContText);
373373
}
374+
} else if ((tag == "pedalFontSize"
375+
|| tag == "ottavaFontSize"
376+
|| tag == "tupletFontSize"
377+
|| tag == "harpPedalDiagramFontSize")
378+
&& m_version < 430) {
379+
double _val = e.readDouble();
380+
if (tag == "pedalFontSize") {
381+
set(Sid::pedalFontSize, _val);
382+
set(Sid::pedalMusicalSymbolsScale, (_val / MUSICAL_SYMBOLS_DEFAULT_FONT_SIZE));
383+
} else if (tag == "ottavaFontSize") {
384+
set(Sid::ottavaFontSize, _val);
385+
set(Sid::ottavaMusicalSymbolsScale, (_val / MUSICAL_SYMBOLS_DEFAULT_FONT_SIZE));
386+
} else if (tag == "tupletFontSize") {
387+
set(Sid::tupletFontSize, _val);
388+
set(Sid::tupletMusicalSymbolsScale, (_val / MUSICAL_SYMBOLS_DEFAULT_FONT_SIZE));
389+
} else if (tag == "harpPedalDiagramFontSize") {
390+
set(Sid::harpPedalDiagramFontSize, _val);
391+
set(Sid::harpPedalDiagramMusicalSymbolsScale, (_val / MUSICAL_SYMBOLS_DEFAULT_FONT_SIZE));
392+
}
374393
} else if (!readProperties(e)) {
375394
e.unknown();
376395
}
@@ -381,6 +400,10 @@ void MStyle::read(XmlReader& e, compat::ReadChordListHook* readChordListHook)
381400
// to INSIDE for compatibility. For files 4.2 and newer, defaults to OUTSIDE.
382401
set(Sid::tiePlacementChord, TiePlacement::INSIDE);
383402
}
403+
if (m_version < 430 && !MScore::testMode) {
404+
//This style didn't exist before version 4.3, so using the old look.
405+
set(Sid::tupletUseSymbols, false);
406+
}
384407

385408
if (readChordListHook) {
386409
readChordListHook->validate();

src/engraving/style/styledef.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
274274
{ Sid::pedalFontSize, "pedalFontSize", 12.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>") },
@@ -578,6 +580,7 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
578580
{ Sid::ottavaFontSize, "ottavaFontSize", 10.0 },
579581
{ Sid::ottavaLineSpacing, "ottavaLineSpacing", 1.0 },
580582
{ Sid::ottavaFontSpatiumDependent, "ottavaFontSpatiumDependent", true },
583+
{ Sid::ottavaMusicalSymbolsScale, "ottavaMusicalSymbolsScale", 1.0 }, // percentage of the standard size
581584
{ Sid::ottavaFontStyle, "ottavaFontStyle", int(FontStyle::Normal) },
582585
{ Sid::ottavaColor, "ottavaColor", PropertyValue::fromValue(Color::BLACK) },
583586
{ Sid::ottavaTextAlignAbove, "ottavaTextAlignAbove", Align(AlignH::LEFT, AlignV::TOP) },
@@ -620,9 +623,11 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
620623
{ Sid::tupletFontSize, "tupletFontSize", 9.0 },
621624
{ Sid::tupletLineSpacing, "tupletLineSpacing", 1.0 },
622625
{ Sid::tupletFontSpatiumDependent, "tupletFontSpatiumDependent", true },
626+
{ Sid::tupletMusicalSymbolsScale, "tupletMusicalSymbolsScale", 1.0 }, // percentage of the standard size
623627
{ Sid::tupletFontStyle, "tupletFontStyle", int(FontStyle::Italic) },
624628
{ Sid::tupletColor, "tupletColor", PropertyValue::fromValue(Color::BLACK) },
625629
{ Sid::tupletAlign, "tupletAlign", Align(AlignH::HCENTER, AlignV::VCENTER) },
630+
{ Sid::tupletUseSymbols, "tupletUseSymbols", true },
626631
{ Sid::tupletBracketHookHeight, "tupletBracketHookHeight", Spatium(0.75) },
627632
{ Sid::tupletOffset, "tupletOffset", PointF() },
628633
{ Sid::tupletFrameType, "tupletFrameType", int(FrameType::NO_FRAME) },
@@ -826,6 +831,7 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
826831
{ Sid::harpPedalDiagramFontSize, "harpPedalDiagramFontSize", 10.0 },
827832
{ Sid::harpPedalDiagramLineSpacing, "harpPedalDiagramLineSpacing", 1.0 },
828833
{ Sid::harpPedalDiagramFontSpatiumDependent, "harpPedalDiagramFontSpatiumDependent", true },
834+
{ Sid::harpPedalDiagramMusicalSymbolsScale, "harpPedalDiagramMusicalSymbolsScale", 1.0 }, // percentage of the standard size
829835
{ Sid::harpPedalDiagramFontStyle, "harpPedalDiagramFontStyle", int(FontStyle::Normal) },
830836
{ Sid::harpPedalDiagramColor, "harpPedalDiagramColor", PropertyValue::fromValue(Color::BLACK) },
831837
{ Sid::harpPedalDiagramAlign, "harpPedalDiagramAlign", Align(AlignH::HCENTER, AlignV::VCENTER) },

0 commit comments

Comments
 (0)