From 0c9709621111fc97f8f59461e7572a6635ec7f83 Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Wed, 21 Oct 2020 23:03:48 -0700 Subject: [PATCH] Bold name in reblog label --- Views/Status/StatusView.swift | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Views/Status/StatusView.swift b/Views/Status/StatusView.swift index 2893a15..dd7c256 100644 --- a/Views/Status/StatusView.swift +++ b/Views/Status/StatusView.swift @@ -336,10 +336,20 @@ private extension StatusView { let metaText = String.localizedStringWithFormat( NSLocalizedString("status.reblogged-by", comment: ""), viewModel.rebloggedByDisplayName) - let mutableMetaText = NSMutableAttributedString(string: metaText) - mutableMetaText.insert(emoji: viewModel.rebloggedByDisplayNameEmoji, view: infoLabel) - mutableMetaText.resizeAttachments(toLineHeight: infoLabel.font.lineHeight) - infoLabel.attributedText = mutableMetaText + let mutableInfoText = NSMutableAttributedString(string: metaText) + + let range = (mutableInfoText.string as NSString).range(of: viewModel.rebloggedByDisplayName) + + if range.location != NSNotFound, + let boldFontDescriptor = infoLabel.font.fontDescriptor.withSymbolicTraits([.traitBold]) { + let boldFont = UIFont(descriptor: boldFontDescriptor, size: infoLabel.font.pointSize) + + mutableInfoText.setAttributes([NSAttributedString.Key.font: boldFont], range: range) + } + + mutableInfoText.insert(emoji: viewModel.rebloggedByDisplayNameEmoji, view: infoLabel) + mutableInfoText.resizeAttachments(toLineHeight: infoLabel.font.lineHeight) + infoLabel.attributedText = mutableInfoText infoIcon.image = UIImage( systemName: "arrow.2.squarepath", withConfiguration: UIImage.SymbolConfiguration(scale: .small))