From 42423f36db909fda53aa9f6be1251ee63ce23f97 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 21 Jul 2024 19:46:17 -0700 Subject: [PATCH] Fix Dynamic Type not applying to status content --- Tusker.xcodeproj/project.pbxproj | 2 +- Tusker/HTMLConverter.swift | 10 ++++++++-- Tusker/Screens/Report/ReportStatusView.swift | 1 + Tusker/Views/ConfirmReblogStatusPreviewView.swift | 1 + Tusker/Views/ContentTextView.swift | 1 + .../Views/Profile Header/ProfileFieldValueView.swift | 1 + .../ConversationMainStatusCollectionViewCell.swift | 1 + .../Status/TimelineStatusCollectionViewCell.swift | 1 + 8 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index e57841e3..e4190ff0 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -3260,7 +3260,7 @@ repositoryURL = "https://git.shadowfacts.net/shadowfacts/HTMLStreamer.git"; requirement = { kind = exactVersion; - version = 0.2.5; + version = 0.3.0; }; }; D63CC700290EC0B8000E19DE /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = { diff --git a/Tusker/HTMLConverter.swift b/Tusker/HTMLConverter.swift index 8dcad658..26dd6ccf 100644 --- a/Tusker/HTMLConverter.swift +++ b/Tusker/HTMLConverter.swift @@ -25,8 +25,14 @@ class HTMLConverter { private let converter: AttributedStringConverter - init(font: UIFont, monospaceFont: UIFont, color: UIColor, paragraphStyle: NSParagraphStyle) { - let config = AttributedStringConverterConfiguration(font: font, monospaceFont: monospaceFont, color: color, paragraphStyle: paragraphStyle) + init(font: UIFont, monospaceFont: UIFont, fontMetrics: UIFontMetrics, color: UIColor, paragraphStyle: NSParagraphStyle) { + let config = AttributedStringConverterConfiguration( + font: font, + monospaceFont: monospaceFont, + fontMetrics: fontMetrics, + color: color, + paragraphStyle: paragraphStyle + ) self.converter = AttributedStringConverter(configuration: config) } diff --git a/Tusker/Screens/Report/ReportStatusView.swift b/Tusker/Screens/Report/ReportStatusView.swift index 036ed91c..57d1da82 100644 --- a/Tusker/Screens/Report/ReportStatusView.swift +++ b/Tusker/Screens/Report/ReportStatusView.swift @@ -12,6 +12,7 @@ import SwiftUI private var converter = HTMLConverter( font: .preferredFont(forTextStyle: .body), monospaceFont: UIFontMetrics.default.scaledFont(for: .monospacedSystemFont(ofSize: 17, weight: .regular)), + fontMetrics: .default, color: .label, paragraphStyle: .default ) diff --git a/Tusker/Views/ConfirmReblogStatusPreviewView.swift b/Tusker/Views/ConfirmReblogStatusPreviewView.swift index 2ac6a3c2..96a44c7c 100644 --- a/Tusker/Views/ConfirmReblogStatusPreviewView.swift +++ b/Tusker/Views/ConfirmReblogStatusPreviewView.swift @@ -13,6 +13,7 @@ class ConfirmReblogStatusPreviewView: UIView { private static let htmlConverter = HTMLConverter( font: .preferredFont(forTextStyle: .caption2), monospaceFont: UIFontMetrics(forTextStyle: .caption2).scaledFont(for: .monospacedSystemFont(ofSize: 17, weight: .regular)), + fontMetrics: UIFontMetrics(forTextStyle: .caption2), color: .label, paragraphStyle: .default ) diff --git a/Tusker/Views/ContentTextView.swift b/Tusker/Views/ContentTextView.swift index edf1c04e..f6fc07fc 100644 --- a/Tusker/Views/ContentTextView.swift +++ b/Tusker/Views/ContentTextView.swift @@ -25,6 +25,7 @@ class ContentTextView: LinkTextView, BaseEmojiLabel { private static let defaultBodyHTMLConverter = HTMLConverter( font: .preferredFont(forTextStyle: .body), monospaceFont: UIFontMetrics.default.scaledFont(for: .monospacedSystemFont(ofSize: 17, weight: .regular)), + fontMetrics: .default, color: .label, paragraphStyle: .default ) diff --git a/Tusker/Views/Profile Header/ProfileFieldValueView.swift b/Tusker/Views/Profile Header/ProfileFieldValueView.swift index e15a6285..cfac804b 100644 --- a/Tusker/Views/Profile Header/ProfileFieldValueView.swift +++ b/Tusker/Views/Profile Header/ProfileFieldValueView.swift @@ -21,6 +21,7 @@ class ProfileFieldValueView: UIView { private static let converter = HTMLConverter( font: .preferredFont(forTextStyle: .body), monospaceFont: UIFontMetrics.default.scaledFont(for: .monospacedSystemFont(ofSize: 17, weight: .regular)), + fontMetrics: .default, color: .label, paragraphStyle: .default ) diff --git a/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift b/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift index 8ed333be..a3cc2ee4 100644 --- a/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift @@ -20,6 +20,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status private static let htmlConverter = HTMLConverter( font: ConversationMainStatusCollectionViewCell.contentFont, monospaceFont: ConversationMainStatusCollectionViewCell.monospaceFont, + fontMetrics: .default, color: .label, paragraphStyle: ConversationMainStatusCollectionViewCell.contentParagraphStyle ) diff --git a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift index 3d32d931..2e75d7a6 100644 --- a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift @@ -23,6 +23,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti static let htmlConverter = HTMLConverter( font: TimelineStatusCollectionViewCell.contentFont, monospaceFont: TimelineStatusCollectionViewCell.monospaceFont, + fontMetrics: .default, color: .label, paragraphStyle: TimelineStatusCollectionViewCell.contentParagraphStyle )