mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
optimize QPainterPath::addText()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1604419297
commit
3edd93fac4
1 changed files with 16 additions and 13 deletions
|
@ -1088,7 +1088,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
|
||||||
ensureData();
|
ensureData();
|
||||||
detach();
|
detach();
|
||||||
|
|
||||||
// qDebug() << Q_FUNC_INFO << point << f << text << direction;
|
// qDebug() << Q_FUNC_INFO << point << f << text;
|
||||||
|
|
||||||
static const QTextEngine::ShaperFlags shaperflags = 0;
|
static const QTextEngine::ShaperFlags shaperflags = 0;
|
||||||
|
|
||||||
|
@ -1097,6 +1097,8 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
|
||||||
if (scriptdetection) {
|
if (scriptdetection) {
|
||||||
qreal xoffset = 0.0;
|
qreal xoffset = 0.0;
|
||||||
QUnicodeTables::Script inheritedscript = QUnicodeTables::Common;
|
QUnicodeTables::Script inheritedscript = QUnicodeTables::Common;
|
||||||
|
QGlyphLayoutArray<2> glyphs;
|
||||||
|
|
||||||
for (int i = 0; i < text.size(); i++) {
|
for (int i = 0; i < text.size(); i++) {
|
||||||
int nglyphs = 1;
|
int nglyphs = 1;
|
||||||
QChar textchars[2] = { text.at(i), 0 };
|
QChar textchars[2] = { text.at(i), 0 };
|
||||||
|
@ -1135,7 +1137,6 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QGlyphLayoutArray<2> glyphs;
|
|
||||||
engine->stringToCMap(textchars, nglyphs, &glyphs, &nglyphs, shaperflags);
|
engine->stringToCMap(textchars, nglyphs, &glyphs, &nglyphs, shaperflags);
|
||||||
engine->addOutlineToPath(point.x() + xoffset, point.y(), glyphs, this);
|
engine->addOutlineToPath(point.x() + xoffset, point.y(), glyphs, this);
|
||||||
|
|
||||||
|
@ -1158,19 +1159,21 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
|
||||||
engine->addOutlineToPath(point.x(), point.y(), glyphs, this);
|
engine->addOutlineToPath(point.x(), point.y(), glyphs, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QFontMetricsF fontmetrics(f);
|
if (f.underline() || f.overline() || f.strikeOut()) {
|
||||||
const qreal linewidth = fontmetrics.lineWidth();
|
const QFontMetricsF fontmetrics(f);
|
||||||
const qreal textwidth = (fontmetrics.width('x') * text.size());
|
const qreal linewidth = fontmetrics.lineWidth();
|
||||||
|
const qreal textwidth = (fontmetrics.width('x') * text.size());
|
||||||
#if 0
|
#if 0
|
||||||
if (f.underline()) {
|
if (f.underline()) {
|
||||||
addRect(point.x(), point.y() + fontmetrics.underlinePos(), textwidth, linewidth);
|
addRect(point.x(), point.y() + fontmetrics.underlinePos(), textwidth, linewidth);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (f.overline()) {
|
if (f.overline()) {
|
||||||
addRect(point.x(), point.y() - fontmetrics.overlinePos(), textwidth, linewidth);
|
addRect(point.x(), point.y() - fontmetrics.overlinePos(), textwidth, linewidth);
|
||||||
}
|
}
|
||||||
if (f.strikeOut()) {
|
if (f.strikeOut()) {
|
||||||
addRect(point.x(), point.y() - fontmetrics.strikeOutPos(), textwidth, linewidth);
|
addRect(point.x(), point.y() - fontmetrics.strikeOutPos(), textwidth, linewidth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue