How to use different fonts for different languages in an iOS application?
fonts, ios, localization, uiappfonts
Solution
I actually have done this by adding different font files for different languages in the project and in the plist against UIAppFonts. Then I introduced:
"fontName" = "English Font";
"fontName" = "Russian Font";
in Localizable.strings for each supported language
I then accessed it using:
UIFont *font = [UIFont fontWithName:NSLocalizedString(@"fontName", nil) size:16];
As I mentioned in my question that the other two approaches seem to be more elegant. Any solution regarding those will be highly helpful.
Problem
I am in a scenario where I want to use different fonts for the different languages in my iOS application. At first, I thought of using localized versions of .ttf files. I tried adding the localized .ttf files in the localized project folders for different languages with the same filename and font-name installed in them. It didn't work. I then looked into the InfoPlist.strings files for different languages. It appeared to me as the key value combination for the 'key' strings found in the main Info.plist. I found the font entry against the key 'UIAppFonts' which was an array. I am unable to figure out how to put the localized font file names in the InfoPlist.strings as an array. As a last resort, I am thinking of adding localized font names in the Localizable.stings files to pick the font name according to the current locale and replace all the occurrences in my project wherever I have used fonts. (Obviously it is a lot cumbersome). Like: ``` UIFont *font = [UIFont fontWithName:NSLocalizedString(@"font-name", nil) size:16]; ``` Please assist if anybody has done this before. It would be great if somehow one of the first two ideas can be implemented.