import UIKit
/*
Prints all available fonts in console. Try pasting this code in Xcode Playground
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
┌───────────┐
│ All Fonts │
└┬──────────┘
├─┬─⦿ Family with fonts
│ ├───⦿ Font 1
│ └───⦿ Font 2
...
├───⦿ Family without fonts
│
└─┬─⦿ Last Family
├───⦿ Font 1
├───⦿ Font 1
└───⦿ Font 1
*/
print("┌───────────┐")
print("│ All Fonts │")
print("└┬──────────┘")
let familyNames = UIFont.familyNames
let lastIndex = familyNames.count-1
let bullet = "⦿"
for i in 0...lastIndex {
let isLastFamily = (i == lastIndex)
let family = familyNames[i]
let fontNames = UIFont.fontNames(forFamilyName: family)
let br1 = isLastFamily ? " └" : " ├"
let br2 = fontNames.count == 0 ? "─" : "┬"
print(br1+"─"+br2+"─"+bullet+" "+family)
if fontNames.count > 0 {
let lastFontIndex = fontNames.count-1
for k in 0...lastFontIndex {
let font = fontNames[k]
let br1 = isLastFamily ? " " : "│"
let br2 = (k == lastFontIndex) ? "└─" : "├─"
print(" "+br1+" "+br2+"──"+bullet+" "+font)
if k == lastFontIndex {
print(" "+br1)
}
}
} else {
let ch1 = isLastFamily ? " " : " │ "
print(ch1)
}
}