我尝试了以下代码将自定义字体添加到imglyKit SDK中,但未添加自定义字体。我还将.ttf文件作为资源放入了info.plist文件中。

        let sampleImage = image.image

    let configuration = Configuration() { builder in
        FontImporter.init().importFonts()

        builder.configurePhotoEditorViewController({ (editPhotoOption) in

            editPhotoOption.allowedPhotoEditorActions = [.text]

            editPhotoOption.actionButtonConfigurationClosure = {cell, _ in

                cell.captionLabel.text = "Add Text"
                //cell.backgroundColor = UIColor.red
            }
            editPhotoOption.backgroundColor = UIColor.brown
            editPhotoOption.allowsPreviewImageZoom = false
        })

        builder.configureToolStackController({ (toolStackOption) in

            toolStackOption.mainToolbarBackgroundColor = UIColor.red
            toolStackOption.secondaryToolbarBackgroundColor = UIColor.brown

        })

        builder.configureTextFontToolController({ (textFontToolOption) in

            var fontArray = [String]()
            fontArray = ["AlexBrush_Regular.ttf", "Arabella.ttf"]
            textFontToolOption.accessibilityElements = fontArray

            textFontToolOption.actionButtonConfigurationClosure = { cell, _ in
                cell.backgroundColor = UIColor.red
            }
        })


        builder.configureTextToolController({ (textToolOption) in

            textToolOption.textViewConfigurationClosure = { label in

                label.textAlignment = NSTextAlignment.center
            }
        })
    }

    let photoEditViewController = PhotoEditViewController(photo: sampleImage!, configuration: configuration)



    let toolStackController = ToolStackController(photoEditViewController: photoEditViewController)
    toolStackController.delegate = self
    toolStackController.navigationController?.view.backgroundColor = UIColor.red
    present(toolStackController, animated: true, completion: nil)

请帮助我添加自定义字体

我还使用FontImporter类按照此处的指南加载自定义字体http://static.photoeditorsdk.com/docs/ios/Classes/FontImporter.html
谢谢...

最佳答案

我已经调查了这个问题。看起来importFonts()函数仅用于内部使用。如果您想添加自定义字体,则应询问imglyKit开发人员,或者可以使用availableFontsList方法添加自定义字体。

您可以在类InstanceFactory on GitHub中找到此方法。类方法令人费解的示例:Gist

10-07 21:15