I want a monospace font for my UILabel in my iOS application.
Unfortunately, I could not find one. Even \"American Typewriter\" was not actually monospaced. What is
In the meantime there is a good Monospace font available from Apple, that can be downloaded here: Apple SFUI Here is how to add the fonts to Xcode: Add fonts to xcode
A list of built-in fonts available on iOS: http://iosfonts.com. Courier and Menlo seem to be the only monospace fonts in there.
You can access system fonts in monospaced with the following Font
factory method:
static func system(Font.TextStyle, design: Font.Design) -> Font
Example:
let monospacedBody = Font.system(.body, .monospaced)
Other usage:
let serifTitle = Font.system(.title, .serif)
If your intent is to display numbers and you don't care about the specific font used, you can do this:
UIFont.monospacedDigitSystemFontOfSize(
UIFont.systemFontSize(),
weight: UIFontWeightRegular)
Adobe just released a nice monospaced font Source Code Pro in both TTF and OTF formats. It's licensed with the Open Font License so it is available for free use within applications, including commercial applications. You will need to add the font file as a resource in Xcode, by setting the UIAppFonts key in the info.plist to point to the SourceCodeProRegular.ttf file.
Now in your code you can set, for example:
self.textView.font = [UIFont fontWithName:@"Source Code Pro" size:14];
Looking at an old listing of fonts shipped with iOS I see several one monospace fonts.
(eg. Andale Mono, Monaco, Courier New)
For 2018 it's only Menlo and Courier.