I would like to use an custom icon font for my application, so ill added the font "simple-line-icons.ttf" into my info.plist - and now i can choose it from interface builder.
When ill set the text from a label to the unicode text, like:
dateIconLabel.text = "\u{e01c}"
It shows me an icon, but not the icon from the icon set as expected.
Its an colored icon, and i dont use any colered icon sets here.
The font is definitive correct, and the unicode should work too (copied from the original css file).
Something strange is, that when ill print out all fonts for my application, the icon font is not there (but its in my list in IB).
print(UIFont.familyNames())
Any help would be greatly appreciated.
Make sure that the icon font is added to the correct target. When I added the font to my app it was not added to any target. So the icon font was not installed in the app and the system was using a default font.
You could still select the font in IB because you probably installed the font on your mac.
Add the font to the info.plist
use:UIAppFonts (Raw Value) or "Fonts Provided by application" as the key,
and the font name example Icon-Font.ttf
Validate that the font file name and font name correspond by opening ttf in font book
Related
I am trying to incorporate a custom font in my app. I am using Nova Solid created by Billy Argel.
I imported the font and set it in info.plist. When I set a label to the Nova Solid font it shows up on storyboard as the correct font:
But when I run the app, the font displays as the default font:
Every other font I import works fine, not sure if it's something with these specific fonts by Argel or something I'm doing. I will appreciate some insight/help.
This is my info.plist
There's a chance that the font file isn't added as a target, try inspecting the file and making sure it is a target otherwise the font file won't be distributed with the app.
This is a common issue when the font works in IB but doesn't work in the simulator/on a device.
I have custom font icon TTF file downloaded to the device. I also have mappings for font icon name and its font code.
A question mark is being displayed instead of font icon for some of the font code. The font code points are received from server in decimal number format. I am doing this to display font icon:
unichar decimal = [iconMap.fontCode unsignedShortValue];//fontCode is an NSNumber
NSString *charStr = [NSString stringWithFormat:#"%C", decimal];
[self.button setTitle:charStr forState:UIControlStateNormal];
Everything works fine I see the font icons but for some font code I am seeing a question mark.
In my font icon TTF file there are 369 icons ranging from font code E800 to E9A7.
Font icons are displayed correctly for font code range E800 to
E902.
But for font icons for font code range E903 to E9A7 are
displayed as question mark.
Edit : Setting direct string literal like #"\uE903" to the label also displays a question mark.
Note : I verified that all the icons (font code ranging from E800 to E9A7) are present in font icon TTF file.
I don't know what is the issue here? Please help.
Sorry, it's my bad.
I did not notice a TTF file was already added in project. The file which I was downloading from server was not getting created since name of TTF files were same. The TTF file that was already added to project was missing icons for range E903 to E9A7 and this outdated font icon file was getting used.
I was verifying the TTF file which I was downloading and it was up to date and contained all font icons. So I deleted old TTF file from project and made sure that newly downloaded file gets saved to disk correctly.
Now I can see the icons correctly.
I purchased the font icon bundle from https://symbolset.com
I copied the ss-social-regular.tff into the project.
In info.plist, I added ss-social-regular.tff under Font provided by application.
In my view controller, I created a UILabel in code, set the font as "ss-social-regular", and set the text as #"\uF610". (this is the Facebook icon. i got U+F610 by hovering over the icon in Font Book)
The result is a box with a question mark inside.
I've tried many different variations for the string set to label text, but none have worked.
In my app, I used custom fonts. It works fine for UILabels, etc...
But the Title is cut from top for Button.
"See the S"
What is happening and how can I resolve this??
try setting button.contentEdgeInsets property to align the title within the button, if it is an issue of misligned baseline of the font you can do this
button.titleLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters
a few steps:
Include your fonts in your XCode project
Make sure that they’re included in the target
Double check that your fonts are included as Resources in your bundle
Include your iOS custom fonts in your application plist
Find the name of the font
Use UIFont and specify the name of the font
detail for this:
http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/
thanks!
In my case it was the font file that was corrupted.
Try to open the ttf file in your mac, select the 'S' and see if the frame that appears cuts off the letter.
My solution was to change the ttf file.
I am experimenting with the new iOS 7 SpriteKit.
This line of code is taken from apple class reference and can be found in their sample project as well.
SKLabelNode *label = [SKLabelNode labelNodeWithFontNamed:#"Chalkduster"];
In this line the Chalkduster font is used.
I understand it's a bitmap font but how do I know what other font name I can use to replace Chalkduster?
You can also view the available fonts within Xcode itself by going to your storyboard file. You create a label there, go to the label's Attributes Inspector (the slider icon in the Utilities bar), select Font -> Custom, then scroll through the Family section to view the font list.
And here is how you would use a custom font of your own. Make sure you go through steps 1-5, then you should be able to use your custom font using [SKLabelNode labelNodeWithFontNamed:#"Font Name Here"].
Here is a list of iOS 7 installed fonts
I found that there is a very useful website showing all the available fonts on iOS. It’s iosfonts.com. The website shows how given font looks like, its name and its code name as well as the iOS version when specific font was added.
You can also log all the font names that are available as described here:
How to log names of all available fonts in iOS project.