Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in height calculation for RTL text when there is headIndent and… #7289

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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