Skip to content

Commit 584ab69

Browse files
Added custom chinese font (#1057)
* Added custom chinese font * Fix fonts folder copying * Add clear PSPDFKit cache guard to do so when incremented --------- Co-authored-by: Miltiadis Vasilakis <[email protected]>
1 parent 5928649 commit 584ab69

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

Zotero.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
618404262A4456A9005AAF22 /* IdentifierLookupController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618404252A4456A9005AAF22 /* IdentifierLookupController.swift */; };
4040
618D83E72BAAC88C00E7966B /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 618D83E62BAAC88C00E7966B /* PrivacyInfo.xcprivacy */; };
4141
618D83E82BAAC88C00E7966B /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 618D83E62BAAC88C00E7966B /* PrivacyInfo.xcprivacy */; };
42+
61975C422D38E6E8005BB41A /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = 61975C412D38E6E8005BB41A /* fonts */; };
4243
61A0C8472B8F669C0048FF92 /* PSPDFKitUI+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61A0C8462B8F669B0048FF92 /* PSPDFKitUI+Extensions.swift */; };
4344
61ABA7512A6137D1002A4219 /* ShareableImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61ABA7502A6137D1002A4219 /* ShareableImage.swift */; };
4445
61BD13952A5831EF008A0704 /* TextKit1TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61BD13942A5831EF008A0704 /* TextKit1TextView.swift */; };
@@ -1307,6 +1308,7 @@
13071308
61639F842AE03B8500026003 /* InstantPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstantPresenter.swift; sourceTree = "<group>"; };
13081309
618404252A4456A9005AAF22 /* IdentifierLookupController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentifierLookupController.swift; sourceTree = "<group>"; };
13091310
618D83E62BAAC88C00E7966B /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
1311+
61975C412D38E6E8005BB41A /* fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = fonts; sourceTree = "<group>"; };
13101312
61A0C8462B8F669B0048FF92 /* PSPDFKitUI+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PSPDFKitUI+Extensions.swift"; sourceTree = "<group>"; };
13111313
61ABA7502A6137D1002A4219 /* ShareableImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareableImage.swift; sourceTree = "<group>"; };
13121314
61BD13942A5831EF008A0704 /* TextKit1TextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextKit1TextView.swift; sourceTree = "<group>"; };
@@ -2843,6 +2845,7 @@
28432845
isa = PBXGroup;
28442846
children = (
28452847
B3F6415E2A28B1EF00A78CB0 /* ci_scripts */,
2848+
61975C412D38E6E8005BB41A /* fonts */,
28462849
B30BA8C3255D415600361D25 /* Bundled */,
28472850
B32A495A2A44730C00080945 /* licenses */,
28482851
B30D59572206F60400884C4A /* Zotero */,
@@ -4511,6 +4514,7 @@
45114514
isa = PBXResourcesBuildPhase;
45124515
buildActionMask = 2147483647;
45134516
files = (
4517+
61975C422D38E6E8005BB41A /* fonts in Resources */,
45144518
B3593F33241A61C700760E20 /* ItemDetailNoteContentView.xib in Resources */,
45154519
618D83E72BAAC88C00E7966B /* PrivacyInfo.xcprivacy in Resources */,
45164520
B32A273D254841B80081E061 /* CreatorEditViewController.xib in Resources */,

Zotero/AppDelegate.swift

+9-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,15 @@ extension AppDelegate: SceneActivityCounter {
210210
extension AppDelegate: UIApplicationDelegate {
211211
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
212212
if let key = Licenses.shared.pspdfkitKey {
213-
PSPDFKit.SDK.setLicenseKey(key)
213+
let additionalFontDirectory = Bundle.main.bundleURL.appendingPathComponent("fonts", isDirectory: true).path
214+
let options: [SDK.Setting: Any] = [.additionalFontDirectories: [additionalFontDirectory]]
215+
PSPDFKit.SDK.setLicenseKey(key, options: options)
216+
}
217+
DDLogInfo("AppDelegate: clearPSPDFKitCacheGuard: \(Defaults.shared.clearPSPDFKitCacheGuard); currentClearPSPDFKitCacheGuard: \(Defaults.currentClearPSPDFKitCacheGuard)")
218+
if Defaults.shared.clearPSPDFKitCacheGuard < Defaults.currentClearPSPDFKitCacheGuard {
219+
PSPDFKit.SDK.shared.cache.clear()
220+
DDLogInfo("AppDelegate: did clear PSPDFKit cache")
221+
Defaults.shared.clearPSPDFKitCacheGuard = Defaults.currentClearPSPDFKitCacheGuard
214222
}
215223
PSPDFKit.SDK.shared.styleManager.setLastUsedValue(AnnotationsConfig.imageAnnotationLineWidth,
216224
forProperty: "lineWidth",

Zotero/Models/Defaults.swift

+5
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ final class Defaults {
175175
@UserDefault(key: "DidPerformFullSyncFix", defaultValue: true)
176176
var didPerformFullSyncFix: Bool
177177

178+
// Increment currentClearPSPDFKitCacheGuard by 1, whenever the upcoming release should clear the PSPDFKit cache.
179+
static let currentClearPSPDFKitCacheGuard = 1
180+
@UserDefault(key: "ClearPSPDFKitCacheGuard", defaultValue: currentClearPSPDFKitCacheGuard - 1)
181+
var clearPSPDFKitCacheGuard: Int
182+
178183
// MARK: - Actions
179184

180185
func reset() {
17 MB
Binary file not shown.

0 commit comments

Comments
 (0)