Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the System font in an iOS app?

I am using Xamarin Studio to develop an iOS iPad app. I need to assign the System font name to a variable in the code behind on one of the pages.

How do I get whatever the System font is programmatically?

like image 860
Dave Haigh Avatar asked Oct 08 '13 09:10

Dave Haigh


People also ask

What font is system font iOS?

SF Pro. This neutral, flexible, sans-serif typeface is the system font for iOS, iPad OS, macOS and tvOS. SF Pro features nine weights, variable optical sizes for optimal legibility, four widths, and includes a rounded variant.

Can you change system font on iOS?

To manage installed fonts, go to Settings > General, then tap Fonts.

How do I get fonts for my apps?

To install a custom font on Android, obtain the TTF file of the font you wish to use and also download the zFont app. Use the zFont app to install the TTF. It may require some prerequisites and the app will help you do it.

What is a system font?

A system font or web-safe font is one that's already assumed to be on the vast majority of users' devices, with no need for a web font to be downloaded.


2 Answers

NOTE: Before somebody thinks he has to change this answer: This is answering a question about Xamarin.iOS and not ObjectiveC. The API really uses uppercase properties and method names.

Create a system UIFont and read its properties:

var font = UIFont.SystemFontOfSize(10);
string familyName = font.FamilyName;
string fontName = font.Name;

See also Apple's reference for UIFont.

like image 139
Krumelur Avatar answered Oct 27 '22 20:10

Krumelur


Starting with iOS7, you have a richer way of getting the font, using the new UIFont properties.

For details see:

http://tirania.org/monomac/archive/2013/Sep-25.html

like image 34
miguel.de.icaza Avatar answered Oct 27 '22 19:10

miguel.de.icaza