I need to write a custom font picker view in my ios project. when user click on font family name, i need to display fonts which are in particular family, i used name as particular text style in the family name. I couldn't find the standard way to getting the text style name of the particular name. please, help me to resolve this.
As an example,
i have compared print all fonts names and UIFontPickerViewController
ios component font names.
if i print family name and font name it is looking below for Times New Roman
family.
Family name Times New Roman
Font name: TimesNewRomanPS-ItalicMT
Font name: TimesNewRomanPS-BoldItalicMT
Font name: TimesNewRomanPS-BoldMT
Font name: TimesNewRomanPSMT
But in the UIFontPickerViewController
(ios component), it display like this
I would like to know , how we can get text style Regular, Italic, Bold, Bold Italic
from above printed names ?
please, help me and appreciate ur feedback.
Please, refer below source code for comparison
import UIKit
class ViewController: UIViewController, UIFontPickerViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let familyNames = UIFont.familyNames.sorted()
for family in familyNames {
print("Family name " + family)
let fontNames = UIFont.fontNames(forFamilyName: family)
for font in fontNames {
print(" Font name: " + font)
}
}
let configuration = UIFontPickerViewController.Configuration()
configuration.includeFaces = true
configuration.displayUsingSystemFont = true
configuration.filteredTraits = [.classModernSerifs]
let vc = UIFontPickerViewController(configuration: configuration)
vc.delegate = self
present(vc, animated: true)
}
}