can I use a downloaded font asset in an iOS app? - ios

I want to use fonts in my app that I've downloaded from my server. I may have a font at some point that I haven't bundled with the app but I want to use; is there a way to download it (well, that's the easy part) and then load it and use it in a view?

It is an old question, but things are changed. The answer is yes since iOS 6.
Here is Apple's example:
https://developer.apple.com/Library/ios/samplecode/DownloadFont/Introduction/Intro.html

You have to "notify" your app about which fonts you intend to use by adding them to the "Fonts Provided By Application" entry in your info.plist file. It is bad practice and for all intents-and-purposes wrong to edit this file at run time. Thus, all fonts that your app will use need to bundled with it at compile time and shipped along with the application.

No, fonts have to be in your application bundle and registered with your Info.plist at compile-time.
If you really wanted to use a font that you downloaded, you could try converting it to a series of images and compositing them together, but that would be pretty hacky.

Related

How to use custom fonts in a property list file?

I use a third-party SDK in my iOS app which requires me to define the fonts I wish to use in a pre-defined .plist file. I have been using Lato-Regular all throughout the app but it seems I cannot use the same in a property list file for some reason. Is there any to achieve this?
P.S. I have checked and rechecked for the name of the font so that's not the problem.

iOS 8 App Extension and Host App in separate project files. Is it possible in Xcode 6?

Currently we're using premake5 to generate our project files, as we develop multi-platform. Obviously we don't need premake to know anything about the extension (as it's iOS8 exclusive feature) but we're facing a problem: Every time we regenerate the main app project file (which happens sometimes) we're forced to manually add all the files and configure the extension, which is dull and error-prone.
Is there a way to add the app extension (a Today Widget) to a separate project? Pbxproj files aren't version control friendly as its contents seem to be shuffled every time you save. So, saving a patch file with all the changes needed doesn't seem like an alternative.
I know this is a broad question about a convenience issue, maybe seasoned Xcode devs know some trickery (or maybe it's just something obvious we're missing here).
Thanks all in advance.

How to automate the creation of bundles for an iOS application?

My iOS app uses data that is packaged by theme into theme bundles. For example theme_math.bundle, theme_history.bundle, etc. A theme bundle contains a .sqlite file and images. The idea would be that those bundles can be downloaded when necessary by the app (theme_x.bundle.zip).
There are hundreds of themes that are stored in a database, and I'd like to automate the process of creating a bundle for every theme with the appropriate name.
Is this approach fine to deliver application content to an iOS app?
If using bundles is fine, how can I automate that process?
This would appear to be a fine idea. You can automate this by creating a shell program file, or use some other scripting language (python, ruby, etc).
A bundle is really just a folder that gets special treatment. It can have an icon when viewed in the Finder, etc. So your high level program will create a bundle (mkdir Name.bundle), then copy whatever resources you want into that directory - Name.bundle. When you're done zip the bundle up, and put it where it can be downloaded.
Bundles often have a plist inside with special flags set (as an executable on OSX does), but don't think you need this.
Its possible that you may need to set some special bits on the bundle for iOS to recognize it - I really don't know for sure. If so see this thread.

Can PhoneGap be used in apps built with theos?

I want to use PhoneGap to make a Cydia app, however the iOS instructions on their website only show how to use it with Xcode.
I don't have a Mac, but I'd like to be able to make my app for Cydia, with theos. Is this possible with PhoneGap, or is it only usable with Xcode?
I've never done this, but YES it should be entirely possible. The Xcode instructions set it up for you to have a specific template with all of the phonegap files already in the proper locations. So it's easy to get going. But it doesn't do anything else that is particularly special. Theoretically you could simply setup all of the files in a theos project.
To do this you will need to 'reconstruct' exactly what goes into a phonegap template. I have no experience with theos, but a rough idea of what you will need to be able to do includes the following:
Import PhoneGap.framework
Reconstruct AppDelegate code
Import Supporting Files (PhoneGap.plist)
Additionally you will need to configure the folder structure with the www folder (that the webview loads from) including the index.html file and the phonegap-1.0.0.js file.
So yes, it should be possible. Let me know if you are successful. Good luck!

iphone multilanguage support

I'm developing an Iphone app that has to support different languages.
I saw that the language has to be set within my app and not within iphone settings. So, do I have to force the language instead to take the current one? I didn't find examples over the internet. All examples need the current language of the application. I would like that the user choose his language when the application starts, then I will set a cookie and (in a way that iI don't know) the app refers automatically to my .lproj folders with different languages.
This is not possible using the default localization mechanisms in iOS. By default, the system chooses the .lproj folder according to the user's system language and does the localization automatically if you have localized NIBs and use NSLocalizedString() etc..
If you really want to change that behavior and "override" the system language, you have to implement your own version of NSLocalizedString that manually accesses the strings file in the .lproj folder you want. Be aware though that NIBs don't use your custom NSLocalizedString function. So either don't use NIBs at all or do the localizing of the NIBs in code instead of using different NIBs.
Your question isn't really very clear. There is nothing saying that "the language has to be set within my app and not within iphone settings" — it is in fact quite the opposite!
Cocoa has a pretty neat localization system that is quite easy to use (grumbles something about rotten localization workflows). Here's the full skinny on it — basically, have files in lproj folders, then use the NSBundle resource APIs to locate them (NIB loading and other subsystems use it automatically, so you don't even have to do work there!).
IIRC, you want NSLocalizedStringFromTable.
You create a .strings file for each language: eg "EN.strings", "JP.strings", etc...
These files will be loadable from the default bundle with the table parameter to NSLocalizedStringFromTable.
When the user picks a language, you switch which table (.strings file) to load the strings from.
One problem tho is that iOS strings will still be localized to the user's settings, or to whatever you have your app localized to in the Info.plist. So you might end up with a mix of languages.
[[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:#"it",#"en", nil] forKey:#"AppleLanguages"];
then if the iPhone language is set to english, my iPhone app will works always with "it". the first of the array.

Resources