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.
Related
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
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
I try to custom fonts like I used to do in XIB,after upgrade Xcode to 7 ,
I cannot find STHeitiSC in the font list?
Is it deprecated?
Sadly, it is no longer a supported IB font. See my issues with it here : Xcode 7 iOS9 font no longer recognized
This font is usually reserved and intended only for Chinese text. However, you can still import the font to your project, add it to your plist and perform accordingly as any other custom font would.
In my app I need to support iOS since iOS 7. As you know iOS 9 uses new system font "San-Francisco".
Is it possible some how to use system font (to make native font for operation system) with setting size and attributes like Light, Medium, Bold, Italic, etc?
I found only one solution to hard code font name as for iOS 9 use "San-Francisco" and for less use "HelveticaNueue".
Maybe some one know a better solution.
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