Skip to content

Commit

Permalink
import file as copy
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuowei committed Dec 30, 2022
1 parent ca97df5 commit cf4a982
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions WDBFontOverwrite/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,11 @@ class WDBImportCustomFontPickerViewControllerDelegate: NSObject, UIDocumentPicke
}
DispatchQueue.global(qos: .userInteractive).async {
let fileURL = urls[0]
guard fileURL.startAccessingSecurityScopedResource() else {
DispatchQueue.main.async {
self.completion("startAccessingSecurityScopedResource false?")
}
return
}
let documentDirectory = FileManager.default.urls(
for: .documentDirectory, in: .userDomainMask)[
0
]
for: .documentDirectory, in: .userDomainMask)[0]
let targetURL = documentDirectory.appendingPathComponent(self.name)
let success = importCustomFontImpl(
fileURL: fileURL, targetURL: targetURL, ttcRepackMode: self.ttcRepackMode)
fileURL.stopAccessingSecurityScopedResource()
DispatchQueue.main.async {
self.completion(success ?? "Imported")
}
Expand All @@ -174,9 +165,10 @@ struct DocumentPicker: UIViewControllerRepresentable {
}
func makeUIViewController(context: Context) -> UIDocumentPickerViewController {
print("make ui view controller?")
let pickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: [
UTType.font, UTType(filenameExtension: "woff2", conformingTo: .font)!,
])
let pickerViewController = UIDocumentPickerViewController(
forOpeningContentTypes: [
UTType.font, UTType(filenameExtension: "woff2", conformingTo: .font)!,
], asCopy: true)
pickerViewController.delegate = self.controllerDelegate
return pickerViewController
}
Expand Down

0 comments on commit cf4a982

Please sign in to comment.