font suitcase to ttf issue - iphone

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.

Related

how to use corbel and calibri font in Xcode

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.)

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.

iPhone Custom Fonts with Font Suitcase

I am attempting to use a Font Suitcase for a custom font in an iOS4 app but am not having any success.
I have read other posts that have documented how to use custom fonts, so have copied the suitcase into my project, added it to resources and the Info.plist '
Fonts provided by application' array, and attempted to use it both in Interface Builder and in code. But it doesn't work!
All examples I've found regarding custom fonts show using them with ttf or otf files, but nothing with a suitcase. Can it be done? If not, how do I get something out of the Font Book into a file structure that can be used as a custom font?
I had the same problem and just solved it. Friend gave me a couple of fonts zipped, I unzipped and then the file sizes are zero kb and I couldn't install them into Font Book.
So I googled and found out that my friend should have used StuffIt Expander to zip. So he sent me the file again, and I used StuffIt Expander to unzip. I was then able to install the fonts into my Font Book.
However, the fonts are still not usable in my iOS app. So below is what I did:
I found out I need to convert the font, so I installed Fondu
http://fondu.sourceforge.net/
The installation ended up saying not successful, but later I was still able to use.
Then I realise I need Rosetta to run Fondu, so I looked at the instructions on this page.
Got my Snow Leopard CD out and install optional package
http://www.macobserver.com/tmo/article/snow_leopard_installing_rosetta/
Open Terminal and go to the directory where your font is. Type the command:
fondu [font file]
Then you will get a prompt asking if you want to save [font file].pfb
Choose yes.
Now in your XCode, add the pfb file into your project. Then go to info.plist and add the file to UIAppFonts (include the .pfb extension).
I tested the font in a UITableViewCell
cell.textLabel.font = [UIFont fontWithName:#"[font file]" size:30]; // do not include .pfb extension
And the font is showing up fine. I initially thought iOS will require a .ttf file but looks like .pfb is fine also.
Hope this helps.
Additional testing tips:
Once you add the UIAppFonts plist array as shown above add a breakpoint in your appDidFinishLaunchingWithOptions method and at the console type
po [UIFont familyNames]
That gets you a list of installed fonts so search for your font family name. Copy that and paste it into this:
po [UIFont fontNamesForFamilyName:#"familyname"]
This gets you the font name you reference in your code. I've not tried the [font filename] approach but this gives you the name the app uses to reference the exact font you want. This is important when a font contains a series of variants or you have multiple installed from the same family. For example helvetica has four variants so you can pick the right one this way:
lblMyLabel.font = [UIFont fontWithName:#"fontname" size:lblMyLabel.font.pointSize]
E.g.
lblMyLabel.font = [UIFont fontWithName:#"Helvetica-Oblique" size:lblMyLabel.font.pointSize]
This keeps the font point size you used originally for the label. I've also only had success once the view is loaded.
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.
https://sittingduck.co.nz/2013/11/unpacking-the-suitcase/
First of all include SystemConfiguration framework to your project. And also add ttf or otf file as per your requirement. Then import dlfcn.h file to delegate implementation file. And you have to call the function after that as attached in the image.
And then you can access in your controller wherever you want to use the custom font. You need to just pass font in fontwithName: method of UIFont.

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.