Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a font with +fontWithName:size: and specify both the font family name and the specific style information for the font?

The docs say:

+ (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize

The fully specified name of the font. This name incorporates both the font family name and the specific style information for the font.

The examples I find only specify a font name. But I want to specify other attributes as well such as medium font weight etc. How is this encoded into the name?

like image 917
Proud Member Avatar asked May 01 '12 15:05

Proud Member


People also ask

How do I create a font family in CSS?

In CSS, we use the font-family property to specify the font of a text. Note: If the font name is more than one word, it must be in quotation marks, like: "Times New Roman".

How do you type a font family in HTML?

To change font type purely with HTML, use the CSS font-family property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.

Which of the following is an example of a specific font family?

There are two types of font family names: family-name - The name of a font-family, like "times", "courier", "arial", etc. generic-family - The name of a generic-family, like "serif", "sans-serif", "cursive", "fantasy", "monospace".

What are the 5 font families?

In CSS (and in typography in general) there are five basic types, or families, of fonts: serif, sans serif, cursive, fantasy, and monospace.


1 Answers

See this answer for naming scheme. Full font list (with names) can be found here.

Example:

[UIFont fontWithName:@"HelveticaNeue-Bold" size:15.0];

Update

iOS 8.2 added this method for fetching system fonts of different weights.

Example:

[UIFont systemFontOfSize:15.0 weight:UIFontWeightBold];
like image 65
jnic Avatar answered Nov 12 '22 05:11

jnic