views:

578

answers:

3

I am currently using the iPhone SDK to create an app that utilizes Indic scripts. However, the iPhone has issues with rendering certain glyphs in many Indic scripts. For example:

प + ् + र = प्र

or

ਕ + ੍ + ਰ = ਕ੍ਰ

When you type this on a Mac (or Windows) the computer will automatically render the three characters into the one glyph (प्र - In Unicode it is still represented as three characters however). Because the iPhone doesn't support AAT (Apple Advanced Typography) or advanced OpenType features it renders the characters as three separate which becomes unreadable in many cases. I'm thinking there should be a way to hard code in Objective-C to ensure that every time the three characters show up in a UILabel they should render a certain glyph from the Arial Unicode MS (built-in) font instead. I do not mind using undocumented APIs to accomplish this.

+1  A: 

Start by exploring what Apple is using as follows:

  • Try entering the separate glyphs in both Notes and Mail and see if they composite. If not, then there is unlikely a hidden piece of code that does this.

  • Next, created a composited character on Mac and email it to your iPhone. See if Mail is even capable of displaying various composited characters. Repeat by hosting a webpage with composited characters and observing what MobileSafari does. I've done this one for you by viewing this page in MobileSafari; it does not composite the characters correctly. So that tells us that WebKit on iPhone can't help you (and makes it much less likely that iPhone can do this at all).

  • Finally, why do you believe that प्र is available at all on iPhone? Have you ever been able to display this glyph on an iPhone in any app? It's very possible there is no such glyph definition, in which case you may be stuck unless you're ready to write your own layout manager (which would likely require creating a completely new text view). If you've been able to display it somewhere, then you can move forward from there to figuring out how Apple is displaying it.

Is there even an Indic keyboard available on iPhone? I haven't been able to find one, and if there isn't, then it's extremely unlikely that they have very much Indic support hidden in private methods.

Be sure to open Radars (bugreport.apple.com) for any glyphs that are incorrectly drawn on iPhone. That's how they know to fix it.

Rob Napier
I've found this: http://www.hackint0sh.org/forum/f9/39822.htm, And this is where I got the idea of using undocumented APIs. I can't seem to figure out what exactly it does and how it could help me since I am relatively new to the framework. As far as the keyboard, I created a custom keyboard for my app and I have been submitting the Indic rendering issue to Apple since Apple started supporting Unicode Indic fonts in 2.0. -Thanks
Kulpreet
What you want to do is take a look in the phone's font directory (should be /System/Library/Fonts or /System/Library/Fonts/Cache) and grab the actual .ttf files and throw them into a font editor and see if these characters are really in there. Don't trust the Simulator's ttf files. You need to check the actual device. You can write code to read that directory, print out what it find, copy files to your own Documents directory, and download in Organizer. Or you can use a jailbroken phone. I suspect that Indic isn't really supported.
Rob Napier
So I went into the iPhone System and used FontForge to find out that the glyphs were not in the Arial Unicode MS (arialuni.ttf) file. It seems that Apple keeps these alternative glyphs in a separate file for each language (i.e. Devanagari.ttf) which has the alternative glyphs. These files are not present on the iPhone. That is disappointing. So I tried putting it in myself with no luck. What can I do in terms of my application?
Kulpreet
I don't know if there's an solution beyond building your own layout manager. I'd start by studying how NSLayoutManager works on Mac as a start. If you find any iPhone app that achieves the layout you're looking for, that's a start. You could also pursue a UIWebView-based solution, where you replace composited characters with images. Of the solutions, that's probably the easiest, but also the least flexible.
Rob Napier
+1  A: 

I work on language learning applications.

There is little to no support for Indic scripts on the iPhone. You're going to have to write your own text rendering support and elements that use it or wait for Apple to implement it.

The iPhone OS couldn't render Arabic scripts until 3.0, and OS X only supports certain Indic text with third party rendering support.

My solution for supporting scripts iPhone OS can't render is to use pre-rendered images. Probably not much help to you, but that's what we do.

coob
+1  A: 

The problem is not the iPhone supports only certain Indic or do not support AAT fonts. The iPhone support AAT table for sure. The problem is the proper AAT font that you use is not included!! U can have few glyph displayed because those ones are inlcude either in arialuni.ttf or helvetica.ttf. But those font do not have any OpenType or AAT tables.

I can confirm with picture what I state, I have a jailbreak iPhone and you can check flickr.com/photos/41161441@N03/ for picture for proper Khmer rendering, which is one of the most complex Indic script.

I explained the problem on modmyi.com web site forum. http://www.modmyi.com/forums/general-iphone-chat/680094-indic-font-rendering-iphone-yes-working.html#post4897261

Thanks! This should really help. How did you create a native Khmer keyboard? BTW...I am using Unicode Gurmukhi in my app. I will try what you did and tell you how it goes. Thanks Again!
Kulpreet
I posted a reply to your thread on the forum. Thanks Again!
Kulpreet
Regarding the keyboard, all the credit goes to KENNYTM which is actually updating is great iKeyEx plugin (You can check is blog). http://networkpx.blogspot.com/2009/08/partial-30-support-for-ikeyex.htmlI only created the plist file for khmer keyboard and follow his instruction to create the keyboard.