How to use custom fonts in a property list file? - ios

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.

Related

How to Use a Custom Font in Xamarin Cross Platform

My App will be used on iOS, I have Windows and Android versions, but I am not too concerned with getting the custom font to work for those platforms. Mainly IOS.
I know how to add the .ttf file to my Resources folder, and set it to Copy Always, I also update the IOS file info.plist and add a string array with name 'Fonts provided by application' and value 'Cardinal.ttf'
What I am not clear on is how to call the Font Family in my Cross Platform code. I know I do something like
labelName.Font = UI.Font( "Cardinal" )
However this will not work in Cross Platform because the UI namespace is not available.
Any help here?
Something with Device.OnPlatform( ...
Thanks to #Gusman above! You simply specify the FontFamily as a string with the value of the Font name. As long as you added the ttf file to resources and updated the info.plist file correctly, it will load the Font on App startup and the call to
FontFamily="Cardinal"
will work fine. Cheers!!!

iOS app using previously selected localization instead of Base

Im using localized strings with NSLocalizedStringFromTable() in my project. Supposed that when a user switches to the one of unsupported languages, Base localization is used. But it works wrong: previously selected localization is used instead of the Base.
I've already tried to remove and add base localization.
May by somebody faced this problem before?
My project settings:
Settings of one of the strings files:
Info.plist:

Xcode storyboards: Load localizable strings from different file

I'm trying to build a library that will allow for dynamic loading of Localizable.strings files. If the views are being developed programmatically, then it's not a problem, as I could build a separate NSBundle, store the .strings files inside, and use NSLocalizedStringFromTableInBundle.
The problem I'm having lies with Storyboards. I haven't managed to find a way to specify which .strings file to load from (rather than using the default .strings that Apple uses).
Does anyone know of a solution for this? It doesn't even have to follow the same approach, as long as I can dynamically update the strings on a Storyboard. (The strings will be pulled down from an external source via API call upon app launch)
Loading strings from a separate bundle/strings source
In order to overcome the issue I had, I created IBOutlets for each object on the Storyboard's collection of views. Within each view's implementation file, I programmatically set the text/values of each object by using NSLocalizedStringFromTableInBundle, which allows me to specify a custom bundle, which can be populated with strings files.
In the event that a project has both programmatic and storyboard developed views, this approach also allows for the usage of only one Localizable.strings file, rather than mixing Storyboard-generated files, and files used only for programmatic views (if applicable).
Loading strings into an app via API call
Unfortunately, the above approach doesn't allow for strings to be downloaded from an external source via API call. The reason for this being, Apple doesn't allow for any files in the app bundle to be edited after being built.
Because of this, the solution would be to build out a data structure within the app's DocumentsDirectory, and edit this whenever necessary, then force the app to use this file/library in order to get localized strings. Not a pretty solution, but it's the best approach I can think of.

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

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.

iOS: Registering for dynamic UTIs

I am developing an application that will be capable of handling multiple file types. To accomplish this, I have registered the UTIs corresponding to the file types in my info.plist file. However, there are a few file types, such as .pub & .indd, for which mdls generates a dynamic UTI (dyn.something).
My question is, how do I register for such types? As far as I can understand, as these are not file types defined by my application (custom file types such as com.mycomp.myapp), I should not be required to export UTIs.
Any help will be really appreciated.
Thanks,
Akshay
I do not think this is possible for 3rd party apps. The URIs must be specified in the info.plist which is built into the bundle.
I have searched about this a lot. It seems that these file types are not supported by iOS (even Mac OS X).
You should check this Q&A page on how to export custom UTI type.
http://developer.apple.com/library/ios/qa/qa1587/_index.html
Even if files of such type might have system UTI type, you can register your own one by some unique name, e.g.
com.yourcompany.${PRODUCT_NAME:rfc1034identifier}.x-pub

Resources