Using painter.translate() doesn't help either.
I guess we are supposed to draw text using drawGlyphRun in these situations?
I hope that works, if not I might have to use a patched version of Qt for the program.
Using painter.translate() doesn't help either.
I guess we are supposed to draw text using drawGlyphRun in these situations?
I hope that works, if not I might have to use a patched version of Qt for the program.
Using painter.translate() doesn't help either.
I guess we are supposed to draw text using drawGlyphRun in these situations?
I hope that works, if not I might have to use a patched version of Qt for the program.
Using painter.translate() doesn't help either.
I guess we are supposed to draw text using drawGlyphRun in these situations?
I hope that works, if not I might have to use a patched version of Qt for the program.
Added after 19 minutes:
Nope, drawGlyphRun doesn't work either:
QTextLayout textLayout
(text, painter
->font
(), painter
->device
());
//int leading = fontMetrics.leading();
qreal height = 0;
textLayout.beginLayout();
while (1) {
if (!line.isValid())
break;
line.setLineWidth(50.0f);//lineWidth);
height += 5.4; //leading;
line.
setPosition(QPointF(0, height
));
height += line.height();
}
textLayout.endLayout();
//textLayout.draw(painter, p);
QList<QGlyphRun> glyphs = textLayout.glyphRuns();
QList<QGlyphRun>::iterator i;
for (i = glyphs.begin(); i != glyphs.end(); ++i) {
printf("Drawing something\n");
QGlyphRun glyph = *i;
//glyph.setRawFont(QRawFont::fromFont(painter->font()));
painter->drawGlyphRun(p, (const QGlyphRun &)glyph);
}
}
static void myDrawText(QPainter *painter, QPointF p, QString text){
QTextLayout textLayout(text, painter->font(), painter->device());
//int leading = fontMetrics.leading();
qreal height = 0;
textLayout.beginLayout();
while (1) {
QTextLine line = textLayout.createLine();
if (!line.isValid())
break;
line.setLineWidth(50.0f);//lineWidth);
height += 5.4; //leading;
line.setPosition(QPointF(0, height));
height += line.height();
}
textLayout.endLayout();
//textLayout.draw(painter, p);
QList<QGlyphRun> glyphs = textLayout.glyphRuns();
QList<QGlyphRun>::iterator i;
for (i = glyphs.begin(); i != glyphs.end(); ++i) {
printf("Drawing something\n");
QGlyphRun glyph = *i;
//glyph.setRawFont(QRawFont::fromFont(painter->font()));
painter->drawGlyphRun(p, (const QGlyphRun &)glyph);
}
}
To copy to clipboard, switch view to plain text mode
Guess I'll just rip out some code from the Qt source and insert it into my program.
(they're both GPL)
Added after 43 minutes:
Got it. This works:
QRawFont rawFont = QRawFont::fromFont(painter->font());
QVector<quint32> indexes = rawFont.glyphIndexesForString(text);
painter->save();
printf("num indexes: %d\n",indexes.count());
for(unsigned int i=0; i<indexes.count(); i++){
painter
->translate
(QPointF(p.
x(), p.
y() + i
*0));
painter->fillPath(path,painter->pen().brush());
}
painter->restore();
}
void myDrawText(QPainter *painter, QPointF p, QString text){
QRawFont rawFont = QRawFont::fromFont(painter->font());
QVector<quint32> indexes = rawFont.glyphIndexesForString(text);
painter->save();
printf("num indexes: %d\n",indexes.count());
for(unsigned int i=0; i<indexes.count(); i++){
QPainterPath path = rawFont.pathForGlyph(indexes[i]);
painter->translate(QPointF(p.x(), p.y() + i*0));
painter->fillPath(path,painter->pen().brush());
}
painter->restore();
}
To copy to clipboard, switch view to plain text mode
Bookmarks