diff --git a/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m b/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m index 422e089902..30647b6320 100644 --- a/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m +++ b/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m @@ -1379,6 +1379,24 @@ - (NSAttributedString *)attributedStringFromEvent:(MXEvent*)event // Build the attributed string with the right font and color for the event attributedDisplayText = [self renderString:body forEvent:event]; } + + // Issue in height calculation for RTL text when there is headIndent and firstlineheadIndent. + if(attributedDisplayText != nil) { + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", @"(?s).*\\p{Arabic}.*"]; + if ([predicate evaluateWithObject:body]) { + NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithAttributedString:attributedDisplayText]; + + NSMutableParagraphStyle *paragraphStyle = [attributedDisplayText attribute:NSParagraphStyleAttributeName atIndex:0 effectiveRange:nil]; + if (paragraphStyle) { + paragraphStyle.baseWritingDirection = NSWritingDirectionRightToLeft; + paragraphStyle.alignment = NSTextAlignmentJustified; + paragraphStyle.headIndent = 0; + paragraphStyle.firstLineHeadIndent = 0; + [attString addAttributes:@{NSParagraphStyleAttributeName : paragraphStyle} range:NSMakeRange(0, attString.length)]; + attributedDisplayText = [[NSAttributedString alloc] initWithAttributedString:attString]; + } + } + } // Build the full emote string after the body message formatting if ([msgtype isEqualToString:kMXMessageTypeEmote]) diff --git a/changelog.d/7288.bugfix b/changelog.d/7288.bugfix new file mode 100644 index 0000000000..21432ace7c --- /dev/null +++ b/changelog.d/7288.bugfix @@ -0,0 +1 @@ +RTL replies sometimes don't get rendered \ No newline at end of file