Custom font not showing up - ios

I tried to modify a UILabel with a custom font, and it works if I use BPREPLAY instead of BPREPLAYITALICS
Both custom fonts are added the same way inside the project and are declared in the info.plist in Fonts provided by Application:
[_all setFont:[UIFont fontWithName:#"BPREPLAYITALICS" size:37.5]];
_all.textColor = [UIColor colorWithRed:(170/255.0) green:(170/255.0) blue:(170/255.0) alpha:1] ;
_all.text = #"All";
Now, when I use the Italics font it does only show the font I used in the storyboard, unlike with the other font style.

Ok so I got it working now, credits go to
Italic Font Is Not Working on XCode
I had to look into the full file-name. The solution was to use
UIFont fontWithName:#"BPreplay-Italic" which I found in the information about the file itself.

Related

How to display icon using font ? ios

I got a file(please find attached file) which contain font, this font supposed to display icons according to code number.
but i didn't succeed to display any icon with this font. here is my code:
iconTest = UILabel();
iconTest.frame = CGRectMake(0, 0, 100, 100);
onTest.center = self.view.center;
iconTest.font = UIFont(name: "icomoon", size:16.0);
iconTest.text = "e906";
what's the correct way to display icons using font !
download font svg file
You have to set text property like:
iconTest.text = "\u{e906}";
Do not forget to register your custom font in your app.
Follow these steps:
Install fonts by double clicking on them.
Drag and drop fonts in Xcode and make sure they are added to target. (check copy items if needed)
In info.plist, set key Fonts provided by application and add font name for item(under key)
Set font type custom in storyboard for your controls or programatically assign font to UILabel
Code:
//In swift 3
let font = UIFont(name: "iconmoon", size: 15)
btnSignout.setTitle("\u{e913}", for: UIControlState.normal) // set font icon on UIButton
btnSignout.titleLabel!.font = font
// In objectiveC
_lbl.text = [NSString stringWithUTF8String:"\ue92e"]; // set font icon on UILabel
_lbl.font = [UIFont fontWithName:#"iconmoon" size:16];
Note: \u prefix is mandatory, Example for unicode e626, the label text should be \ue626 or \u{e626}
I use icon font in some of my projects. I have create a project to use icon font easily. The README of this project is written in Chinese. But the demo project will show everything clearly. https://github.com/JohnWong/IconFont
Icon font is always used in UILabel by setting text. But I think creating a UIImage from font is more flexible. This is why I create this project.
Method of register font by setting project is in answer provided by martin. Here is a way to register font by code: https://github.com/JohnWong/IconFont/blob/master/IconFont/TBCityIconFont.m#L16
Icomoon.swift: Use your Icomoon fonts with Swift - auto-generates type safe enums for each icon.
Despite it's not IcoMoon, this library is worth noting:
https://github.com/0x73/SDevIconFonts
It integrates FontAwesome, Ionicons, Octicons and Iconic as Icon Fonts.
Assign them with code as easy as:
label.font = UIFont.iconFontOfSize(.FontAwesome, fontSize: 50.0)
label.text = String.fontAwesomeIconWithName(.Twitter)
As noted before, you have to register the font files in your app's Info.plist.
Anyway, regarding IcoMoon: I would use the above library as a starting point. Should be fairly easy (*) to add IcoMoon in a fork (or better as a pull request).
(*) technically spoken, adding a list of convenience shortcuts like .Twitter is quite an expensive task when I have a look at https://github.com/0x73/SDevIconFonts/blob/master/SDevIconFonts/Classes/FontAwesome.swift.

How do i add in a custom font into my iOS app?

Before Xcode updated to v7, there used to be a font which i used for my app called Heiti SC. After the update the font just disappeared. Now I have to figure out where i can download this font and how i can put it into my app. Could somebody point me in the right direction?
From here you can download the font
http://www.free-fonts.com/heiti-tc-light..
After downloading add the folder(.ttf format) to supporting files in the project.
Then Edit info.Plist like this
Fonts provided by Application take as array
Item 0 as Heiti SC.ttf
now you can set
label.font = [UIFont fontWithName:#"Heiti SC" size:15];
In addition to the answers that have already been given here:
(check this link how to add custom font ios)
Check the buildphase if the font has been added correctly. If you don't see your font here, just drag and drop it inside.

Using styles of the iOS system font other than Regular in code

At the moment I know I can use [UIFont systemFontOfSize:15] to set the font of a UILabel to the system font. But how would I retrieve the medium style of the system font programmatically? There only seems to see a method with the regular style of the font to be applied.
At the moment I can only seem to use these fonts in IB:
You can use +systemFontOfSize:weight:, with one of the font weight constants from UIFontDescriptor.
Or, perhaps more appropriately, preferredFontForTextStyle: which respects the user's settings.

Use BPReplay (font) in iOS app

I want to use the font BPReplay for my iOS app. How can I add it and does it work?
Thanks for help
You need to do the following.
Add a property Fonts provided by application in your APPNAME_info.plist
Add items under it and put the name of your font against each item as shown in the picture
Use the font in your app like this
UIFont *yourFont = [UIFont fontWithName:#"Century" size:28];
[SomeLabel setFont:yourFont];
Hope this helps

How to Import the Font in xcode for Iphone Application [duplicate]

This question already has answers here:
Can I embed a custom font in an iPhone application?
(32 answers)
How to include and use new fonts in iPhone SDK?
(9 answers)
Closed 8 years ago.
I am import the font in my app folder.
Then i added font in info.plist file.
Like..... Fonts provided by application--->add two font.
Then set the font to title.After create the UILabel to set the font. Like this
self.title = #"Home";
CGRect frame = CGRectMake(0, 0,100, 44);
label = [[UILabel alloc] initWithFrame:frame];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:#"Benguiat Gothic" size:9];
label.textAlignment = UITextAlignmentCenter;
self.navigationItem.titleView = label;
label.text =self.title;
This code written in viewdidload method.
But the font is not changed.its appear only default font for that label.
1 Add your custom font into your project , i.e. Dragged the font file(CALIBRIZ_0.TTF) into XCode project.
2 Edit Info.plist: Add a new entry with the key "Fonts provided by application".
3 For each of your files, add the file name to this array
4.Opened the font in font book(double click on your font in finder) to see what the real filename is and I see this:
Now set font to your label
yourLabel.font = [UIFont fontWithName:#"Calibri" size:15];
First download your relevant font
Add your custom font into your project , i.e. Dragged the font file(Berlin Sans FB.TTF) into XCode project.
Add a new entry with the key "Fonts provided by application".
Now use this font in your textview
txtview.font = [UIFont fontWithName:#"Berlin Sans FB" size:15];
i used Berlin Sans FB you use your teleugu font
for more detail check this link
Using a custom font in iOS requires a few steps:
Have access to the TTF or OTF file for the desired font.
Drag the TTF or OTF font file into your Xcode project.
Located the application's Plist file and add a new row with the key "Fonts provided by the application.
Make sure that the associated value in the Plist perfectly matches the naming of the dragged in font file.
In your code, you can now assign the custom font to be used with your label, textfield or any other control that has the font property.
[myLabel setFont:[UIFont fontWithName:#"Benguiat Gothic" size:12.0f]];
Or, if you prefer dot notation syntax
myLabel.font = [UIFont fontWithName:#"Benguiat Gothic" size: 12.0f];
There's a few things to take into consideration. The actual naming of the Font File may not always be what you have to pass in as a string literal. Some custom fonts may have different weights associated with it (Light, Regular, Medium, Bold, Italic Bold etc). If the font isn't displaying as you would expect and all steps above have been explicitly followed then it could be down to the string you're using in your code.
You can get the list of font family names in debug by logging out as so:
NSLog (#"Font families: %#", [UIFont familyNames]);
That should give you a decent indication of what to actually use in your code when defining the custom font for use with the label.

Resources