Show nbsps as a degree symbol to differeniate from normal spaces
When using QTextOption::ShowTabsAndSpaces then spaces and nbsps would appear the same. So since using the degree symbol to illustrate nbsps is an accepted standard, we use that and spaces are illustrated as before. [ChangeLog][QtGui] Display non-breaking spaces as a degree symbol when QTextOption::ShowTabsAndSpaces is used. Task-number: QTBUG-57479 Change-Id: I20c72c9e1640457c034b87587a8975cb73228803 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
f816f2e3c9
commit
ca58c62727
@ -2064,7 +2064,7 @@ void QTextEngine::itemize() const
|
||||
case QChar::Space:
|
||||
case QChar::Nbsp:
|
||||
if (option.flags() & QTextOption::ShowTabsAndSpaces) {
|
||||
analysis->flags = QScriptAnalysis::Space;
|
||||
analysis->flags = (*uc == QChar::Space) ? QScriptAnalysis::Space : QScriptAnalysis::Nbsp;
|
||||
analysis->bidiLevel = bidi.baseLevel;
|
||||
break;
|
||||
}
|
||||
|
@ -143,9 +143,10 @@ struct Q_AUTOTEST_EXPORT QScriptAnalysis
|
||||
LineOrParagraphSeparator = 4,
|
||||
Space = 5,
|
||||
SpaceTabOrObject = Space,
|
||||
Tab = 6,
|
||||
Nbsp = 6,
|
||||
Tab = 7,
|
||||
TabOrObject = Tab,
|
||||
Object = 7
|
||||
Object = 8
|
||||
};
|
||||
enum BidiFlags {
|
||||
BidiBN = 1,
|
||||
|
@ -2610,12 +2610,13 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
|
||||
QPainterPrivate::get(p)->drawTextItem(pos, gf, eng);
|
||||
}
|
||||
|
||||
if (si.analysis.flags == QScriptAnalysis::Space
|
||||
if ((si.analysis.flags == QScriptAnalysis::Space
|
||||
|| si.analysis.flags == QScriptAnalysis::Nbsp)
|
||||
&& (eng->option.flags() & QTextOption::ShowTabsAndSpaces)) {
|
||||
QBrush c = format.foreground();
|
||||
if (c.style() != Qt::NoBrush)
|
||||
p->setPen(c.color());
|
||||
QChar visualSpace((ushort)0xb7);
|
||||
QChar visualSpace(si.analysis.flags == QScriptAnalysis::Space ? (ushort)0xb7 : (ushort)0xb0);
|
||||
p->drawText(QPointF(iterator.x.toReal(), itemBaseLine.toReal()), visualSpace);
|
||||
p->setPen(pen);
|
||||
}
|
||||
|
@ -307,7 +307,8 @@ QList<QTextOption::Tab> QTextOption::tabs() const
|
||||
\value IncludeTrailingSpaces When this option is set, QTextLine::naturalTextWidth() and naturalTextRect() will
|
||||
return a value that includes the width of trailing spaces in the text; otherwise
|
||||
this width is excluded.
|
||||
\value ShowTabsAndSpaces Visualize spaces with little dots, and tabs with little arrows.
|
||||
\value ShowTabsAndSpaces Visualize spaces with little dots, and tabs with little arrows. Non-breaking spaces are
|
||||
shown differently to breaking spaces.
|
||||
\value ShowLineAndParagraphSeparators Visualize line and paragraph separators with appropriate symbol characters.
|
||||
\value ShowDocumentTerminator Visualize the end of the document with a section sign. This enum value was added
|
||||
in Qt 5.7.
|
||||
|
Loading…
Reference in New Issue
Block a user