Font picker consistency (#960)

* Put SF Rounded into the popup menu with Hyperlegible & Dislexia

* Remove SF Rounded Toggle
This commit is contained in:
Gareth Simpson 2023-02-21 06:08:32 +00:00 committed by GitHub
parent 5057659cfc
commit 53f364b232
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 30 additions and 24 deletions

View file

@ -48,6 +48,8 @@ struct DisplaySettingsView: View {
return FontState.openDyslexic return FontState.openDyslexic
} else if theme.chosenFont?.fontName == "AtkinsonHyperlegible-Regular" { } else if theme.chosenFont?.fontName == "AtkinsonHyperlegible-Regular" {
return FontState.hyperLegible return FontState.hyperLegible
} else if theme.chosenFont?.fontName == ".AppleSystemUIFontRounded-Regular" {
return FontState.SFRounded
} }
return theme.chosenFontData != nil ? FontState.custom : FontState.system return theme.chosenFontData != nil ? FontState.custom : FontState.system
}, set: { newValue in }, set: { newValue in
@ -58,6 +60,8 @@ struct DisplaySettingsView: View {
theme.chosenFont = UIFont(name: "OpenDyslexic", size: 1) theme.chosenFont = UIFont(name: "OpenDyslexic", size: 1)
case .hyperLegible: case .hyperLegible:
theme.chosenFont = UIFont(name: "Atkinson Hyperlegible", size: 1) theme.chosenFont = UIFont(name: "Atkinson Hyperlegible", size: 1)
case.SFRounded:
theme.chosenFont = UIFont.systemFont(ofSize: 1).rounded()
case .custom: case .custom:
isFontSelectorPresented = true isFontSelectorPresented = true
} }
@ -68,9 +72,6 @@ struct DisplaySettingsView: View {
} }
.navigationDestination(isPresented: $isFontSelectorPresented, destination: { FontPicker() }) .navigationDestination(isPresented: $isFontSelectorPresented, destination: { FontPicker() })
Toggle("settings.display.font.rounded", isOn: $theme.useSFRoundedFont)
.disabled(theme.chosenFont != nil)
VStack { VStack {
Slider(value: $theme.fontSizeScale, in: 0.5 ... 1.5, step: 0.1) Slider(value: $theme.fontSizeScale, in: 0.5 ... 1.5, step: 0.1)
Text("settings.display.font.scaling-\(String(format: "%.1f", theme.fontSizeScale))") Text("settings.display.font.scaling-\(String(format: "%.1f", theme.fontSizeScale))")

View file

@ -186,7 +186,6 @@
"settings.swipeactions.status.icon-style" = "Icon style"; "settings.swipeactions.status.icon-style" = "Icon style";
"settings.display.section.font" = "Font"; "settings.display.section.font" = "Font";
"settings.display.font.rounded" = "Use SF Rounded";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "Exploreu"; "tab.explore" = "Exploreu";

View file

@ -184,7 +184,6 @@
"settings.swipeactions.status.icon-style" = "Symbolstil"; "settings.swipeactions.status.icon-style" = "Symbolstil";
"settings.display.section.font" = "Schriftart"; "settings.display.section.font" = "Schriftart";
"settings.display.font.rounded" = "SF Rounded verwenden";
"enum.expand-media.show" = "Alle zeigen"; "enum.expand-media.show" = "Alle zeigen";
"enum.expand-media.hide" = "Alle ausblenden"; "enum.expand-media.hide" = "Alle ausblenden";

View file

@ -190,7 +190,6 @@
"settings.swipeactions.status.icon-style" = "Icon style"; "settings.swipeactions.status.icon-style" = "Icon style";
"settings.display.section.font" = "Font"; "settings.display.section.font" = "Font";
"settings.display.font.rounded" = "Use SF Rounded";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "Explore"; "tab.explore" = "Explore";

View file

@ -188,7 +188,6 @@
"settings.swipeactions.status.icon-style" = "Icon style"; "settings.swipeactions.status.icon-style" = "Icon style";
"settings.display.section.font" = "Font"; "settings.display.section.font" = "Font";
"settings.display.font.rounded" = "Use SF Rounded";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "Explore"; "tab.explore" = "Explore";

View file

@ -184,7 +184,6 @@
"settings.swipeactions.status.icon-style" = "Estilo de icono"; "settings.swipeactions.status.icon-style" = "Estilo de icono";
"settings.display.section.font" = "Font"; "settings.display.section.font" = "Font";
"settings.display.font.rounded" = "Use SF Rounded";
"enum.expand-media.show" = "Siempre"; "enum.expand-media.show" = "Siempre";
"enum.expand-media.hide" = "Nunca"; "enum.expand-media.hide" = "Nunca";

View file

@ -184,7 +184,6 @@
"settings.swipeactions.status.icon-style" = "Ikonoen itxura"; "settings.swipeactions.status.icon-style" = "Ikonoen itxura";
"settings.display.section.font" = "Font"; "settings.display.section.font" = "Font";
"settings.display.font.rounded" = "Use SF Rounded";
"enum.expand-media.show" = "Erakutsi guztia"; "enum.expand-media.show" = "Erakutsi guztia";
"enum.expand-media.hide" = "Ezkutatu guztia"; "enum.expand-media.hide" = "Ezkutatu guztia";

View file

@ -187,7 +187,6 @@
"settings.swipeactions.status.icon-style" = "Style de l'icône"; "settings.swipeactions.status.icon-style" = "Style de l'icône";
"settings.display.section.font" = "Police"; "settings.display.section.font" = "Police";
"settings.display.font.rounded" = "Utiliser SF Rounded";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "Explorer"; "tab.explore" = "Explorer";

View file

@ -187,7 +187,6 @@
"settings.swipeactions.status.icon-style" = "Stile delle icone"; "settings.swipeactions.status.icon-style" = "Stile delle icone";
"settings.display.section.font" = "Font"; "settings.display.section.font" = "Font";
"settings.display.font.rounded" = "Use SF Rounded";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "Esplora"; "tab.explore" = "Esplora";

View file

@ -187,7 +187,6 @@
"settings.swipeactions.status.icon-style" = "アイコンスタイル"; "settings.swipeactions.status.icon-style" = "アイコンスタイル";
"settings.display.section.font" = "フォント"; "settings.display.section.font" = "フォント";
"settings.display.font.rounded" = "角丸SFを使用する";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "探索"; "tab.explore" = "探索";

View file

@ -187,7 +187,6 @@
"settings.swipeactions.status.icon-style" = "아이콘 모양"; "settings.swipeactions.status.icon-style" = "아이콘 모양";
"settings.display.section.font" = "글꼴"; "settings.display.section.font" = "글꼴";
"settings.display.font.rounded" = "SF Rounded 글꼴 사용";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "둘러보기"; "tab.explore" = "둘러보기";

View file

@ -187,7 +187,6 @@
"settings.swipeactions.status.icon-style" = "Icon style"; "settings.swipeactions.status.icon-style" = "Icon style";
"settings.display.section.font" = "Font"; "settings.display.section.font" = "Font";
"settings.display.font.rounded" = "Use SF Rounded";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "Utforsk"; "tab.explore" = "Utforsk";

View file

@ -184,7 +184,6 @@
"settings.swipeactions.status.icon-style" = "Symboolstijl"; "settings.swipeactions.status.icon-style" = "Symboolstijl";
"settings.display.section.font" = "Lettertype"; "settings.display.section.font" = "Lettertype";
"settings.display.font.rounded" = "Gebruik SF Rounded";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "Ontdekken"; "tab.explore" = "Ontdekken";

View file

@ -187,7 +187,6 @@
"settings.swipeactions.status.icon-style" = "Styl ikony"; "settings.swipeactions.status.icon-style" = "Styl ikony";
"settings.display.section.font" = "Czcionka"; "settings.display.section.font" = "Czcionka";
"settings.display.font.rounded" = "Użyj czcionkę SF Rounded";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "Odkrywaj"; "tab.explore" = "Odkrywaj";

View file

@ -187,7 +187,6 @@
"settings.swipeactions.status.icon-style" = "Icon style"; "settings.swipeactions.status.icon-style" = "Icon style";
"settings.display.section.font" = "Font"; "settings.display.section.font" = "Font";
"settings.display.font.rounded" = "Use SF Rounded";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "Explorar"; "tab.explore" = "Explorar";

View file

@ -187,7 +187,6 @@
"settings.swipeactions.status.icon-style" = "Icon style"; "settings.swipeactions.status.icon-style" = "Icon style";
"settings.display.section.font" = "Font"; "settings.display.section.font" = "Font";
"settings.display.font.rounded" = "Use SF Rounded";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "Keşfet"; "tab.explore" = "Keşfet";

View file

@ -185,7 +185,6 @@
"settings.swipeactions.status.icon-style" = "图标样式"; "settings.swipeactions.status.icon-style" = "图标样式";
"settings.display.section.font" = "字体"; "settings.display.section.font" = "字体";
"settings.display.font.rounded" = "使用 SF Rounded 字体";
// MARK: Tabs // MARK: Tabs
"tab.explore" = "探索"; "tab.explore" = "探索";

View file

@ -15,18 +15,23 @@ public extension Font {
private static let onMac = ProcessInfo.processInfo.isiOSAppOnMac private static let onMac = ProcessInfo.processInfo.isiOSAppOnMac
private static func customFont(size: CGFloat, relativeTo textStyle: TextStyle) -> Font { private static func customFont(size: CGFloat, relativeTo textStyle: TextStyle) -> Font {
if let chosenFont = Theme.shared.chosenFont { 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 { private static func customUIFont(size: CGFloat) -> UIFont {
if let chosenFont = Theme.shared.chosenFont { if let chosenFont = Theme.shared.chosenFont {
return chosenFont.withSize(size) return chosenFont.withSize(size)
} }
return .systemFont(ofSize: size) return .systemFont(ofSize: size)
} }
@ -66,3 +71,14 @@ public extension Font {
customFont(size: userScaledFontSize(baseSize: caption), relativeTo: .caption) 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)
}
}

View file

@ -14,6 +14,7 @@ public class Theme: ObservableObject {
case system case system
case openDyslexic case openDyslexic
case hyperLegible case hyperLegible
case SFRounded
case custom case custom
@MainActor @MainActor
@ -25,6 +26,8 @@ public class Theme: ObservableObject {
return "Open Dyslexic" return "Open Dyslexic"
case .hyperLegible: case .hyperLegible:
return "Hyper Legible" return "Hyper Legible"
case .SFRounded:
return "SF Rounded"
case .custom: case .custom:
return "settings.display.font.custom" return "settings.display.font.custom"
} }
@ -118,7 +121,6 @@ public class Theme: ObservableObject {
@AppStorage(ThemeKey.displayFullUsernameTimeline.rawValue) public var displayFullUsername: Bool = true @AppStorage(ThemeKey.displayFullUsernameTimeline.rawValue) public var displayFullUsername: Bool = true
@AppStorage("font_size_scale") public var fontSizeScale: Double = 1 @AppStorage("font_size_scale") public var fontSizeScale: Double = 1
@AppStorage("chosen_font") public private(set) var chosenFontData: Data? @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 avatarPosition: AvatarPosition = .top
@Published public var avatarShape: AvatarShape = .rounded @Published public var avatarShape: AvatarShape = .rounded

View file

@ -108,7 +108,7 @@ public class UserPreferences: ObservableObject {
} }
return count return count
} }
@Published public var serverPreferences: ServerPreferences? @Published public var serverPreferences: ServerPreferences?
private init() {} private init() {}
@ -134,3 +134,6 @@ public class UserPreferences: ObservableObject {
recentlyUsedLanguages = Array(copy.prefix(3)) recentlyUsedLanguages = Array(copy.prefix(3))
} }
} }