Instead of the plain vanilla
systemFontOfSize:
in the
Hello
project,
you can install a font from the web.
http://www.dafont.com/
to choose a font.
For my example I chose to download:
http://www.dafont.com/aez-wedding-dings.font
.
The file you want looks something like
AEZweddingdings.ttf
.
This is a true type font (ttf).
I suspect you can also do for an
open type font (otf).
.ttf
file) into the Supporting Files folder of the project.AEZweddingdings.ttf
in the 'Copy Bundle Resources' listed under 'Build Phases' under your
target.
To confirm this,
select the project in the Xcode Project Navigator,
select the TARGET in the left pane of the Xcode central panel,
and scroll down to Copy Bundle Resources.
Projectname-Info.plist
file in the Supporting Files
folder,
you must add a
row for 'Fonts provided by application'.
The value needs to be the name of the
.ttf
file referenced above; in our case,
AEZweddingdings.ttf
.
fontWithName:size:
method of class
UIFont
to utilize the font in our app,
however, discovery of the name is tricky
for this method of import.
I utilize the following to print out the fonts available to make sure
the new font is there:
NSLog(@"%@", [UIFont familyNames]);There probably is a better way to figure out the name in a font tool or within Xcode, but this works.
UIFont *importedFont = [UIFont fontWithName: @"AEZ wedding dings" size: 28.0]; [@"abcdefg" drawAtPoint: CGPointMake(0, 0) withFont: importedFont];The string concatenation is pretty self-explanatory. The only odd step was when creating the new file, you select category.