Apply specialData font capitalization to non-rawFont text

We were not using the capitalization details from specialData in the
regular path of QTextEngine::itemize() causing it to be ignored.

Pick-to: 6.1 5.15
Fixes: QTBUG-90840
Change-Id: I7bb71fad4009f6d0685905a946c36ac1d24d8d3c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2021-05-06 13:47:06 +02:00
parent b24da5449b
commit 5fa80f6cd7

View File

@ -1994,20 +1994,30 @@ void QTextEngine::itemize() const
QTextDocumentPrivate::FragmentIterator end = p->find(block.position() + block.length() - 1); // -1 to omit the block separator char
int format = it.value()->format;
int preeditPosition = s ? s->preeditPosition : INT_MAX;
int prevPosition = 0;
int position = prevPosition;
while (1) {
const QTextFragmentData * const frag = it.value();
if (it == end || format != frag->format) {
if (s && position >= s->preeditPosition) {
if (s && position >= preeditPosition) {
position += s->preeditText.length();
s = nullptr;
preeditPosition = INT_MAX;
}
Q_ASSERT(position <= length);
QFont::Capitalization capitalization =
formatCollection()->charFormat(format).hasProperty(QTextFormat::FontCapitalization)
? formatCollection()->charFormat(format).fontCapitalization()
: formatCollection()->defaultFont().capitalization();
if (s) {
for (const auto &range : qAsConst(s->formats)) {
if (range.start >= prevPosition && range.start < position && range.format.hasProperty(QTextFormat::FontCapitalization)) {
itemizer.generate(prevPosition, range.start - prevPosition, capitalization);
itemizer.generate(range.start, range.length, range.format.fontCapitalization());
prevPosition = range.start + range.length;
}
}
}
itemizer.generate(prevPosition, position - prevPosition, capitalization);
if (it == end) {
if (position < length)