Can I preload custom fonts on iPhone to improve performance? - iphone

I've added the UIAppFonts entry on my info.plist to enable custom ttf fonts, it works fine. However when using the font there's also a delay in the UIView the first time it's called, is there a way to preload the fonts or some other technique to avoid this?
Thanks

In your application delegate or some other place that is called when the application launches try creating a hidden UILabel that uses your custom font and remove it straight away. That way it will preload the font so that the next time you use a UILabel with that font it won't pay the first time penalty.

Related

How to replace the default font for the whole OS

Is there a way to make my app override the current font of the currently foreground application?
What I have in mind is no matter which app is on foreground my app to be able to attach a button to the keyboard which will switch the font to a custom one thus overriding the current font for all ui elements(labels, buttons, text fields etc.).
What you're looking for is not allowed by Apple.
It seems it can be done for jailbroken devices though. It's difficult to tell how exactly they're doing it but I guess they meddled around with the images/colors provided by Apple for the keyboard and replaced them with their custom ones leaving the default un-recoverable.
Here's a blog about it too.
You can create a category on UIFont and replace systemFontWithName:size: and boldSystemFontWithName:size: with your own font. But this may have some weird side effects, as even alertViews and actionSheets are customized with that method..
edit: of course this works only in your own app.. you cannot change anything outside of your app.

adding text to image within image picker

hello i am creating an iOS app using cocoa and xcode
i am very new to the whole thing and have gotten kind of lost.
in part of my application the user must choose a picture from the library or using a camera, then some text is added to it(just like "id cap that").
the question is where would i add the text and how do i save it to the phone?
i know there is a allowsImageEditing property, the question is how to i edit it so that instead of crop and zoom it will add text and have an option of saving.
thank you
The system determines what kind of editing is allowed. You can only tell it whether it's allowed or not, but you cannot choose what type of editing. If you want to add a caption to an image, you'll have to use Core Graphics to do so. Or, if you don't care about the image being saved with the caption on it, you can simply use a UILabel on top of a UIImageView.

CTFontCreateWithName returning ".LastResort" font

I have multiple custom fonts provided with my app, all defined in the app's plist correctly. I can load UIFonts with those custom fonts with no problems. UILabels using [UIFont fontWithName:#"some-custom-font" size:14] as font work flawlessly.
What doesn't work is CoreText methods.
I need to use those fonts in attributed strings, so I absolutely need the CTFontRef. Till iOS 5 I had no problem what-so-ever. Now, CTFontCreateWithName tends to return a font called .LastResort, instead of what I need. If I kill the app and relaunch, some of the fonts that failed last time do work now, but others don't. Seemingly random. If I call CTFontCreateWithName immediately on app launch, that specific font works later, but again most of the others do not.
I never encountered this kind of behavior before. My app isn't very memory heavy. This feels like some iOS 5 bug. Any help or advice will be very welcome.
I've only used custom fonts via UIKit. You may want to contact DTS, or definitely bugreport.apple.com

is it possible to add images in between the text view in iphone

I'm developing an application. It consists of notes and images also. I'm unable to find the best way of coding to add images and text together.
I want to add the images between the textview and after that, the text has to continue. Is it possible to do like this?
You will probably be better to use a webview and load in some static html from the application unless you particularly need textviews, in which case look at holding things in UITableView

UIButton resizes when I change font?

I have several UIButtons, I'm trying to bulk change the font for all of them in InterfaceBuilder, but when I change the font, they auto-resize to the original image dimensions instead of what I had them set to, screwing up the layout. I would like to avoid having to resize and move everything around again any time I change the font. I could just set the font in a loop in code, but it seems redundant.
Is there a setting to stop this from happening?
This issue doesn't seem to occur in Xcode 4.0 or above.
Should anyone still be using a lesser version of Xcode I would suggest updating.