aboutsummaryrefslogtreecommitdiff
path: root/Map
diff options
context:
space:
mode:
Diffstat (limited to 'Map')
-rw-r--r--Map/Localizable.xcstrings11
-rw-r--r--Map/Presentation/Complex Components/MapRender/MapRenderView.swift3
-rw-r--r--Map/Presentation/Preferences/MapPreferencesView.swift14
-rw-r--r--Map/Presentation/Theme/Font+theme.swift31
4 files changed, 54 insertions, 5 deletions
diff --git a/Map/Localizable.xcstrings b/Map/Localizable.xcstrings
index 69b9423..a4b07f0 100644
--- a/Map/Localizable.xcstrings
+++ b/Map/Localizable.xcstrings
@@ -280,6 +280,17 @@
}
}
},
+ "preferences.map.map_style.use_custom_font" : {
+ "extractionState" : "manual",
+ "localizations" : {
+ "en" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Use Custom Font"
+ }
+ }
+ }
+ },
"preferences.menu.appearance" : {
"extractionState" : "manual",
"localizations" : {
diff --git a/Map/Presentation/Complex Components/MapRender/MapRenderView.swift b/Map/Presentation/Complex Components/MapRender/MapRenderView.swift
index 2357013..7fd4092 100644
--- a/Map/Presentation/Complex Components/MapRender/MapRenderView.swift
+++ b/Map/Presentation/Complex Components/MapRender/MapRenderView.swift
@@ -22,6 +22,8 @@ struct MapRenderView: View {
@Binding var document: MapDocument
@Binding var evolution: StageType
@AppStorage("showMapBackground") var showMapBackground: Bool = true
+ @AppStorage("useCustomFont") var useCustomFont: Bool = false
+ @AppStorage("customFontName") var customFontName: String = "Helvetica"
var stage: Stage {
Stage.stages(evolution)
@@ -77,6 +79,7 @@ struct MapRenderView: View {
MapNotes(
mapSize: mapSize, lineWidth: lineWidth, notes: parsedMap.notes)
}
+ .id("\(useCustomFont)-\(customFontName)")
.offset(x: padding, y: padding).frame(
width: mapSize.width + 2 * padding,
height: mapSize.height + 2 * padding, alignment: .topLeading
diff --git a/Map/Presentation/Preferences/MapPreferencesView.swift b/Map/Presentation/Preferences/MapPreferencesView.swift
index f8c976e..c5a9236 100644
--- a/Map/Presentation/Preferences/MapPreferencesView.swift
+++ b/Map/Presentation/Preferences/MapPreferencesView.swift
@@ -18,6 +18,8 @@ import SwiftUI
struct MapPreferencesView: View {
@AppStorage("showMapBackground") private var showBackground = true
@AppStorage("useSmartEditor") private var useSmartEditor = false
+ @AppStorage("useCustomFont") private var useCustomFont = false
+ @AppStorage("customFontName") private var customFontName = "Helvetica"
var body: some View {
VStack(alignment: .center, spacing: Dimensions.Spacing.loose) {
@@ -30,6 +32,18 @@ struct MapPreferencesView: View {
Toggle(isOn: $showBackground, label: { Text("preferences.map.map_style.show_background")
.font(.Theme.Body.regular)
})
+
+ Toggle(isOn: $useCustomFont, label: { Text("preferences.map.map_style.use_custom_font")
+ .font(.Theme.Body.regular)
+ })
+
+ Picker("", selection: $customFontName) {
+ ForEach(NSFontManager.shared.availableFontFamilies, id: \.self) { fontFamily in
+ Text(fontFamily).tag(fontFamily)
+ }
+ }
+ .pickerStyle(MenuPickerStyle())
+ .disabled(!useCustomFont)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
diff --git a/Map/Presentation/Theme/Font+theme.swift b/Map/Presentation/Theme/Font+theme.swift
index cc80fc4..079c0de 100644
--- a/Map/Presentation/Theme/Font+theme.swift
+++ b/Map/Presentation/Theme/Font+theme.swift
@@ -46,11 +46,32 @@ extension Font {
}
struct Map {
- static let note = Font.libertinus(size: Dimensions.FontSize.Map.note).weight(.regular)
- static let axisLabel = Font.libertinus(size: Dimensions.FontSize.Map.axisLabel).weight(
- .regular)
- static let vertexLabel = Font.libertinus(size: Dimensions.FontSize.Map.vertexLabel).weight(
- .regular)
+ static var note: Font {
+ if UserDefaults.standard.bool(forKey: "useCustomFont"),
+ let customFontName = UserDefaults.standard.string(forKey: "customFontName"),
+ !customFontName.isEmpty {
+ return Font.custom(customFontName, size: Dimensions.FontSize.Map.note).weight(.regular)
+ }
+ return Font.libertinus(size: Dimensions.FontSize.Map.note).weight(.regular)
+ }
+
+ static var axisLabel: Font {
+ if UserDefaults.standard.bool(forKey: "useCustomFont"),
+ let customFontName = UserDefaults.standard.string(forKey: "customFontName"),
+ !customFontName.isEmpty {
+ return Font.custom(customFontName, size: Dimensions.FontSize.Map.axisLabel).weight(.regular)
+ }
+ return Font.libertinus(size: Dimensions.FontSize.Map.axisLabel).weight(.regular)
+ }
+
+ static var vertexLabel: Font {
+ if UserDefaults.standard.bool(forKey: "useCustomFont"),
+ let customFontName = UserDefaults.standard.string(forKey: "customFontName"),
+ !customFontName.isEmpty {
+ return Font.custom(customFontName, size: Dimensions.FontSize.Map.vertexLabel).weight(.regular)
+ }
+ return Font.libertinus(size: Dimensions.FontSize.Map.vertexLabel).weight(.regular)
+ }
}
}
}