From 53f364b23240571c9d73acace774caa4c220fd5d Mon Sep 17 00:00:00 2001 From: Gareth Simpson Date: Tue, 21 Feb 2023 06:08:32 +0000 Subject: [PATCH] Font picker consistency (#960) * Put SF Rounded into the popup menu with Hyperlegible & Dislexia * Remove SF Rounded Toggle --- .../Tabs/Settings/DisplaySettingsView.swift | 7 +++--- .../Localization/ca.lproj/Localizable.strings | 1 - .../Localization/de.lproj/Localizable.strings | 1 - .../en-GB.lproj/Localizable.strings | 1 - .../Localization/en.lproj/Localizable.strings | 1 - .../Localization/es.lproj/Localizable.strings | 1 - .../Localization/eu.lproj/Localizable.strings | 1 - .../Localization/fr.lproj/Localizable.strings | 1 - .../Localization/it.lproj/Localizable.strings | 1 - .../Localization/ja.lproj/Localizable.strings | 1 - .../Localization/ko.lproj/Localizable.strings | 1 - .../Localization/nb.lproj/Localizable.strings | 1 - .../Localization/nl.lproj/Localizable.strings | 1 - .../Localization/pl.lproj/Localizable.strings | 1 - .../pt-BR.lproj/Localizable.strings | 1 - .../Localization/tr.lproj/Localizable.strings | 1 - .../zh-Hans.lproj/Localizable.strings | 1 - .../Sources/DesignSystem/Font.swift | 22 ++++++++++++++++--- .../Sources/DesignSystem/Theme.swift | 4 +++- .../Env/Sources/Env/UserPreferences.swift | 5 ++++- 20 files changed, 30 insertions(+), 24 deletions(-) diff --git a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift index e1158852..c7767965 100644 --- a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift @@ -48,6 +48,8 @@ struct DisplaySettingsView: View { return FontState.openDyslexic } else if theme.chosenFont?.fontName == "AtkinsonHyperlegible-Regular" { return FontState.hyperLegible + } else if theme.chosenFont?.fontName == ".AppleSystemUIFontRounded-Regular" { + return FontState.SFRounded } return theme.chosenFontData != nil ? FontState.custom : FontState.system }, set: { newValue in @@ -58,6 +60,8 @@ struct DisplaySettingsView: View { theme.chosenFont = UIFont(name: "OpenDyslexic", size: 1) case .hyperLegible: theme.chosenFont = UIFont(name: "Atkinson Hyperlegible", size: 1) + case.SFRounded: + theme.chosenFont = UIFont.systemFont(ofSize: 1).rounded() case .custom: isFontSelectorPresented = true } @@ -68,9 +72,6 @@ struct DisplaySettingsView: View { } .navigationDestination(isPresented: $isFontSelectorPresented, destination: { FontPicker() }) - Toggle("settings.display.font.rounded", isOn: $theme.useSFRoundedFont) - .disabled(theme.chosenFont != nil) - VStack { Slider(value: $theme.fontSizeScale, in: 0.5 ... 1.5, step: 0.1) Text("settings.display.font.scaling-\(String(format: "%.1f", theme.fontSizeScale))") diff --git a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings index 79b72212..771adff4 100644 --- a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings @@ -186,7 +186,6 @@ "settings.swipeactions.status.icon-style" = "Icon style"; "settings.display.section.font" = "Font"; -"settings.display.font.rounded" = "Use SF Rounded"; // MARK: Tabs "tab.explore" = "Exploreu"; diff --git a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings index 0e5576f5..37c45861 100644 --- a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings @@ -184,7 +184,6 @@ "settings.swipeactions.status.icon-style" = "Symbolstil"; "settings.display.section.font" = "Schriftart"; -"settings.display.font.rounded" = "SF Rounded verwenden"; "enum.expand-media.show" = "Alle zeigen"; "enum.expand-media.hide" = "Alle ausblenden"; diff --git a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings index 5383b624..84f80d89 100644 --- a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings @@ -190,7 +190,6 @@ "settings.swipeactions.status.icon-style" = "Icon style"; "settings.display.section.font" = "Font"; -"settings.display.font.rounded" = "Use SF Rounded"; // MARK: Tabs "tab.explore" = "Explore"; diff --git a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings index b05d3bf1..3f81b54a 100644 --- a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings @@ -188,7 +188,6 @@ "settings.swipeactions.status.icon-style" = "Icon style"; "settings.display.section.font" = "Font"; -"settings.display.font.rounded" = "Use SF Rounded"; // MARK: Tabs "tab.explore" = "Explore"; diff --git a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings index f494cdb2..ac6e28e6 100644 --- a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings @@ -184,7 +184,6 @@ "settings.swipeactions.status.icon-style" = "Estilo de icono"; "settings.display.section.font" = "Font"; -"settings.display.font.rounded" = "Use SF Rounded"; "enum.expand-media.show" = "Siempre"; "enum.expand-media.hide" = "Nunca"; diff --git a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings index db2e9c9c..0550548a 100644 --- a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings @@ -184,7 +184,6 @@ "settings.swipeactions.status.icon-style" = "Ikonoen itxura"; "settings.display.section.font" = "Font"; -"settings.display.font.rounded" = "Use SF Rounded"; "enum.expand-media.show" = "Erakutsi guztia"; "enum.expand-media.hide" = "Ezkutatu guztia"; diff --git a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings index 09d71432..fc8b0191 100644 --- a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings @@ -187,7 +187,6 @@ "settings.swipeactions.status.icon-style" = "Style de l'icône"; "settings.display.section.font" = "Police"; -"settings.display.font.rounded" = "Utiliser SF Rounded"; // MARK: Tabs "tab.explore" = "Explorer"; diff --git a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings index 81d3ac21..c2dbfc24 100644 --- a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings @@ -187,7 +187,6 @@ "settings.swipeactions.status.icon-style" = "Stile delle icone"; "settings.display.section.font" = "Font"; -"settings.display.font.rounded" = "Use SF Rounded"; // MARK: Tabs "tab.explore" = "Esplora"; diff --git a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings index 54d018ba..5e1a2f30 100644 --- a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings @@ -187,7 +187,6 @@ "settings.swipeactions.status.icon-style" = "アイコンスタイル"; "settings.display.section.font" = "フォント"; -"settings.display.font.rounded" = "角丸SFを使用する"; // MARK: Tabs "tab.explore" = "探索"; diff --git a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings index 332a329a..965b57a7 100644 --- a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings @@ -187,7 +187,6 @@ "settings.swipeactions.status.icon-style" = "아이콘 모양"; "settings.display.section.font" = "글꼴"; -"settings.display.font.rounded" = "SF Rounded 글꼴 사용"; // MARK: Tabs "tab.explore" = "둘러보기"; diff --git a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings index 24358b94..dfce0c26 100644 --- a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings @@ -187,7 +187,6 @@ "settings.swipeactions.status.icon-style" = "Icon style"; "settings.display.section.font" = "Font"; -"settings.display.font.rounded" = "Use SF Rounded"; // MARK: Tabs "tab.explore" = "Utforsk"; diff --git a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings index 1a3c3906..e8caea0a 100644 --- a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings @@ -184,7 +184,6 @@ "settings.swipeactions.status.icon-style" = "Symboolstijl"; "settings.display.section.font" = "Lettertype"; -"settings.display.font.rounded" = "Gebruik SF Rounded"; // MARK: Tabs "tab.explore" = "Ontdekken"; diff --git a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings index aa6dae9a..79ca51b9 100644 --- a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings @@ -187,7 +187,6 @@ "settings.swipeactions.status.icon-style" = "Styl ikony"; "settings.display.section.font" = "Czcionka"; -"settings.display.font.rounded" = "Użyj czcionkę SF Rounded"; // MARK: Tabs "tab.explore" = "Odkrywaj"; diff --git a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings index 3b133210..4ad3d070 100644 --- a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings @@ -187,7 +187,6 @@ "settings.swipeactions.status.icon-style" = "Icon style"; "settings.display.section.font" = "Font"; -"settings.display.font.rounded" = "Use SF Rounded"; // MARK: Tabs "tab.explore" = "Explorar"; diff --git a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings index f2593249..0e8dc7aa 100644 --- a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings @@ -187,7 +187,6 @@ "settings.swipeactions.status.icon-style" = "Icon style"; "settings.display.section.font" = "Font"; -"settings.display.font.rounded" = "Use SF Rounded"; // MARK: Tabs "tab.explore" = "Keşfet"; diff --git a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings index 69b40e51..98f6b637 100644 --- a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings @@ -185,7 +185,6 @@ "settings.swipeactions.status.icon-style" = "图标样式"; "settings.display.section.font" = "字体"; -"settings.display.font.rounded" = "使用 SF Rounded 字体"; // MARK: Tabs "tab.explore" = "探索"; diff --git a/Packages/DesignSystem/Sources/DesignSystem/Font.swift b/Packages/DesignSystem/Sources/DesignSystem/Font.swift index 742014a3..a8fcf474 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Font.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Font.swift @@ -15,18 +15,23 @@ public extension Font { private static let onMac = ProcessInfo.processInfo.isiOSAppOnMac private static func customFont(size: CGFloat, relativeTo textStyle: TextStyle) -> Font { + if let chosenFont = Theme.shared.chosenFont { - return .custom(chosenFont.fontName, size: size, relativeTo: textStyle) + if chosenFont.fontName == ".AppleSystemUIFontRounded-Regular" { + return .system(size: size, design: .rounded) + } + else { + return .custom(chosenFont.fontName, size: size, relativeTo: textStyle) + } } - return .system(size: size, design: Theme.shared.useSFRoundedFont ? .rounded : .default) + return .system(size: size, design: .default) } private static func customUIFont(size: CGFloat) -> UIFont { if let chosenFont = Theme.shared.chosenFont { return chosenFont.withSize(size) } - return .systemFont(ofSize: size) } @@ -66,3 +71,14 @@ public extension Font { customFont(size: userScaledFontSize(baseSize: caption), relativeTo: .caption) } } + + + +extension UIFont { + public func rounded() -> UIFont { + guard let descriptor = fontDescriptor.withDesign(.rounded) else { + return self + } + return UIFont(descriptor: descriptor, size: pointSize) + } +} diff --git a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift index 1ca3a78b..30e8f0f5 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift @@ -14,6 +14,7 @@ public class Theme: ObservableObject { case system case openDyslexic case hyperLegible + case SFRounded case custom @MainActor @@ -25,6 +26,8 @@ public class Theme: ObservableObject { return "Open Dyslexic" case .hyperLegible: return "Hyper Legible" + case .SFRounded: + return "SF Rounded" case .custom: return "settings.display.font.custom" } @@ -118,7 +121,6 @@ public class Theme: ObservableObject { @AppStorage(ThemeKey.displayFullUsernameTimeline.rawValue) public var displayFullUsername: Bool = true @AppStorage("font_size_scale") public var fontSizeScale: Double = 1 @AppStorage("chosen_font") public private(set) var chosenFontData: Data? - @AppStorage("font_use_sf_rounded") public var useSFRoundedFont = false @Published public var avatarPosition: AvatarPosition = .top @Published public var avatarShape: AvatarShape = .rounded diff --git a/Packages/Env/Sources/Env/UserPreferences.swift b/Packages/Env/Sources/Env/UserPreferences.swift index 91a8d730..cf698df1 100644 --- a/Packages/Env/Sources/Env/UserPreferences.swift +++ b/Packages/Env/Sources/Env/UserPreferences.swift @@ -108,7 +108,7 @@ public class UserPreferences: ObservableObject { } return count } - + @Published public var serverPreferences: ServerPreferences? private init() {} @@ -134,3 +134,6 @@ public class UserPreferences: ObservableObject { recentlyUsedLanguages = Array(copy.prefix(3)) } } + + +