import PhotoEditorSDK
import UIKit
class PhotoAddFontsFromAppBundleSwift: Example, PhotoEditViewControllerDelegate {
override func invokeExample() {
let photo = Photo(url: Bundle.main.url(forResource: "LA", withExtension: "jpg")!)
let fontURL = Bundle.main.url(forResource: "custom_font_raleway_regular", withExtension: "ttf")
let customFont = Font(url: fontURL!, displayName: "Raleway", fontName: "custom_font_raleway_regular", identifier: "custom_font_raleway_regular")
let systemFont = Font(displayName: "Helvetica", fontName: "Helvetica", identifier: "system_font_helvetica")
let configuration = Configuration { builder in
let assetCatalog = AssetCatalog.defaultItems
assetCatalog.fonts.append(contentsOf: [customFont, systemFont])
builder.assetCatalog = assetCatalog
}
let photoEditViewController = PhotoEditViewController(photoAsset: photo, configuration: configuration)
photoEditViewController.delegate = self
photoEditViewController.modalPresentationStyle = .fullScreen
presentingViewController?.present(photoEditViewController, animated: true, completion: nil)
}
func photoEditViewControllerShouldStart(_ photoEditViewController: PhotoEditViewController, task: PhotoEditorTask) -> Bool {
true
}
func photoEditViewControllerDidFinish(_ photoEditViewController: PhotoEditViewController, result: PhotoEditorResult) {
presentingViewController?.dismiss(animated: true, completion: nil)
}
func photoEditViewControllerDidFail(_ photoEditViewController: PhotoEditViewController, error: PhotoEditorError) {
print(error.localizedDescription)
presentingViewController?.dismiss(animated: true, completion: nil)
}
func photoEditViewControllerDidCancel(_ photoEditViewController: PhotoEditViewController) {
presentingViewController?.dismiss(animated: true, completion: nil)
}
}