From ff570e214c4dbea4f1ea3e368abce406ab9a57dd Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Mon, 6 Feb 2023 18:15:08 +0100 Subject: [PATCH] Properly support OpenDyslexic and HyperLegible Fix #677 --- .../App/Tabs/Settings/DisplaySettingsView.swift | 13 +++++++++++-- .../DesignSystem/Sources/DesignSystem/Theme.swift | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift index c505b6de..d70fde6d 100644 --- a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift @@ -35,12 +35,21 @@ struct DisplaySettingsView: View { .listRowBackground(theme.primaryBackgroundColor) Section("settings.display.section.display") { - Picker("settings.display.font", selection: .init(get: { - userPreferences.chosenFontData != nil ? FontState.custom : FontState.system + Picker("settings.display.font", selection: .init(get: { () -> FontState in + if userPreferences.chosenFont?.fontName == "OpenDyslexic-Regular" { + return FontState.openDyslexic + } else if userPreferences.chosenFont?.fontName == "AtkinsonHyperlegible-Regular" { + return FontState.hyperLegible + } + return userPreferences.chosenFontData != nil ? FontState.custom : FontState.system }, set: { newValue in switch newValue { case .system: userPreferences.chosenFont = nil + case .openDyslexic: + userPreferences.chosenFont = UIFont(name: "OpenDyslexic", size: 1) + case .hyperLegible: + userPreferences.chosenFont = UIFont(name: "Atkinson Hyperlegible", size: 1) case .custom: isFontSelectorPresented = true } diff --git a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift index d8945afe..15021270 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift @@ -11,6 +11,8 @@ public class Theme: ObservableObject { public enum FontState: Int, CaseIterable { case system + case openDyslexic + case hyperLegible case custom @MainActor @@ -18,6 +20,10 @@ public class Theme: ObservableObject { switch self { case .system: return "settings.display.font.system" + case .openDyslexic: + return "Open Dyslexic" + case .hyperLegible: + return "Hyper Legible" case .custom: return "settings.display.font.custom" }