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

When respecting Preferred Font size, only touch font size and keep ot… #928

Merged
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
25 changes: 23 additions & 2 deletions Riot/Modules/MatrixKit/Views/MXKMessageTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,37 @@ - (void)setAttributedText:(NSAttributedString *)attributedText
if (@available(iOS 15.0, *)) {
[self flushPills];
}

// Tchap: set text type to prefered font to rerspect user text size
attributedText = [self respectPreferredFontForAttributedString:attributedText];

[super setAttributedText:attributedText];

if (@available(iOS 15.0, *)) {
// Fixes an iOS 16 issue where attachment are not drawn properly by
// forcing the layoutManager to redraw the glyphs at all NSAttachment positions.
[self vc_invalidateTextAttachmentsDisplay];
}
}

// Tchap: Update font size using preferred font settings but keeping other attributes
- (NSAttributedString *)respectPreferredFontForAttributedString:(NSAttributedString *)sourceString
{
UIFont *preferredFont = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];

// Tchap: set text type to prefered font to rerspect user text size
self.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
NSMutableAttributedString *workString = [sourceString mutableCopy];

[workString beginEditing];
[workString enumerateAttribute:NSFontAttributeName
inRange:NSMakeRange(0, workString.length)
options:0
usingBlock:^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) {
[workString removeAttribute:NSFontAttributeName range:range];
[workString addAttribute:NSFontAttributeName value:[(UIFont *)value fontWithSize:preferredFont.pointSize] range:range];
}];
[workString endEditing];

return workString;
}

- (void)registerPillView:(UIView *)pillView
Expand Down
1 change: 1 addition & 0 deletions changelog.d/927.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Conserver les enrichissements de texte quand on respecte le réglage de la taille de texte de l'utilisateur
Loading