From 92425c7a1ed3bd7aabd7568a618b259f0e8d34b0 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 3 Sep 2021 20:09:47 +0300 Subject: [PATCH] Fixed space of action animation in middle text for different scales. --- .../history/view/history_view_send_action.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_send_action.cpp b/Telegram/SourceFiles/history/view/history_view_send_action.cpp index 6ad1fcc28..e8c0015ed 100644 --- a/Telegram/SourceFiles/history/view/history_view_send_action.cpp +++ b/Telegram/SourceFiles/history/view/history_view_send_action.cpp @@ -296,15 +296,17 @@ bool SendActionPainter::updateNeedsAnimating(crl::time now, bool force) { const auto index = newTypingString.size() - lang.rightIndexChoosingStickerReplacement( isNamed); - animationLeft = _st.font->width( - newTypingString, - 0, - index); + animationLeft = Ui::Text::String( + _st, + newTypingString.mid(0, index)).maxWidth(); if (!_spacesCount) { - _spacesCount = std::ceil( + // We have to use QFontMetricsF instead of + // FontData::spacew for more precise calculation. + const auto mf = QFontMetricsF(_st.font->f); + _spacesCount = std::round( _sendActionAnimation.width() - / _st.font->spacew); + / mf.horizontalAdvance(' ')); } newTypingString = newTypingString.replace( index,