From 7e324283b4e4a6974f36144925c106c5ae10075c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fauconnier?= Date: Mon, 15 Jul 2019 11:03:11 +0200 Subject: [PATCH] fixed an issue where font family styles of a block with the same font family were lost when changing size --- src/domain/UBGraphicsTextItemDelegate.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/domain/UBGraphicsTextItemDelegate.cpp b/src/domain/UBGraphicsTextItemDelegate.cpp index 73e3f107..a2f711fb 100644 --- a/src/domain/UBGraphicsTextItemDelegate.cpp +++ b/src/domain/UBGraphicsTextItemDelegate.cpp @@ -630,7 +630,15 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode cha nextCharBrush = cursor.charFormat().foreground(); iNextPointSize = nextCharFont.pointSize(); - if ((iPointSize != iNextPointSize)||(iCursorPos+iBlockLen >= endPos)||(0 != curFont.family().compare(nextCharFont.family()))||(curBrush != nextCharBrush)){ + if ( + (iPointSize != iNextPointSize) + || (iCursorPos+iBlockLen >= endPos) + || (curFont.family().compare(nextCharFont.family()) != 0) + || (curFont.italic() != nextCharFont.italic()) + || (curFont.bold() != nextCharFont.bold()) + || (curFont.underline() != nextCharFont.underline()) + || (curBrush != nextCharBrush)) + { bEndofTheSameBlock = true; break; } @@ -647,7 +655,7 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode cha textFormat.setFont(tmpFont); textFormat.setForeground(curBrush); cursor.setPosition (iCursorPos+iBlockLen, QTextCursor::KeepAnchor); - cursor.setCharFormat(textFormat); + cursor.mergeCharFormat(textFormat); iCursorPos += iBlockLen; cursor.setPosition (iCursorPos, QTextCursor::MoveAnchor);