Update font when text format's letter spacing type is changed
The QTextFormat::FontLetterSpacingType property was added outside the span of the FirstFontProperty and LastFontProperty, so the fontDirty flag would not be set when it was changed. There is no binary compatible way to fix this before Qt 6, so for now, we add a special case for it. [ChangeLog][QtGui][Text] Fixed an issue where changing the letter spacing type of a QTextCharFormat would not cause its font to update. Task-number: QTBUG-65345 Change-Id: I5ab53d7f82d529b57edceacfc3fa688c6741cd17 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: C. Boemann <cbo@boemann.dk> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
ca47afbfaa
commit
67b1fa48be
@ -201,8 +201,10 @@ public:
|
||||
inline void insertProperty(qint32 key, const QVariant &value)
|
||||
{
|
||||
hashDirty = true;
|
||||
if (key >= QTextFormat::FirstFontProperty && key <= QTextFormat::LastFontProperty)
|
||||
if ((key >= QTextFormat::FirstFontProperty && key <= QTextFormat::LastFontProperty)
|
||||
|| key == QTextFormat::FontLetterSpacingType) {
|
||||
fontDirty = true;
|
||||
}
|
||||
for (int i = 0; i < props.count(); ++i)
|
||||
if (props.at(i).key == key) {
|
||||
props[i].value = value;
|
||||
@ -216,8 +218,10 @@ public:
|
||||
for (int i = 0; i < props.count(); ++i)
|
||||
if (props.at(i).key == key) {
|
||||
hashDirty = true;
|
||||
if (key >= QTextFormat::FirstFontProperty && key <= QTextFormat::LastFontProperty)
|
||||
if ((key >= QTextFormat::FirstFontProperty && key <= QTextFormat::LastFontProperty)
|
||||
|| key == QTextFormat::FontLetterSpacingType) {
|
||||
fontDirty = true;
|
||||
}
|
||||
props.remove(i);
|
||||
return;
|
||||
}
|
||||
|
@ -283,20 +283,29 @@ void tst_QTextFormat::testLetterSpacing()
|
||||
QCOMPARE(format.hasProperty(QTextFormat::FontLetterSpacingType), false);
|
||||
|
||||
format.setFontLetterSpacingType(QFont::AbsoluteSpacing);
|
||||
QCOMPARE(format.font().letterSpacingType(), QFont::AbsoluteSpacing);
|
||||
|
||||
format.setFontLetterSpacing(10.0);
|
||||
QCOMPARE(format.font().letterSpacing(), 10.0);
|
||||
|
||||
QCOMPARE(format.hasProperty(QTextFormat::FontLetterSpacing), true);
|
||||
QCOMPARE(format.property(QTextFormat::FontLetterSpacing).toDouble(), 10.0);
|
||||
QCOMPARE(format.property(QTextFormat::FontLetterSpacingType).toInt(), int(QFont::AbsoluteSpacing));
|
||||
|
||||
format.setFontLetterSpacingType(QFont::PercentageSpacing);
|
||||
QCOMPARE(format.font().letterSpacingType(), QFont::PercentageSpacing);
|
||||
|
||||
format.setFontLetterSpacing(110.0);
|
||||
QCOMPARE(format.font().letterSpacing(), 110.0);
|
||||
|
||||
QCOMPARE(format.property(QTextFormat::FontLetterSpacing).toDouble(), 110.0);
|
||||
QCOMPARE(format.property(QTextFormat::FontLetterSpacingType).toInt(), int(QFont::PercentageSpacing));
|
||||
|
||||
format.setFontLetterSpacingType(QFont::AbsoluteSpacing);
|
||||
QCOMPARE(format.font().letterSpacingType(), QFont::AbsoluteSpacing);
|
||||
|
||||
format.setFontLetterSpacing(10.0);
|
||||
QCOMPARE(format.font().letterSpacing(), 10.0);
|
||||
|
||||
QCOMPARE(format.property(QTextFormat::FontLetterSpacingType).toInt(), int(QFont::AbsoluteSpacing));
|
||||
QCOMPARE(format.property(QTextFormat::FontLetterSpacing).toDouble(), 10.0);
|
||||
|
Loading…
Reference in New Issue
Block a user