Skip to content

Commit

Permalink
Merge pull request #928 from tchapgouv/927-conserver-les-enrichisseme…
Browse files Browse the repository at this point in the history
…nts-de-texte-quand-on-respecte-le-reglage-de-la-taille-de-texte-de-lutilisateur

When respecting Preferred Font size, only touch font size and keep ot…
  • Loading branch information
NicolasBuquet authored Nov 21, 2023
2 parents 3fbed20 + 38c26ea commit 4d16a33
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
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

0 comments on commit 4d16a33

Please sign in to comment.