Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
1 change: 1 addition & 0 deletions changelog.d/7288.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RTL replies sometimes don't get rendered