Skip to content

Instantly share code, notes, and snippets.

@ahmedk92
Created June 5, 2020 22:28
Show Gist options
  • Save ahmedk92/d8816a899b2331227724127b2b6e94fe to your computer and use it in GitHub Desktop.
Save ahmedk92/d8816a899b2331227724127b2b6e94fe to your computer and use it in GitHub Desktop.
Print Glyph Names
let font = CGFont("fontName" as CFString)!
for glyphIndex in 0..<font.numberOfGlyphs {
let hexPart = (font.name(for: CGGlyph(glyphIndex))! as String).replacingOccurrences(of: "uni", with: "")
if let int = Int(hexPart, radix: 16) {
print(Character(Unicode.Scalar(int)!))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment