Skip to content

Commit

Permalink
fix #281601 and fix #284218 [workaround]: broken on-screen rendering …
Browse files Browse the repository at this point in the history
…of synthetically emboldened fonts + collect_artifacts
  • Loading branch information
AntonioBL committed Mar 8, 2020
1 parent 6a94de9 commit 2fd9cad
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions libmscore/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,35 @@ void TextFragment::draw(QPainter* p, const TextBase* t) const
{
QFont f(font(t));
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
#if defined Q_OS_WIN || defined Q_OS_LINUX
if (f.bold()) {
// workaround for https://musescore.org/en/node/284218
// and https://musescore.org/en/node/281601
// only needed for certain artificially emboldened fonts
// see https://musescore.org/en/node/281601#comment-900261
// in Qt 5.12.x this workaround should be no more necessary if
// env variable QT_MAX_CACHED_GLYPH_SIZE is set to 1
p->save();
qreal mm = p->worldTransform().m11();
qreal dx = p->worldTransform().dx();
qreal dy = p->worldTransform().dy();
qreal factor = 1 / mm; // correction factor for bold text drawing
p->setMatrix(QMatrix(mm*factor,0.0,0.0,mm*factor,dx,dy));
f.setPointSizeF(f.pointSizeF() / factor);
p->setFont(f);
p->drawText(pos / factor, text);
// Restore the
p->setMatrix(QMatrix(mm,0.0,0.0,mm,dx,dy));
p->restore();
}
else {
p->setFont(f);
p->drawText(pos, text);
}
#else
p->setFont(f);
p->drawText(pos, text);
#endif
}

//---------------------------------------------------------
Expand Down

0 comments on commit 2fd9cad

Please sign in to comment.