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
Related
I'm using cocos-builder to create my view which contains a CCLabelBMFont, the font is set correctly in cocos-builder. But each time I run the app it crashes in the setFntFlie: because it isn't able to find the font file.
I've checked my simulator and it contains the .fnt and .png files.
Any ideas?
Ok so I figured out that the problem is with cocos-builder. For some weird reason it isn't able to find the font files in the bundle, but if I use CCLabelBMFont directly it works fine. Any ideas on why cocos-builder behaves weirdly ?
Please check whether the membership of these files are included in the target.
1. Select file on right side pane.
2. Select the target.
I'm trying to use this font in my app. I've added it to the plist and to the project, but for some reason it is not loading on the label. I've tried to verify the font in the project with:
NSLog(#"DK Crayon Crumble: %#",
[UIFont fontNamesForFamilyName:#"DK Crayon Crumble"]);
But I'm getting this output:
DK Crayon Crumble: ( )
I found the problem. For some reason Xcode it was not copying the font file to the bundle package.
The convention with the built-in fonts (you can select them in Interface Builder) is that you eliminate the spaces and add the attributes after a hyphen, such as
#"HelveticaNeue-Bold"
for Helvetica Neue, Bold.
I don't know the exact name of your font but if you follow this scheme, it should work.
Some times the fonts are visible in the project file but are not actually
added to the target to do so
click on the project's name -> click on target -> Build Phases, go to
'Copy Bundle Ressources', if the concerned font(.ttf extension) file is not there add it to the list.
Clean your Project and run you should be able to see the font.
Maybe the problem is that the name of font is with space. Remove spaces, in real file name, add it again to your plist and try again with code:
[UIFont fontNamesForFamilyName:#"DKCrayonCrumble"];
This link help you to set font:
set custom font
So I'm having a couple of problems actually. The first is that I want to use a "Font Suitcase" file as a custom font in an iOS app and haven't been able to get it to work. Not only that, but I haven't been able to properly use a .ttf file either. Here are the steps that I've taken to try and make it work:
Imported the file into my supporting files in xCode.
Added the file name, e.g. "badaboom.TTF" into the Info.plist file
Called UIFont *myFont = [UIFont fontWithName:#"Badaboom" size:20.0];
I also used the code found here to see if the font was even being loaded and it doesn't appear either. This applies for both ttf and font suitcase files.
Any idea what I'm doing wrong?
Thanks,
Pete
You have to add your fonts as resources.
So do the following steps:
Go to your project settings
Select your target
Go to Build Phases
Add the custom font to Copy Bundle Resources
With this and the code you posted you should now be able to load custom fonts
Double click on the TTF file in Finder. Look at the title bar. The name inside preview has to be exactly the same as what is in your quote [UIFont fontWithName:#"" size:20.0];
It's case sensitive.
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.)
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.