Properly support OpenDyslexic and HyperLegible Fix #677

This commit is contained in:
Thomas Ricouard 2023-02-06 18:15:08 +01:00
parent 3c9b0af3dd
commit ff570e214c
2 changed files with 17 additions and 2 deletions

View File

@ -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
}

View File

@ -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"
}