Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 42 additions & 7 deletions WDBFontOverwrite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
C5C9A7A12959263A00466D87 /* OverwriteFontImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5C9A7A02959263A00466D87 /* OverwriteFontImpl.swift */; };
C5C9A7A32959341600466D87 /* RepackedFonts in Resources */ = {isa = PBXBuildFile; fileRef = C5C9A7A22959341600466D87 /* RepackedFonts */; };
C5C9A7AA2959417100466D87 /* vm_unaligned_copy_switch_race.c in Sources */ = {isa = PBXBuildFile; fileRef = C5C9A7A92959417100466D87 /* vm_unaligned_copy_switch_race.c */; };
EE205E7E29A37AF50086D58E /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = EE205E8029A37AF50086D58E /* Localizable.strings */; };
EE205E8329A3924D0086D58E /* ToolsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE205E8229A3924D0086D58E /* ToolsManager.swift */; };
EEFA4D3E29A4762B00D51F8D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = EEFA4D4029A4762B00D51F8D /* InfoPlist.strings */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -75,6 +78,11 @@
C5C9A7A82959417100466D87 /* WDBFontOverwrite-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WDBFontOverwrite-Bridging-Header.h"; sourceTree = "<group>"; };
C5C9A7A92959417100466D87 /* vm_unaligned_copy_switch_race.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vm_unaligned_copy_switch_race.c; sourceTree = "<group>"; };
C5C9A7AB2959438600466D87 /* vm_unaligned_copy_switch_race.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vm_unaligned_copy_switch_race.h; sourceTree = "<group>"; };
EE205E7F29A37AF50086D58E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
EE205E8129A37AF80086D58E /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
EE205E8229A3924D0086D58E /* ToolsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolsManager.swift; sourceTree = "<group>"; };
EEFA4D3F29A4762B00D51F8D /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
EEFA4D4129A4763000D51F8D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -119,6 +127,7 @@
4FF28A1129679EEC00143640 /* ExplanationView.swift */,
4FF28A132967AA2D00143640 /* ActionButtons.swift */,
4F085E382994EF2F004099C1 /* ActionButtons.ViewModel.swift */,
EE205E8229A3924D0086D58E /* ToolsManager.swift */,
);
path = MainInterface;
sourceTree = "<group>";
Expand Down Expand Up @@ -182,6 +191,8 @@
C5C9A7AB2959438600466D87 /* vm_unaligned_copy_switch_race.h */,
C5C9A7A82959417100466D87 /* WDBFontOverwrite-Bridging-Header.h */,
C5C9A7982959261200466D87 /* Preview Content */,
EE205E8029A37AF50086D58E /* Localizable.strings */,
EEFA4D4029A4762B00D51F8D /* InfoPlist.strings */,
);
path = WDBFontOverwrite;
sourceTree = "<group>";
Expand Down Expand Up @@ -236,7 +247,7 @@
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
"zh-Hans",
);
mainGroup = C5C9A7862959261000466D87;
productRefGroup = C5C9A7902959261000466D87 /* Products */;
Expand All @@ -253,6 +264,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EE205E7E29A37AF50086D58E /* Localizable.strings in Resources */,
EEFA4D3E29A4762B00D51F8D /* InfoPlist.strings in Resources */,
C5A95F46295964AE00C58FDB /* PreviewFonts in Resources */,
C5C9A79A2959261200466D87 /* Preview Assets.xcassets in Resources */,
C5C9A7A32959341600466D87 /* RepackedFonts in Resources */,
Expand All @@ -276,6 +289,7 @@
4FE5EF452966AD87003384EC /* FontDiscoveryScene.swift in Sources */,
4FD690992986395B00B751B2 /* helpers.m in Sources */,
4FF28A1229679EEC00143640 /* ExplanationView.swift in Sources */,
EE205E8329A3924D0086D58E /* ToolsManager.swift in Sources */,
C5C9A7932959261000466D87 /* WDBFontOverwriteApp.swift in Sources */,
4FE5EF38296561A5003384EC /* FileEditorView.swift in Sources */,
4FD690952986367C00B751B2 /* grant_full_disk_access.m in Sources */,
Expand All @@ -297,6 +311,27 @@
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
EE205E8029A37AF50086D58E /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
EE205E7F29A37AF50086D58E /* en */,
EE205E8129A37AF80086D58E /* zh-Hans */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
EEFA4D4029A4762B00D51F8D /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
EEFA4D3F29A4762B00D51F8D /* zh-Hans */,
EEFA4D4129A4763000D51F8D /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
C5C9A79B2959261200466D87 /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down Expand Up @@ -419,9 +454,9 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEVELOPMENT_ASSET_PATHS = "\"WDBFontOverwrite/Preview Content\"";
DEVELOPMENT_TEAM = WNUZX4NA7T;
DEVELOPMENT_TEAM = DB7Q3NDCDU;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = WDBFontOverwrite/Info.plist;
Expand All @@ -440,7 +475,7 @@
"$(inherited)",
"$(PROJECT_DIR)/WDBFontOverwrite",
);
MARKETING_VERSION = 1.10.8;
MARKETING_VERSION = 1.10.10;
PRODUCT_BUNDLE_IDENTIFIER = com.ginsudev.WDBFontOverwrite;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -458,9 +493,9 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 0;
DEVELOPMENT_ASSET_PATHS = "\"WDBFontOverwrite/Preview Content\"";
DEVELOPMENT_TEAM = WNUZX4NA7T;
DEVELOPMENT_TEAM = DB7Q3NDCDU;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = WDBFontOverwrite/Info.plist;
Expand All @@ -479,7 +514,7 @@
"$(inherited)",
"$(PROJECT_DIR)/WDBFontOverwrite",
);
MARKETING_VERSION = 1.10.8;
MARKETING_VERSION = 1.10.10;
PRODUCT_BUNDLE_IDENTIFIER = com.ginsudev.WDBFontOverwrite;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
3 changes: 2 additions & 1 deletion WDBFontOverwrite/MainInterface/ActionButtons.ViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension ActionButtons {
print("can't get disk access, using backup respring")
respringLegacy()
} else {
xpc_crasher(UnsafeMutablePointer<CChar>(mutating: "com.apple.frontboard.systemappservices"))
respring()
}
}
}
Expand All @@ -43,3 +43,4 @@ extension ActionButtons {
}
}
}

4 changes: 2 additions & 2 deletions WDBFontOverwrite/MainInterface/ActionButtons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct ActionButtons: View {
} label: {
AlignedRowContentView(
imageName: "trash",
text: "Clear keyboard cache"
text: NSLocalizedString("Clear keyboard cache", comment: "Clear keyboard cache")
)
}
}
Expand All @@ -30,7 +30,7 @@ struct ActionButtons: View {
} label: {
AlignedRowContentView(
imageName: "arrow.triangle.2.circlepath",
text: "Restart SpringBoard"
text: NSLocalizedString("Restart SpringBoard", comment: "Restart SpringBoard")
)
}
}
Expand Down
14 changes: 7 additions & 7 deletions WDBFontOverwrite/MainInterface/CustomFontsScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct CustomFontsScene: View {
Section {
ExplanationView(
systemImage: "textformat",
description: "Import & manage custom fonts that have been ported to iOS.",
description: NSLocalizedString("Import & manage custom fonts that have been ported to iOS.", comment: "Import & manage custom fonts that have been ported to iOS."),
canShowProgress: true
)
}
Expand Down Expand Up @@ -64,25 +64,25 @@ struct CustomFontsScene: View {
.pickerStyle(.segmented)

Button {
progressManager.message = "Importing..."
progressManager.message = NSLocalizedString("Importing...", comment: "Importing...")
viewModel.importTTCRepackMode = .woff2
viewModel.importPresented = true
} label: {
AlignedRowContentView(
imageName: "square.and.arrow.down",
text: "Import custom \(viewModel.selectedCustomFontType.rawValue)"
text: NSLocalizedString("Import custom \(viewModel.selectedCustomFontType.rawValue)", comment: "Import custom")
)
}
Button {
progressManager.isBusy = true
progressManager.message = "Running"
progressManager.message = NSLocalizedString("Running", comment: "Running")
Task {
await viewModel.batchOverwriteFonts()
}
} label: {
AlignedRowContentView(
imageName: "checkmark.circle",
text: "Apply \(viewModel.selectedCustomFontType.rawValue)"
text: NSLocalizedString("Apply \(viewModel.selectedCustomFontType.rawValue)", comment: "Apply")
)
}
} header: {
Expand All @@ -97,14 +97,14 @@ struct CustomFontsScene: View {
} label: {
AlignedRowContentView(
imageName: "doc.badge.gearshape",
text: "Manage imported fonts"
text: NSLocalizedString("Manage imported fonts", comment: "Manage imported fonts")
)
}
ActionButtons()
} header: {
Text("Actions")
} footer: {
Text("Originally created by [@zhuowei](https://twitter.com/zhuowei). Updated & maintained by [@GinsuDev](https://twitter.com/GinsuDev).")
Text("Originally created by [@zhuowei](https://twitter.com/zhuowei). Updated & maintained by [@GinsuDev](https://twitter.com/GinsuDev). Chinese translation by [@chihaodong](https://twitter.com/chihaodong).")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct FileEditorView: View {
}
}
}
.navigationTitle("Imported fonts (\(viewModel.files.count))")
.navigationTitle(NSLocalizedString("Imported fonts", comment: "Imported fonts") + " (\(viewModel.files.count))")
}
.alert(isPresented: $viewModel.isVisibleRemoveAllAlert) {
Alert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct FontDiscoveryScene: View {
VStack(spacing: 10) {
ExplanationView(
systemImage: "star.fill",
description: "Find fonts and emojis from these talented developers and themers.",
description: NSLocalizedString("Find fonts and emojis from these talented developers and themers.", comment: "Find fonts and emojis from these talented developers and themers."),
canShowProgress: false
)
ForEach(viewModel.descriptors, id: \.name) { descriptor in
Expand Down
14 changes: 12 additions & 2 deletions WDBFontOverwrite/MainInterface/PresetFontsScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,34 @@ import SwiftUI
struct PresetFontsScene: View {
@EnvironmentObject private var progressManager: ProgressManager
private let viewModel = ViewModel()
@State private var versionBuildString: String?

var body: some View {
NavigationView {
Form {
Section {
ExplanationView(
systemImage: "textformat",
description: "Choose from a selection of preset fonts.",
description: NSLocalizedString("Choose from a selection of preset fonts.", comment: "Choose from a selection of preset fonts."),
canShowProgress: true
)
}
.listRowBackground(Color(UIColor(red: 0.44, green: 0.69, blue: 0.67, alpha: 1.00)))
fontsSection
actionSection
Section {
} header: {
Label("Version \(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "UNKNOWN") (\(versionBuildString ?? "Release"))", systemImage: "info")
}
}
.navigationTitle("Presets")
}
.navigationViewStyle(.stack)
.onAppear {
if let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String, build != "0" {
versionBuildString = "Beta \(build)"
}
}
}
}

Expand Down Expand Up @@ -60,7 +70,7 @@ private extension PresetFontsScene {
} header: {
Text("Actions")
} footer: {
Text("Originally created by [@zhuowei](https://twitter.com/zhuowei). Updated & maintained by [@GinsuDev](https://twitter.com/GinsuDev).")
Text("Originally created by [@zhuowei](https://twitter.com/zhuowei). Updated & maintained by [@GinsuDev](https://twitter.com/GinsuDev). Chinese translation by [@chihaodong](https://twitter.com/chihaodong).")
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions WDBFontOverwrite/MainInterface/ToolsManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// ToolsManager.swift
// WDBFontOverwrite
//
// Created by 迟浩东 on 2023/2/20.
//

import UIKit

/* 注销重启 */
func respring() {
UIImpactFeedbackGenerator(style: .soft).impactOccurred()

let view = UIView(frame: UIScreen.main.bounds)
view.backgroundColor = .black
view.alpha = 0

for window in UIApplication.shared.connectedScenes.map({ $0 as? UIWindowScene }).compactMap({ $0 }).flatMap({ $0.windows.map { $0 } }) {
window.addSubview(view)
UIView.animate(withDuration: 0.2, delay: 0, animations: {
view.alpha = 1
})
}

DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: {
restartFrontboard()
exit(0)
})
}
4 changes: 2 additions & 2 deletions WDBFontOverwrite/Progress/ProgressManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ final class ProgressManager: ObservableObject {
@Published var completedProgress: Double = 0
@Published var totalProgress: Double = 0
@Published var importResults = [ImportStatus]()
@Published var message: String = "Choose a font."
@Published var message: String = NSLocalizedString("Choose a font.", comment: "Choose a font.")

@Published var isPresentedResultsAlert = false {
didSet {
if !isPresentedResultsAlert {
importResults = []
message = "Done."
message = NSLocalizedString("Done.", comment: "Done.")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion WDBFontOverwrite/WDBFontOverwriteApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct WDBFontOverwriteApp: App {
for result in progressManager.importResults {
switch result {
case .success:
message += "Successfully imported.\n"
message += NSLocalizedString("Successfully imported.\n", comment: "Successfully imported.\n")
case .failure(let string):
message += "\(string)\n"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class WDBImportCustomFontPickerViewControllerDelegate: NSObject, UIDocumentPicke

func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
Task { @MainActor in
ProgressManager.shared.message = "Cancelled"
ProgressManager.shared.message = NSLocalizedString("Cancelled", comment: "Cancelled")
}
}

Expand Down Expand Up @@ -55,10 +55,10 @@ class WDBImportCustomFontPickerViewControllerDelegate: NSObject, UIDocumentPicke
}

ProgressManager.shared.message = String(
format: "Successfully imported %d/%d files.%@",
format: NSLocalizedString("Successfully imported %d/%d files.%@", comment: "Successfully imported %d/%d files.%@"),
successfullyImportedCount,
urls.count,
successfullyImportedCount == urls.count ? "" : " Some files were skipped because your device doesn't have those fonts or because they don't support your iOS/device."
successfullyImportedCount == urls.count ? "" : NSLocalizedString(" Some files were skipped because your device doesn't have those fonts or because they don't support your iOS/device.", comment: " Some files were skipped because your device doesn't have those fonts or because they don't support your iOS/device.")
)
}

Expand Down
12 changes: 12 additions & 0 deletions WDBFontOverwrite/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
InfoPlist.strings
WDBFontOverwrite

Created by 迟浩东 on 2023/2/21.

*/
/* Bundle display name */
"CFBundleDisplayName" = "WDBFontOverwrite";

/* Bundle name */
"CFBundleName" = "WDBFontOverwrite";
7 changes: 7 additions & 0 deletions WDBFontOverwrite/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
Localizable.strings
WDBFontOverwrite

Created by 迟浩东 on 2023/2/20.

*/
2 changes: 2 additions & 0 deletions WDBFontOverwrite/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ void test_nsexpressions(void);
char* set_up_tmp_file(void);

void xpc_crasher(char* service_name);
void restartBackboard(void);
void restartFrontboard(void);

#define ROUND_DOWN_PAGE(val) (val & ~(PAGE_SIZE - 1ULL))

Expand Down
Loading