Skip to content

Commit

Permalink
fix #315363 : Workaround for bad on-screen rendering of emboldened fo…
Browse files Browse the repository at this point in the history
…nt for harmony elements
  • Loading branch information
AntonioBL authored and vpereverzev committed Jan 11, 2021
1 parent c086567 commit 27cc075
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions libmscore/harmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1501,8 +1501,12 @@ void Harmony::draw(QPainter* painter) const
for (const TextSegment* ts : textList) {
QFont f(ts->font);
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
#ifndef Q_OS_MACOS
TextBase::drawTextWorkaround(painter, f, ts->pos(), ts->text);
#else
painter->setFont(f);
painter->drawText(ts->pos(), ts->text);
#endif
}
}

Expand Down
17 changes: 13 additions & 4 deletions libmscore/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,19 @@ void TextFragment::draw(QPainter* p, const TextBase* t) const
QFont 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(QPainter* p, QFont& f, const QPointF pos, const QString text)
{
qreal mm = p->worldTransform().m11();
if (!(MScore::pdfPrinting) && (mm < 1.0) && f.bold() && !(f.underline())) {
// workaround for https://musescore.org/en/node/284218
Expand Down Expand Up @@ -819,10 +832,6 @@ void TextFragment::draw(QPainter* p, const TextBase* t) const
p->setFont(f);
p->drawText(pos, text);
}
#else
p->setFont(f);
p->drawText(pos, text);
#endif
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/textbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class TextBase : public Element {

virtual void draw(QPainter*) const override;
virtual void drawEditMode(QPainter* p, EditData& ed) override;
static void drawTextWorkaround(QPainter* p, QFont& f, const QPointF pos, const QString text);

static QString plainToXmlText(const QString& s) { return s.toHtmlEscaped(); }
void setPlainText(const QString& t) { setXmlText(plainToXmlText(t)); }
Expand Down

0 comments on commit 27cc075

Please sign in to comment.