Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ composer ,composer
#a ,piano

a >/l#d4 .8"?8.8?8;8?_8?
b "8"?,8?>k.8.?#0-v<K
b "8"?,8?">k.8.?#0-v<K
2 changes: 1 addition & 1 deletion src/engraving/dom/bend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Font Bend::font(double sp) const
f.setUnderline(m_fontStyle & FontStyle::Underline);
f.setStrike(m_fontStyle & FontStyle::Strike);
double m = m_fontSize;
m *= sp / SPATIUM20;
m *= sp / defaultSpatium();

f.setPointSizeF(m);
return f;
Expand Down
7 changes: 6 additions & 1 deletion src/engraving/dom/engravingitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ double EngravingItem::spatium() const
return s ? s->spatium(this) : style().spatium();
}

double EngravingItem::defaultSpatium() const
{
return style().defaultSpatium();
}

bool EngravingItem::isInteractionAvailable() const
{
if (!getProperty(Pid::VISIBLE).toBool() && (score()->printing() || !score()->isShowInvisible())) {
Expand Down Expand Up @@ -293,7 +298,7 @@ PlacementV EngravingItem::placement() const

double EngravingItem::magS() const
{
return mag() * (style().spatium() / SPATIUM20);
return mag() * (style().spatium() / defaultSpatium());
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/engravingitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class EngravingItem : public EngravingObject
virtual bool isEngravingItem() const override { return true; }

double spatium() const;
double defaultSpatium() const;

inline void setFlag(ElementFlag f, bool v)
{
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/dom/harmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,12 +1200,12 @@ void TextSegment::setFont(const muse::draw::Font& f)
const Char& c2 = m_text.at(i + 1);
++i;
char32_t v = Char::surrogateToUcs4(c, c2);
if (!fm.inFontUcs4(v)) {
if (!fm.inFont(v)) {
fail = true;
break;
}
} else {
if (!fm.inFont(c)) {
if (!fm.inFont(c.unicode())) {
fail = true;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/indicatoricon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Font IndicatorIcon::font() const
{
Font font(configuration()->iconsFontFamily(), Font::Type::Icon);
static constexpr double STANDARD_POINT_SIZE = 12.0;
const double scaling = spatium() / SPATIUM20;
const double scaling = spatium() / defaultSpatium();
font.setPointSizeF(STANDARD_POINT_SIZE * scaling);
return font;
}
2 changes: 1 addition & 1 deletion src/engraving/dom/layoutbreak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Font LayoutBreak::font() const
{
Font font(configuration()->iconsFontFamily(), Font::Type::Icon);
static constexpr double STANDARD_POINT_SIZE = 12.0;
double scaling = spatium() / SPATIUM20;
double scaling = spatium() / defaultSpatium();
font.setPointSizeF(STANDARD_POINT_SIZE * scaling);
return font;
}
Expand Down
2 changes: 0 additions & 2 deletions src/engraving/dom/mscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ bool MScore::noImages = false;
bool MScore::pdfPrinting = false;
bool MScore::svgPrinting = false;

double MScore::pixelRatio = 0.8; // DPI / logicalDPI

extern void initDrumset();

MsError MScore::_error { MsError::MS_NO_ERROR };
Expand Down
16 changes: 9 additions & 7 deletions src/engraving/dom/mscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ inline constexpr bool isDownVoice(voice_idx_t voiceIdx)
static constexpr int MAX_HEADERS = 3;
static constexpr int MAX_FOOTERS = 3;

static constexpr double INCH = 25.4;
static constexpr double PPI = 72.0; // printer points per inch
static constexpr double DPI_F = 5;
static constexpr double DPI = 72.0 * DPI_F;
static constexpr double SPATIUM20 = 5.0 * (DPI / 72.0);
static constexpr double DPMM = DPI / INCH;
// UNIVERSAL UNITS
static constexpr double INCH = 25.4; // millimitres per inch
static constexpr double PPI = 72.0; // typographical points per inch

// INTERNAL DRAWING UNITS
// Given that it's ultimately arbitrary, we may as well set our internal units to
// something that makes them easier to read when debugging, e.g. 1/100 of millimitre.
static constexpr double DPI = 1200;
static constexpr double DPMM = DPI / INCH;

// NOTE: the SMuFL default is actually 20pt. We use 10 for historical reasons
// and back-compatibility, but this will be multiplied x2 during layout.
Expand Down Expand Up @@ -220,7 +223,6 @@ class MScore

static bool pdfPrinting;
static bool svgPrinting;
static double pixelRatio;

static double verticalPageGap;
static double horizontalPageGapEven;
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/dom/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ void Score::spatiumChanged(double oldValue, double newValue)
for (Staff* staff : m_staves) {
staff->spatiumChanged(oldValue, newValue);
}
m_layoutOptions.noteHeadWidth = m_engravingFont->width(SymId::noteheadBlack, newValue / SPATIUM20);
m_layoutOptions.noteHeadWidth = m_engravingFont->width(SymId::noteheadBlack, newValue / style().defaultSpatium());
createPaddingTable();
}

Expand Down Expand Up @@ -6008,7 +6008,7 @@ void Score::doLayoutRange(const Fraction& st, const Fraction& et)
}

m_engravingFont = engravingFonts()->fontByName(style().value(Sid::musicalSymbolFont).value<String>().toStdString());
m_layoutOptions.noteHeadWidth = m_engravingFont->width(SymId::noteheadBlack, style().spatium() / SPATIUM20);
m_layoutOptions.noteHeadWidth = m_engravingFont->width(SymId::noteheadBlack, style().spatium() / style().defaultSpatium());

if (this->cmdState().layoutFlags & LayoutFlag::REBUILD_MIDI_MAPPING) {
if (this->isMaster()) {
Expand Down
5 changes: 0 additions & 5 deletions src/engraving/dom/scorefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ std::shared_ptr<Pixmap> Score::createThumbnail()

auto pixmap = imageProvider()->createPixmap(w, h, dpm, configuration()->thumbnailBackgroundColor());

double pr = MScore::pixelRatio;
MScore::pixelRatio = 1.0;

auto painterProvider = imageProvider()->painterForImage(pixmap);
Painter p(painterProvider, "thumbnail");

Expand All @@ -99,8 +96,6 @@ std::shared_ptr<Pixmap> Score::createThumbnail()
print(&p, 0);
p.endDraw();

MScore::pixelRatio = pr;

if (layoutMode() != mode) {
setLayoutMode(mode);
doLayout();
Expand Down
47 changes: 41 additions & 6 deletions src/engraving/dom/stafftype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void StaffType::setDurationMetrics()
RectF bb(fm.tightBoundingRect(txt));
// raise symbols by a default margin and, if marks are above lines, by half the line distance
// (converted from spatium units to raster units)
m_durationGridYOffset = (TAB_DEFAULT_DUR_YOFFS - (m_onLines ? 0.0 : lineDistance().val() * 0.5)) * SPATIUM20;
m_durationGridYOffset = (TAB_DEFAULT_DUR_YOFFS - (m_onLines ? 0.0 : lineDistance().val() * 0.5)) * defaultSpatium();
// this is the bottomest point of any duration sign
m_durationYOffset = m_durationGridYOffset;
// move symbols so that the lowest margin 'sits' on the base line:
Expand Down Expand Up @@ -480,12 +480,12 @@ void StaffType::setFretMetrics()

// Calculate position for dead fret marks - these must be centred separately based on their glyph
RectF deadBb = fm.tightBoundingRect(m_fretFontInfo.xChar);
double lineThickness = style().styleS(Sid::staffLineWidth).val() * SPATIUM20 * 0.5;
double lineThickness = style().styleS(Sid::staffLineWidth).val() * defaultSpatium() * 0.5;
m_deadFretYOffset = -deadBb.y() / 2.0 + lineThickness;

// if on string, we are done; if between strings, raise by half line distance
if (!m_onLines) {
double lineAdj = lineDistance().val() * SPATIUM20 * 0.5;
double lineAdj = lineDistance().val() * defaultSpatium() * 0.5;
m_fretYOffset -= lineAdj;
m_deadFretYOffset -= lineAdj;
}
Expand Down Expand Up @@ -522,6 +522,11 @@ void StaffType::setDurationFontName(const String& name)
// durationBoxH / durationBoxY
//---------------------------------------------------------

double StaffType::defaultSpatium() const
{
return StyleDef::styleValues[static_cast<size_t>(Sid::spatium)].defaultValue().toDouble();
}

double StaffType::durationBoxH() const
{
if (!m_genDurations && !m_stemless) {
Expand All @@ -535,7 +540,37 @@ double StaffType::durationBoxY() const
if (!m_genDurations && !m_stemless) {
return 0.0;
}
return m_durationBoxY + m_durationFontUserY * SPATIUM20;
return m_durationBoxY + m_durationFontUserY * defaultSpatium();
}

double StaffType::durationFontYOffset() const
{
return m_durationYOffset + m_durationFontUserY * defaultSpatium();
}

double StaffType::fretBoxY() const
{
return m_fretBoxY + m_fretFontUserY * defaultSpatium();
}

double StaffType::deadFretBoxY() const
{
return m_deadFretBoxY + m_fretFontUserY * defaultSpatium();
}

double StaffType::fretMaskH() const
{
return m_lineDistance.val() * defaultSpatium();
}

double StaffType::fretMaskY() const
{
return (m_onLines ? -0.5 : -1.0) * m_lineDistance.val() * defaultSpatium();
}

double StaffType::fretFontYOffset() const
{
return m_fretYOffset + m_fretFontUserY * defaultSpatium();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -669,7 +704,7 @@ void StaffType::drawInputStringMarks(Painter* p, int string, const Color& select
static constexpr double LEDGER_LINE_LEFTX = 0.25; // in % of cursor rectangle width
static constexpr double LEDGER_LINE_RIGHTX = 0.75; // in % of cursor rectangle width

double spatium = SPATIUM20;
double spatium = defaultSpatium();
double lineDist = m_lineDistance.val() * spatium;
bool hasFret = false;
String text = tabBassStringPrefix(string, &hasFret);
Expand All @@ -691,7 +726,7 @@ void StaffType::drawInputStringMarks(Painter* p, int string, const Color& select
// draw the text, if any
if (!text.isEmpty()) {
Font f = fretFont();
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
f.setPointSizeF(f.pointSizeF());
p->setFont(f);
p->drawText(PointF(rect.left(), rect.top() + lineDist), text);
}
Expand Down
13 changes: 7 additions & 6 deletions src/engraving/dom/stafftype.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,22 +258,22 @@ class StaffType
const String& durationFontName() const { return m_durationFonts[m_durationFontIdx].displayName; }
double durationFontSize() const { return m_durationFontSize; }
double durationFontUserY() const { return m_durationFontUserY; }
double durationFontYOffset() const { return m_durationYOffset + m_durationFontUserY * SPATIUM20; }
double durationFontYOffset() const;
double durationGridYOffset() const { return m_durationGridYOffset; }
double fretBoxH() const { return m_fretBoxH; }
double deadFretBoxH() const { return m_deadFretBoxH; }
double fretBoxY() const { return m_fretBoxY + m_fretFontUserY * SPATIUM20; }
double deadFretBoxY() const { return m_deadFretBoxY + m_fretFontUserY * SPATIUM20; }
double fretBoxY() const;
double deadFretBoxY() const;

// 2 methods to return the size of a box masking lines under a fret mark
double fretMaskH() const { return m_lineDistance.val() * SPATIUM20; }
double fretMaskY() const { return (m_onLines ? -0.5 : -1.0) * m_lineDistance.val() * SPATIUM20; }
double fretMaskH() const;
double fretMaskY() const;

const muse::draw::Font& fretFont() const { return m_fretFont; }
const String fretFontName() const { return m_fretFontInfo.displayName; }
double fretFontSize() const { return m_fretFontSize; }
double fretFontUserY() const { return m_fretFontUserY; }
double fretFontYOffset() const { return m_fretYOffset + m_fretFontUserY * SPATIUM20; }
double fretFontYOffset() const;
bool genDurations() const { return m_genDurations; }
bool linesThrough() const { return m_linesThrough; }
TablatureMinimStyle minimStyle() const { return m_minimStyle; }
Expand Down Expand Up @@ -336,6 +336,7 @@ class StaffType

Score* m_score = nullptr;

double defaultSpatium() const;
void setDurationMetrics();
void setFretMetrics();

Expand Down
54 changes: 5 additions & 49 deletions src/engraving/dom/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <stack>

#include "draw/fontmetrics.h"
#include "draw/painter.h"

#include "iengravingfont.h"

Expand Down Expand Up @@ -851,37 +850,6 @@ bool TextFragment::operator ==(const TextFragment& f) const
return format == f.format && text == f.text;
}

//---------------------------------------------------------
// draw
//---------------------------------------------------------

void TextFragment::draw(Painter* p, const TextBase* t) const
{
Font f(font(t));
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
#ifndef Q_OS_MACOS
TextBase::drawTextWorkaround(p, f, pos, text);
#else
p->setFont(f);
p->drawText(pos, text);
#endif
}

//---------------------------------------------------------
// drawTextWorkaround
//---------------------------------------------------------

void TextBase::drawTextWorkaround(Painter* p, Font& f, const PointF& pos, const String& text)
{
double mm = p->worldTransform().m11();
if (!(MScore::pdfPrinting) && (mm < 1.0) && f.bold() && !(f.underline() || f.strike())) {
p->drawTextWorkaround(f, pos, text);
} else {
p->setFont(f);
p->drawText(pos, text);
}
}

//---------------------------------------------------------
// font
//---------------------------------------------------------
Expand All @@ -894,9 +862,9 @@ Font TextFragment::font(const TextBase* t) const
double spatiumScaling = 0.0;

if (t->isInstrumentName()) {
spatiumScaling = toInstrumentName(t)->largestStaffSpatium() / SPATIUM20;
spatiumScaling = toInstrumentName(t)->largestStaffSpatium() / t->defaultSpatium();
} else {
spatiumScaling = t->spatium() / SPATIUM20;
spatiumScaling = t->spatium() / t->defaultSpatium();
}

if (t->sizeIsSpatiumDependent()) {
Expand Down Expand Up @@ -969,12 +937,12 @@ Font TextFragment::font(const TextBase* t) const
const Char& c2 = text.at(i + 1);
++i;
char32_t v = Char::surrogateToUcs4(c, c2);
if (!fm.inFontUcs4(v)) {
if (!fm.inFont(v)) {
fail = true;
break;
}
} else {
if (!fm.inFont(c)) {
if (!fm.inFont(c.unicode())) {
fail = true;
break;
}
Expand Down Expand Up @@ -1003,20 +971,8 @@ Font TextFragment::font(const TextBase* t) const
return font;
}

//---------------------------------------------------------
// draw
//---------------------------------------------------------

void TextBlock::draw(Painter* p, const TextBase* t) const
{
p->translate(0.0, m_y);
for (const TextFragment& f : m_fragments) {
f.draw(p, t);
}
p->translate(0.0, -m_y);
}

//---------------------------------------------------------
// fragmentsWithoutEmpty
//---------------------------------------------------------

Expand Down Expand Up @@ -2580,7 +2536,7 @@ Font TextBase::font() const
{
double m = size();
if (sizeIsSpatiumDependent()) {
m *= spatium() / SPATIUM20;
m *= spatium() / defaultSpatium();
}
Font f(family(), Font::Type::Unknown);
f.setPointSizeF(m);
Expand Down
Loading
Loading