It is possible to do that on iOS. First to configure the text in the textOptions
tool you can use this snippet when setting up Configuration
:
let configuration = Configuration { builder in
builder.configureTextOptionsToolController { options in
options.actionButtonConfigurationClosure = { cell, textAction in
guard textAction == .selectFont else { return }
cell.iconImageView.image = IconGenerator.generateTextImage(with: UIFont.systemFont(ofSize: 20), of: CGSize(width: 36, height: 36), text: "Aa")?.withRenderingMode(.alwaysTemplate)
}
}
}
Then for the font menu you will need to write a custom FontListSectionController
like this:
class MyFontListSelectionController: FontListSectionController {
private var fontMenuItem: FontMenuItem?
open override func didUpdate(to object: Any) {
super.didUpdate(to: object)
if let fontMenuItem = object as? FontMenuItem {
self.fontMenuItem = fontMenuItem
}
}
open override func cellForItem(at index: Int) -> UICollectionViewCell {
guard let cell = super.cellForItem(at: index) as? MenuCollectionViewCell,
let fontMenuItem = fontMenuItem else {
fatalError()
}
if let uiFont = UIFont(name: fontMenuItem.font.fontName, size: 20) {
cell.iconImageView.image = IconGenerator.generateTextImage(with: uiFont, of: CGSize(width: 36, height: 36), text: "Aa")?.withRenderingMode(.alwaysTemplate)
}
cell.captionTextLabel.text = fontMenuItem.title
cell.accessibilityLabel = fontMenuItem.accessibilityLabel
return cell
}
}
Once you have done that, where you initialize the licence, someplace after that replace stock FontListSectionController
with MyFontListSelectionController
which is done like this:**try**! IMGLY.replaceClass(FontListSectionController.**self**, with: MyFontListSelectionController.**self**)
. Let me know if you have any more questions.