Enable font scaling on iOS

This commit is contained in:
Thomas Ricouard 2023-01-31 12:16:11 +01:00
parent 0a0e985e33
commit 22af2db36c
2 changed files with 6 additions and 12 deletions

View File

@ -71,12 +71,10 @@ struct DisplaySettingsView: View {
Text(buttonStyle.description).tag(buttonStyle) Text(buttonStyle.description).tag(buttonStyle)
} }
} }
if ProcessInfo.processInfo.isiOSAppOnMac { VStack {
VStack { Slider(value: $userPreferences.fontSizeScale, in: 0.5 ... 1.5, step: 0.1)
Slider(value: $userPreferences.fontSizeScale, in: 0.5 ... 1.5, step: 0.1) Text("Font scaling: \(String(format: "%.1f", userPreferences.fontSizeScale))")
Text("Font scaling: \(String(format: "%.1f", userPreferences.fontSizeScale))") .font(.scaledBody)
.font(.scaledBody)
}
} }
Toggle("settings.display.translate-button", isOn: $userPreferences.showTranslateButton) Toggle("settings.display.translate-button", isOn: $userPreferences.showTranslateButton)
} }

View File

@ -19,7 +19,7 @@ public extension Font {
return .custom(chosenFont.fontName, size: size, relativeTo: textStyle) return .custom(chosenFont.fontName, size: size, relativeTo: textStyle)
} }
return onMac ? .system(size: size) : .system(textStyle) return .system(size: size)
} }
private static func customUIFont(size: CGFloat) -> UIFont { private static func customUIFont(size: CGFloat) -> UIFont {
@ -31,11 +31,7 @@ public extension Font {
} }
private static func userScaledFontSize(baseSize: CGFloat) -> CGFloat { private static func userScaledFontSize(baseSize: CGFloat) -> CGFloat {
if onMac { UIFontMetrics.default.scaledValue(for: baseSize * UserPreferences.shared.fontSizeScale)
return UIFontMetrics.default.scaledValue(for: baseSize * UserPreferences.shared.fontSizeScale)
}
return baseSize
} }
static var scaledTitle: Font { static var scaledTitle: Font {