@@ -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-
306245void QPainterProvider::drawSymbol (const PointF& point, char32_t ucs4Code)
307246{
308247 static QHash<char32_t , QString> cache;
0 commit comments