diff --git a/.gitignore b/.gitignore index 4ade8f822..89b16baf4 100644 --- a/.gitignore +++ b/.gitignore @@ -80,4 +80,5 @@ fastlane/test_output bundled/translators bundled/styles bundled/locales -bundled/note_editor \ No newline at end of file +bundled/note_editor +fonts diff --git a/Zotero.xcodeproj/project.pbxproj b/Zotero.xcodeproj/project.pbxproj index 79f52169b..c75f9ad4e 100644 --- a/Zotero.xcodeproj/project.pbxproj +++ b/Zotero.xcodeproj/project.pbxproj @@ -39,6 +39,7 @@ 618404262A4456A9005AAF22 /* IdentifierLookupController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618404252A4456A9005AAF22 /* IdentifierLookupController.swift */; }; 618D83E72BAAC88C00E7966B /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 618D83E62BAAC88C00E7966B /* PrivacyInfo.xcprivacy */; }; 618D83E82BAAC88C00E7966B /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 618D83E62BAAC88C00E7966B /* PrivacyInfo.xcprivacy */; }; + 61975C422D38E6E8005BB41A /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = 61975C412D38E6E8005BB41A /* fonts */; }; 61A0C8472B8F669C0048FF92 /* PSPDFKitUI+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61A0C8462B8F669B0048FF92 /* PSPDFKitUI+Extensions.swift */; }; 61ABA7512A6137D1002A4219 /* ShareableImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61ABA7502A6137D1002A4219 /* ShareableImage.swift */; }; 61BD13952A5831EF008A0704 /* TextKit1TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61BD13942A5831EF008A0704 /* TextKit1TextView.swift */; }; @@ -1307,6 +1308,7 @@ 61639F842AE03B8500026003 /* InstantPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstantPresenter.swift; sourceTree = ""; }; 618404252A4456A9005AAF22 /* IdentifierLookupController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentifierLookupController.swift; sourceTree = ""; }; 618D83E62BAAC88C00E7966B /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 61975C412D38E6E8005BB41A /* fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = fonts; sourceTree = ""; }; 61A0C8462B8F669B0048FF92 /* PSPDFKitUI+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PSPDFKitUI+Extensions.swift"; sourceTree = ""; }; 61ABA7502A6137D1002A4219 /* ShareableImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareableImage.swift; sourceTree = ""; }; 61BD13942A5831EF008A0704 /* TextKit1TextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextKit1TextView.swift; sourceTree = ""; }; @@ -2843,6 +2845,7 @@ isa = PBXGroup; children = ( B3F6415E2A28B1EF00A78CB0 /* ci_scripts */, + 61975C412D38E6E8005BB41A /* fonts */, B30BA8C3255D415600361D25 /* Bundled */, B32A495A2A44730C00080945 /* licenses */, B30D59572206F60400884C4A /* Zotero */, @@ -4511,6 +4514,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 61975C422D38E6E8005BB41A /* fonts in Resources */, B3593F33241A61C700760E20 /* ItemDetailNoteContentView.xib in Resources */, 618D83E72BAAC88C00E7966B /* PrivacyInfo.xcprivacy in Resources */, B32A273D254841B80081E061 /* CreatorEditViewController.xib in Resources */, diff --git a/Zotero/AppDelegate.swift b/Zotero/AppDelegate.swift index 63d22002a..947dc9399 100644 --- a/Zotero/AppDelegate.swift +++ b/Zotero/AppDelegate.swift @@ -210,7 +210,15 @@ extension AppDelegate: SceneActivityCounter { extension AppDelegate: UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { if let key = Licenses.shared.pspdfkitKey { - PSPDFKit.SDK.setLicenseKey(key) + let additionalFontDirectory = Bundle.main.bundleURL.appendingPathComponent("fonts", isDirectory: true).path + let options: [SDK.Setting: Any] = [.additionalFontDirectories: [additionalFontDirectory]] + PSPDFKit.SDK.setLicenseKey(key, options: options) + } + DDLogInfo("AppDelegate: clearPSPDFKitCacheGuard: \(Defaults.shared.clearPSPDFKitCacheGuard); currentClearPSPDFKitCacheGuard: \(Defaults.currentClearPSPDFKitCacheGuard)") + if Defaults.shared.clearPSPDFKitCacheGuard < Defaults.currentClearPSPDFKitCacheGuard { + PSPDFKit.SDK.shared.cache.clear() + DDLogInfo("AppDelegate: did clear PSPDFKit cache") + Defaults.shared.clearPSPDFKitCacheGuard = Defaults.currentClearPSPDFKitCacheGuard } PSPDFKit.SDK.shared.styleManager.setLastUsedValue(AnnotationsConfig.imageAnnotationLineWidth, forProperty: "lineWidth", diff --git a/Zotero/Models/Defaults.swift b/Zotero/Models/Defaults.swift index ce1f74f14..2154f93de 100644 --- a/Zotero/Models/Defaults.swift +++ b/Zotero/Models/Defaults.swift @@ -175,6 +175,11 @@ final class Defaults { @UserDefault(key: "DidPerformFullSyncFix", defaultValue: true) var didPerformFullSyncFix: Bool + // Increment currentClearPSPDFKitCacheGuard by 1, whenever the upcoming release should clear the PSPDFKit cache. + static let currentClearPSPDFKitCacheGuard = 1 + @UserDefault(key: "ClearPSPDFKitCacheGuard", defaultValue: currentClearPSPDFKitCacheGuard - 1) + var clearPSPDFKitCacheGuard: Int + // MARK: - Actions func reset() { diff --git a/ci_scripts/ci_post_clone.sh b/ci_scripts/ci_post_clone.sh index 3c1abe78c..2656d7d1f 100755 --- a/ci_scripts/ci_post_clone.sh +++ b/ci_scripts/ci_post_clone.sh @@ -8,6 +8,22 @@ set -euo pipefail +# Download missing fonts (remove if fixed in PSPDFKit) +font_url="https://raw.githubusercontent.com/notofonts/noto-cjk/refs/heads/main/google-fonts/NotoSansSC%5Bwght%5D.ttf" +output_directory="../fonts" +mkdir -p $output_directory +output_filename="NotoSansSC[wght].ttf" +output_path="$output_directory/$output_filename" +curl -fL -o "$output_path" $font_url || { echo "Font download failed"; exit 1; } +echo "Verifying downloaded font file..." +if file "$output_path" | grep -q "TrueType Font data"; then + echo "Font file verification passed: $output_path is a TTF file." +else + echo "Font file verification failed: $output_path is not a TTF file." + rm -f "$output_path" + exit 1 +fi + which swiftgen || HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install swiftgen which swiftlint || HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install swiftlint which openssl || HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install openssl