how to use corbel and calibri font in Xcode - iphone

i need to use corbel and caliber font in textview , textfield and label in my new application. I have searched for it in google but i did not got any solutions . Can any one please help me. Thanks in advance.

Follow these steps:
1) Add desired fonts to Xcode as resource.
2) Open info.plist file. Now create a key called UIAppFonts and make it an array. Add the filename of the font as a value.
<key>UIAppFonts</key>
<array>
<string>corbel.ttf</string>
</array>
3) Save info.plist FILE.
4) To use the font in your application add this line.
[UIFont fontWithName:#"corbel" size:32.0]
Courtesy :
Can I embed a custom font in an iPhone application?
CUSTOM FONTS IN IOS.
P.S. But to determine the exact name of font put temporary line of code as even small case sensitivity might cause a problem loading fonts.
NSLog(#"%#",[UIFont familyNames]);
This will print names of all the fonts on the device. Find the one that matches your font.Whatever the font name you get use it in the line in Step 4.
Courtesy: How do I include a font with my iPhone application?

You can add custom fonts to Xcode, I think this article can help you out doing so. I also found this video. As for the caliber and corbel files, a quick search in google will get what you want: corbel caliber tff.

Install same font in Mac OSX and try to find same font name in textedit application.
type exact spelling (with case sensitivity) in Xcode.
some time it happens font file name is different and we type it differently.
put the exect file name in plist file... but use the installed font name in application (Xcode.)

Related

font suitcase to ttf issue

I used Mac OS Font Book to export fonts from it. I got 2 fonts files: Font Suitcase and PostScriptType.
Then I want to use these fonts in my iOS application, but to do that I need to convert them to, for example, ttf. But how?
May be someone faced this problem?
Important:
I don't need advices how to use custom fonts (such as ttf), I need advice how to use Font Suitcase and PostScriptType of fonts (may be how to convert it to ttf)
This solution doesn't require Fondu or Rosetta, but it does involve a little cut-and-paste into macOS's Terminal app.
Pretty simple, and free. And it works on macOS Mojave.
https://sittingduck.co.nz/2013/11/unpacking-the-suitcase/
Try to use these steps.
1) Add your custom font files into your project using Xcode as a resource
2) Add a key to your Info.plist file called "Fonts provided by application".
3) Make this key an array
4) For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array
5) Save Info.plist
6) Now in your application you can simply call [UIFont fontWithName:#"CustomFontName" size:12] to get the custom font to use with your UILabels etc…
Also: Make sure the fonts are in your Copy Bundle Resources.

Using a custom font in Xcode

I'm trying to use a custom font (Sassoon Infant) in Xcode. Despite looking at the numerous posts here on this issue, i haven't been able to resolve the problem.
These are the steps i have taken so far.
Added font to resources
Added font to Font Book
Added SassoonInfantCom-Regular.ttf to Fonts Provided by Application
Tried using fontWithName:#"Sassoon Infant Com", the name in Font Book
Also tried just #"Sassoon"
The font name is not showing up in IB either under the dropdown font menu. The above seems to work for most people but i can't get it working. Anyone have any ideas?
Remove the extension .otf / .ttf from the file and the plist.
Also make sure you are editing the correct plist file for the "Fonts provided by application property"! I spent two days trying everything to make some custom fonts work. Then I realised I was editing the APPTest-info.plist (which is in the resources folder of the Tests folder in XCODE) instead of editing the APP-info.plist file!
In my defence, both files are really close to each other in the files navigator in Xcode... ;-)
I just added it into the bundle and did this
myLabel.font = [UIFont fontWithName:#"MyCustomFont" size:19];
MyCustomFont being a .ttf file.
Hope this helps.
Make sure that the font is added to your target. Select the font and check the target membership in the left Xcode sidebar.
Make sure that you got the correct font name. Open the font in "Font Book" and see its name.

Add Custom Fonts In Xcode 4.1

i want to use custom fonts in y application.
i have declared the "Fonts provided by the application" in the info.Plist file
and set the label.font to the font with name with / without the .TTF extension
draged the TTF file in to the project and copied the file to the project
created an outlet to the label but still, nothing works.
if someone knows what is going on over there i would like to get some help.
recently i have noticed the this problem are known # the 4.1 (xcode version).
TNX :)
The font name isn't the name of the file. What you want to do is double click on the font in Finder.
This should open it in Font Book like this image
The font name you want is the one in the title which I've highlighted so attractively in red.
I just spent a big chunk of my day trying to figure my problem out... what I missed was, when I dragged the .ttf file into xcode, I did not select my app's name under "Add to target:" section.
Even though it seemed as if the file was in the correct directory and what not, it wasn't recognising it under the family names, using this code:
NSLog(#"FONT FAMILIES\n%#",[UIFont familyNames]);
So hopefully this can help someone if they're stuck.
The above advice did not work for me, so I wanted to share what did:
Opening the font in Finder gave a long name that did not work (TypeWrong Smudged - DGL), but when I looked for the same font in the Photoshop font list it showed the name as just TypeWrong, which did work. So if Finder shows a long name with spaces in it, you might want to try just using the first space-free chunk.
You have to check what is the font name it is at times different from font file name...
check this link

Has anyone had success using custom otf fonts on the iPhone?

It looks like there a few working solutions for using custom true type fonts (ttf) on the iPhone, most notably Can I embed a custom font in an iPhone application? However, this method does not support open type fonts (otf).
Has anyone come across a way to make use of otf typefaces?
For my own project I wanted to use the opentype font and I basically used this method:
Add your custom font file into your project using XCode as a resource
Add a key to your info.plist file (Fonts provided by application)
For each font you have, enter the full name of your font file (including the extension)
save info.plist
then use this for your labels (ex:)
UIFont* font = [UIFont fontWithName:#"Harrowprint" size:20];
In my case #"Harrowprint" was the filename without the extension and not the font name provided by Finder.
My font was an otf and it worked...so I guess it's supported...or I was lucky. I'll test another font..and keep you posted..
references:
http://blog.beefyapps.com/2010/06/custom-fonts-in-ios-4/
Can I embed a custom font in an iPhone application?
Must you use an otf font on the device or can you convert it to ttf? It is relatively straightforward to convert an OTF font to a TTF font using a tool such as fontforge, perhaps that would be an easy solution.
I had trouble with this, too. Here is what worked for me:
Copy the font files into the Resources.
Check to see that the font files are in 'Build Phases'->'Copy Bundle Resources' (Xcode put them there for me when I added the files to the Resources. If, for some reason, they are not there, add them.
Add the filenames to your info.plist file as describe above. Include the extensions.
Open Font Book, select your font and Preview-Show Font Info and look at the 'Family', e.g., 'Foo'
Put this in your code somewhere and set a breakpoint to check the array of names: NSArray *names = [UIFont fontNamesForFamilyName:#"Foo";
Run your app and when it breaks, right-click on the 'names' variable in the debugger. This will show you the font names to use, e.g.: <__NSCFArray 0xe9c4da0>(
Foo-100Italic, Foo-100 )
Note that my font names were not shown
correctly anywhere else, not in the filename nor in Font Book.
You should be good to go with:
myLabel.font = [UIFont fontWithName:#"Foo-100Italic" size:24];
This article answers your question (it worked like a charm for me using OTF):
http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/
OTF is perfectly supported, no need to convert to TTF
With regards to the first answer - the solution is correct (i.e. just convert the font over to TTF) but the software suggested is a super hassle to compile and install. Instead I just did a quick google search and used this instead: http://www.freefontconverter.com/ and that worked perfectly.
(Make sure to add the font to your info.plist file as well)
I researched this throughly, and this is the best method I found:
1) Convert font file to TTF using this online tool: http://www.freefontconverter.com/
2) Add the TTF files to your project
3) Make some configurations to your info.plist file:
3.1) Edit info.plist as source code (right click on file -> open as -> source code)
3.2) Add this:
<key>UIAppFonts</key>
<array>
<string>font1.ttf</string>
<string>font2.ttf</string>
...etc...
</array>
3.3) Your info.plist should have this now:
4) Use the new fonts just like the system fonts:
[UIFont fontWithName:#"font1" size:16.0];
(Notice no ".ttf" in the font name)
You should use the font names, not the font file names. To get the font names, run
for family in UIFont.familyNames {
print("font family", family)
for names in UIFont.fontNames(forFamilyName: family) {
print("font name \(names)")
}
}

How do I include a font with my iPhone application?

I've already seen this post:
Can I embed a custom font in an iPhone application?
which is helpful, but I'd love to simply load the font via:
UIFont* font = [UIFont fontWithName:#"Harrowprint" size:20];
Some people have reported this possible but it's not working for me. Can someone confirm how to bundle a custom font with an iphone app?
Also, in the aforementioned post, one answer notes: The "name" of the font is not necessarily the filename.
How do I determine the "name" of the font that would be recognized by UIFont? It's possible i'm not using the correct name.
There are several steps you need to take:
1) Make sure you have the rights to distribute the font. Most fonts -- even free ones -- do not allow you to distribute them. Putting them in your app most likely consitutes 'distribution' and would be considered illegal.
2) Copy the font to your Resources folder in your app. Make sure it's in your Copy Files build phase.
3) Add a "Fonts provided by application" key to the plist file, and add the complete file name of the font (including extension)
4) Get the 'name' of the font by putting in a temporary line of code:
NSLog(#"%#",[UIFont familyNames]);
Build and run the app. This will print to the Console the family names of all the fonts on the device. Find the one that matches your font.
You can then use that font name in the fontWithName: method.
To add onto August's answer above, you need to add a "Fonts provided by application" key to the plist file, and add the complete file name of the font (including extension). Then the font will appear in the family printout and you can use that name to set the font.