Skip to content

Commit dd339d8

Browse files
committed
Remove drawTextWorkaround
No idea about the exact history of this. It seems to have been introduced as a Mac-specific hack ages ago to solve some Qt-related problem. Pretty sure it's not necessary anymore (also produces no difference in vtests).
1 parent 75400fa commit dd339d8

File tree

14 files changed

+1
-125
lines changed

14 files changed

+1
-125
lines changed

src/engraving/dom/textbase.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -863,27 +863,8 @@ void TextFragment::draw(Painter* p, const TextBase* t) const
863863
{
864864
Font f(font(t));
865865
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
866-
#ifndef Q_OS_MACOS
867-
TextBase::drawTextWorkaround(p, f, pos, text);
868-
#else
869866
p->setFont(f);
870867
p->drawText(pos, text);
871-
#endif
872-
}
873-
874-
//---------------------------------------------------------
875-
// drawTextWorkaround
876-
//---------------------------------------------------------
877-
878-
void TextBase::drawTextWorkaround(Painter* p, Font& f, const PointF& pos, const String& text)
879-
{
880-
double mm = p->worldTransform().m11();
881-
if (!(MScore::pdfPrinting) && (mm < 1.0) && f.bold() && !(f.underline() || f.strike())) {
882-
p->drawTextWorkaround(f, pos, text);
883-
} else {
884-
p->setFont(f);
885-
p->drawText(pos, text);
886-
}
887868
}
888869

889870
//---------------------------------------------------------

src/engraving/dom/textbase.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,6 @@ class TextBase : public EngravingItem
310310
AlignH position() const { return m_position; }
311311
void setPosition(AlignH val) { m_position = val; }
312312

313-
static void drawTextWorkaround(muse::draw::Painter* p, muse::draw::Font& f, const PointF& pos, const String& text);
314-
315313
static String plainToXmlText(const String& s) { return s.toXmlEscaped(); }
316314
void setPlainText(const String& t) { setXmlText(plainToXmlText(t)); }
317315
virtual void setXmlText(const String&);

src/engraving/rendering/score/paintdebugger.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,6 @@ void PaintDebugger::drawText(const RectF& rect, int flags, const String& text)
186186
m_real->drawText(rect, flags, text);
187187
}
188188

189-
void PaintDebugger::drawTextWorkaround(const Font& f, const PointF& pos, const String& text)
190-
{
191-
m_real->drawTextWorkaround(f, pos, text);
192-
}
193-
194189
void PaintDebugger::drawSymbol(const PointF& point, char32_t ucs4Code)
195190
{
196191
m_real->drawSymbol(point, ucs4Code);

src/engraving/rendering/score/paintdebugger.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class PaintDebugger : public muse::draw::IPaintProvider
6868

6969
void drawText(const muse::PointF& point, const muse::String& text) override;
7070
void drawText(const muse::RectF& rect, int flags, const muse::String& text) override;
71-
void drawTextWorkaround(const muse::draw::Font& f, const muse::PointF& pos, const muse::String& text) override;
7271

7372
void drawSymbol(const muse::PointF& point, char32_t ucs4Code) override;
7473

src/engraving/rendering/score/tdraw.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,12 +1844,8 @@ void TDraw::draw(const Harmony* item, Painter* painter, const PaintOptions& opt)
18441844
if (const TextSegment* ts = dynamic_cast<const TextSegment*>(renderItem)) {
18451845
Font f(ts->font());
18461846
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
1847-
#ifndef Q_OS_MACOS
1848-
TextBase::drawTextWorkaround(painter, f, ts->pos(), ts->text());
1849-
#else
18501847
painter->setFont(f);
18511848
painter->drawText(ts->pos(), ts->text());
1852-
#endif
18531849
} else if (const ChordSymbolParen* parenItem = dynamic_cast<const ChordSymbolParen*>(renderItem)) {
18541850
Parenthesis* p = parenItem->parenItem;
18551851
painter->translate(parenItem->pos());

src/engraving/rendering/single/singledraw.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,12 +1753,8 @@ void SingleDraw::draw(const Harmony* item, Painter* painter, const PaintOptions&
17531753
if (const TextSegment* ts = dynamic_cast<const TextSegment*>(renderItem)) {
17541754
Font f(ts->font());
17551755
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
1756-
#ifndef Q_OS_MACOS
1757-
TextBase::drawTextWorkaround(painter, f, ts->pos(), ts->text());
1758-
#else
17591756
painter->setFont(f);
17601757
painter->drawText(ts->pos(), ts->text());
1761-
#endif
17621758
}
17631759
}
17641760
}

src/framework/draw/bufferedpaintprovider.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,6 @@ void BufferedPaintProvider::drawText(const RectF& rect, int flags, const String&
300300
editableData().texts.push_back(DrawText { DrawText::Rect, rect, flags, text });
301301
}
302302

303-
void BufferedPaintProvider::drawTextWorkaround(const Font& f, const PointF& pos, const String& text)
304-
{
305-
setFont(f);
306-
drawText(pos, text);
307-
}
308-
309303
void BufferedPaintProvider::drawSymbol(const PointF& point, char32_t ucs4Code)
310304
{
311305
drawText(point, String::fromUcs4(&ucs4Code, 1));

src/framework/draw/bufferedpaintprovider.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class BufferedPaintProvider : public IPaintProvider
7070

7171
void drawText(const PointF& point, const String& text) override;
7272
void drawText(const RectF& rect, int flags, const String& text) override;
73-
void drawTextWorkaround(const Font& f, const PointF& pos, const String& text) override;
7473

7574
void drawSymbol(const PointF& point, char32_t ucs4Code) override;
7675

src/framework/draw/internal/qpainterprovider.cpp

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -242,67 +242,6 @@ void QPainterProvider::drawText(const RectF& rect, int flags, const String& text
242242
m_painter->drawText(rect.toQRectF(), flags, text);
243243
}
244244

245-
void QPainterProvider::drawTextWorkaround(const Font& f, const PointF& pos, const String& text)
246-
{
247-
m_painter->save();
248-
double mm = m_painter->worldTransform().m11();
249-
double dx = m_painter->worldTransform().dx();
250-
double dy = m_painter->worldTransform().dy();
251-
// diagonal elements will now be changed to 1.0
252-
m_painter->setWorldTransform(QTransform(1.0, 0.0, 0.0, 1.0, dx, dy));
253-
254-
// correction factor for bold text drawing, due to the change of the diagonal elements
255-
double factor = 1.0 / mm;
256-
QFont fnew(f.toQFont(), m_painter->device());
257-
fnew.setPointSizeF(f.pointSizeF() / factor);
258-
QRawFont fRaw = QRawFont::fromFont(fnew);
259-
QTextLayout textLayout(text, f.toQFont(), m_painter->device());
260-
textLayout.beginLayout();
261-
while (true) {
262-
QTextLine line = textLayout.createLine();
263-
if (!line.isValid()) {
264-
break;
265-
}
266-
}
267-
textLayout.endLayout();
268-
// glyphruns with correct positions, but potentially wrong glyphs
269-
// (see bug https://musescore.org/en/node/117191 regarding positions and DPI)
270-
QList<QGlyphRun> glyphruns = textLayout.glyphRuns();
271-
double offset = 0;
272-
// glyphrun drawing has an offset equal to the max ascent of the text fragment
273-
for (int i = 0; i < glyphruns.length(); i++) {
274-
double value = glyphruns.at(i).rawFont().ascent() / factor;
275-
if (value > offset) {
276-
offset = value;
277-
}
278-
}
279-
for (int i = 0; i < glyphruns.length(); i++) {
280-
QVector<QPointF> positions1 = glyphruns.at(i).positions();
281-
QVector<QPointF> positions2;
282-
// calculate the new positions for the scaled geometry
283-
for (int j = 0; j < positions1.length(); j++) {
284-
QPointF newPoint = positions1.at(j) / factor;
285-
positions2.append(newPoint);
286-
}
287-
QGlyphRun glyphrun2 = glyphruns.at(i);
288-
glyphrun2.setPositions(positions2);
289-
// change the glyphs with the correct glyphs
290-
// and account for glyph substitution
291-
if (glyphrun2.rawFont().familyName() != fnew.family()) {
292-
QFont f2(fnew);
293-
f2.setFamily(glyphrun2.rawFont().familyName());
294-
glyphrun2.setRawFont(QRawFont::fromFont(f2));
295-
} else {
296-
glyphrun2.setRawFont(fRaw);
297-
}
298-
m_painter->drawGlyphRun(QPointF(pos.x() / factor, pos.y() / factor - offset), glyphrun2);
299-
positions2.clear();
300-
}
301-
// Restore the QPainter to its former state
302-
m_painter->setWorldTransform(QTransform(mm, 0.0, 0.0, mm, dx, dy));
303-
m_painter->restore();
304-
}
305-
306245
void QPainterProvider::drawSymbol(const PointF& point, char32_t ucs4Code)
307246
{
308247
static QHash<char32_t, QString> cache;

src/framework/draw/internal/qpainterprovider.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ class QPainterProvider : public IPaintProvider
7474

7575
void drawText(const PointF& point, const String& text) override;
7676
void drawText(const RectF& rect, int flags, const String& text) override;
77-
void drawTextWorkaround(const Font& f, const PointF& pos, const String& text) override;
7877

7978
void drawSymbol(const PointF& point, char32_t ucs4Code) override;
8079

0 commit comments

Comments
 (0)