From 6639d7b3493b0f1ebe0dcefbb17c57d03f380469 Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Mon, 1 Dec 2025 23:37:20 -0500 Subject: [PATCH 1/2] support setting generic font families --- assets/zh-Hans.lproj/Localizable.strings | Bin 11160 -> 11276 bytes assets/zh-Hant.lproj/Localizable.strings | Bin 11234 -> 11354 bytes fcitx5 | 2 +- src/config/FontView.swift | 123 +++++++++++++++++++++++ src/config/optionviews.swift | 85 ---------------- 5 files changed, 124 insertions(+), 86 deletions(-) create mode 100644 src/config/FontView.swift diff --git a/assets/zh-Hans.lproj/Localizable.strings b/assets/zh-Hans.lproj/Localizable.strings index b95edc994e186fb7ee127087eb2ef1f13e260722..fa39645c40d2c9186011bee2101ced62adcaf052 100644 GIT binary patch delta 116 zcmbOc-V?E5ih!CMLq0eFgA$N$3&ctc;nBhV=Tj&52 String { + return NSFontManager.shared.localizedName(forFamily: fontFamily, face: nil) + } +} diff --git a/src/config/optionviews.swift b/src/config/optionviews.swift index c26c559..af84d44 100644 --- a/src/config/optionviews.swift +++ b/src/config/optionviews.swift @@ -387,91 +387,6 @@ struct ListOptionView: OptionView { } } -struct FontOptionView: OptionView { - let label: String - @ObservedObject var model: FontOption - @State private var selectorIsOpen = false - @State var searchInput = "" - @State var previewInput = NSLocalizedString("Preview", comment: "") - - // If initialize [], the sheet will list nothing on first open. - @State var availableFontFamilies = NSFontManager.shared.availableFontFamilies - var filteredFontFamilies: [String] { - if searchInput.trimmingCharacters(in: .whitespaces).isEmpty { - return availableFontFamilies - } else { - return availableFontFamilies.filter { - $0.localizedCaseInsensitiveContains(searchInput) - || localize($0).localizedCaseInsensitiveContains(searchInput) - } - } - } - @State private var selectedFontFamily: String? - - var body: some View { - Button(action: openSelector) { - if model.value.isEmpty { - Text("Select font") - } else { - Text(localize(model.value)) - } - } - .sheet(isPresented: $selectorIsOpen) { - VStack { - TextField(NSLocalizedString("Search", comment: ""), text: $searchInput) - TextField(NSLocalizedString("Preview", comment: ""), text: $previewInput) - Text(previewInput).font(Font.custom(selectedFontFamily ?? model.value, size: 32)).frame( - height: 64) - List(selection: $selectedFontFamily) { - ForEach(filteredFontFamilies, id: \.self) { family in - HStack { - Text(localize(family)).font(Font.custom(family, size: 14)) - Spacer() - Text(localize(family)) - } - } - }.contextMenu(forSelectionType: String.self) { items in - } primaryAction: { items in - // Double click - select() - } - HStack { - Button { - selectorIsOpen = false - } label: { - Text("Cancel") - } - Spacer() - Button { - select() - } label: { - Text("Select") - }.buttonStyle(.borderedProminent) - .disabled(selectedFontFamily == nil) - } - } - .padding() - .frame(minWidth: 500, minHeight: 600) - } - } - - private func openSelector() { - availableFontFamilies = NSFontManager.shared.availableFontFamilies - selectorIsOpen = true - } - - private func select() { - if let selectedFontFamily = selectedFontFamily { - model.value = selectedFontFamily - } - selectorIsOpen = false - } - - private func localize(_ fontFamily: String) -> String { - return NSFontManager.shared.localizedName(forFamily: fontFamily, face: nil) - } -} - struct PunctuationMapOptionView: OptionView { let label: String @ObservedObject var model: PunctuationMapOption From 5a10d3b547b63a522b343be04b4b7e1a826019e9 Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Tue, 2 Dec 2025 00:09:40 -0500 Subject: [PATCH 2/2] fix quote --- fcitx5-webview | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fcitx5-webview b/fcitx5-webview index eaa3b57..781e802 160000 --- a/fcitx5-webview +++ b/fcitx5-webview @@ -1 +1 @@ -Subproject commit eaa3b57b32f1722860cd1795729cc334539b0511 +Subproject commit 781e802257250c1df4f59467fc98af7498df7140