Last active
July 27, 2017 20:28
-
-
Save ashikahmad/6b3eb300e9e99fa16d66efa891e457e0 to your computer and use it in GitHub Desktop.
Prints all available fonts in console. Try pasting this code in Xcode Playground.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment