Equal and Unchanging Spacing between Characters in a label [duplicate] - ios
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 a monospace font available in XCode?
iOS mono-spaced fonts
Courier
Courier-Bold
Courier-BoldOblique
Courier-Oblique
CourierNewPS-BoldItalicMT
CourierNewPS-BoldMT
CourierNewPS-ItalicMT
CourierNewPSMT
Menlo-Bold
Menlo-BoldItalic
Menlo-Italic
Menlo-Regular
iosfonts.com maintain a list of all iOS fonts.
This webpage detects your installed system fonts and returns a fairly comprehensive list.
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.
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];
Expanding upon #reggie-pinkham's answer, I built this JS Bin for folks to use as a live test page; to save future reader's some time, here's a few screen shots using iOS Simulator on Mavericks:
iPad Air, iOS 8.1
iPhone 6 plus, iOS 8.1
As of iOS 13, San Francisco (SF) Mono is available. Couldn't find a way to set this in interface builder, but by code it's:
let font = UIFont.monospacedSystemFont(ofSize: 17.0, weight: .regular)
If you're looking for a monospace font for numbers, then try "Helvetica Neue".
A list of built-in fonts available on iOS: http://iosfonts.com. Courier and Menlo seem to be the only monospace fonts in there.
SwiftUI
You can use Font's instance method monospacedDigit
Text("0123456789")
.foregroundColor(.white)
.font(Font.custom("San Francisco", size: 20).monospacedDigit())
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)
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
Related
Xcode and installed SF Pro Display( Apple font )
I have an InvisionApp design with a typeface set to "SF UI Display" & "SF UI Text". I downloaded the font from apple, with an installer. It installed it in "~/Library/Fonts". I can understand that if I use "System", then it will use "SF Pro Display". My question is, how can I actively/manually use it - so it will not change accordingly and or together with iOS. I can not find see "SF Pro Display", in Xcode when I choose "Custom" font. Do you know how to use it? One solution is/could be to add the "otf" file as described here But I can see "SF Pro Display" when I use TextEdit and other Mac applications.
You don't need to manually choose between those font families (Text & Display), the system will decide which one to use. You can just get the system font which you need (size & weight) and Apple will take care about the rest :) Here is the source, explanation is between 12:30 and 13:30 in the video.
Default font(system font) for Xcode 7.3.1 is San Francisco font?
I need to use San Francisco font in my app. But I'm not sure if the default font (system font) in my current Xcode is SF font. My app is supporting iOS 7 and above and I need all OS version to use SF font. So, I want to know how can I do this? Is the default system font in 7.3.1 using SF font? I've checked in Font Book app but I didn't see SF font. Do I need to install it to use it? (like in this question: How to get San Francisco font into Xcode?) I'm using Xcode 7.3.1 with OS 10.11.2. The font is set in Storyboard, not progamatically.
Helvetica Neue was the default font for iOS 8 and prior. Apple has changed its default font from iOS 9 to San Francisco. 1) For your app If you want consistent font for all iOS versions then you have to explicitly set the San Francisco font via Storyboard or code. 2) iOS default font is based on iOS version not Xcode version. So, If you want SF fonts for iOS then then you have to install that font. Also If you want to make available that font in storyboard then you have to add that font in Apple Font Book app by double clicking on font file. (Note: Any custom font set by storyboard was not added in App then it will use the default font) 3) YES
minic iOS 7 UIBarButton font for UIBarButtonSystemItemAdd and others
I would like to generate a button or label with the same visual plus sign or icons as used in the UIButtonBar system items. Is there a way to determine what font and characters are being used to generate these items?
Breaking this into two answers: The system fonts: Helvetica Neue Ultralight is used by iOS 7, while iOS 6 uses Helvetica (or more specifically, the nearly-identical Helvetica Neue). If you are trying to make icons that look like iOS defaults, I have used http://www.glyphish.com/ successfully.
Does iOS dev has build-in fixed width font?
The font called from [UIFont boldSystemFontWithSize xx] is not fixed-width, I don't know the exact name of this system font (iOS 6). I'm wondering if there is a built-in fixed-width font? Otherwise I have to embed a new font to my app. PS: maybe iOS 7 system font is fixed-width, LOL Thanks guys.
Here's the list of built-in fonts available on iOS: http://iosfonts.com. Courier looks like the only monospace font in there.
What is a monospace font in iOS?
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 a monospace font available in XCode?
iOS mono-spaced fonts Courier Courier-Bold Courier-BoldOblique Courier-Oblique CourierNewPS-BoldItalicMT CourierNewPS-BoldMT CourierNewPS-ItalicMT CourierNewPSMT Menlo-Bold Menlo-BoldItalic Menlo-Italic Menlo-Regular iosfonts.com maintain a list of all iOS fonts. This webpage detects your installed system fonts and returns a fairly comprehensive list.
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.
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];
Expanding upon #reggie-pinkham's answer, I built this JS Bin for folks to use as a live test page; to save future reader's some time, here's a few screen shots using iOS Simulator on Mavericks: iPad Air, iOS 8.1 iPhone 6 plus, iOS 8.1
As of iOS 13, San Francisco (SF) Mono is available. Couldn't find a way to set this in interface builder, but by code it's: let font = UIFont.monospacedSystemFont(ofSize: 17.0, weight: .regular)
If you're looking for a monospace font for numbers, then try "Helvetica Neue".
A list of built-in fonts available on iOS: http://iosfonts.com. Courier and Menlo seem to be the only monospace fonts in there.
SwiftUI You can use Font's instance method monospacedDigit Text("0123456789") .foregroundColor(.white) .font(Font.custom("San Francisco", size: 20).monospacedDigit())
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)
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