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
Related
I added a custom Chinese font to my project, (followed the instruction here). I only want to set the font for a few buttons, but when i do this in code or in storyboard, all the other labels, buttons, textFields.. are all set to this font too. And this only happens to ios8, and it works fine on ios9. Why did this happen, can anyone help?
this is my code to set the font:
UIFont *hannotate = [UIFont fontWithName:#"Hannotate SC" size:18];
self.button1.titleLabel.font = hannotate;
self.button2.titleLabel.font = hannotate;
this is what i set in storyboard:
Updation1:
this is screenshot of my Info.plist, I have change the font name everywhere to "FHTHannotateSC".
Updation2
I printed all the fonts in ios 8 system, and found i was using the font family name(Hannotate SC) as the font name, the real font name is "HannotateSC-W5", so i corrected the font name, and run the APP again, but unluckily, the font is still global set.
I solved this problem by doing following steps:
1. Go to project target
2. Choose Build Phase option
3. Add the font files in Copy Bundle resources.
May this help you!
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.
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.
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.
I am working with custom fonts and I have applied a custom font called "CicleSemi", I have added this font in info.plist file and below is the code which I have written
DateLabel.font = [UIFont fontWithName:#"CicleSemi" size:15.0];
This works fine, for english language in my app, but for russian language , I know that this font is not available , so Xcode automatically shifts to system font and its shifting also but the issue is that the font is becoming "BOLD" but I want it normal, and I dont have any clue what might be the issue, how xcode is treating this.
So friends, if you have any clue or suggestions please let me know.
Regards
Ranjit