Persian Soft Keyboard and Applications for Android

[Permalink]

I recently got a new smart phone — an Android-powered HTC Dream. As I wrote in a previous post, one of the first applications that I always look for is a multilingual dictionary, or at the very least a way to enter input in languages other than English.

It took me almost no time to write up a Persian Soft Keyboard, which I have put on the Android Market. (If you’re viewing this page on an Android device, you can download the application directly by clicking this link.)

Because Android is open source, it was remarkably easy to learn how to use the SDK. Unfortunately, despite this, there are a number of design decisions which make it difficult to enable Android devices for the Persian language (or many other languages). For one thing, it is impossible for the average user to install a new font, and the default fonts that ship with most Android phones don’t cover character sets outside of the Latin-based alphabets. For another, built-in support for complex text layout is very incomplete, and that includes the bidirectional text display and glyph-shaping which are essential for properly rendering Persian text.

I can understand the decision to leave these features out, since space is limited on most Android devices. However, this means that users who use languages other than English end up having to go to a lot of trouble to get these languages to work, such as downloading versions of applications capable of handling their specific language. It would have been much simpler if the base Android system had been packaged with a font that covered the Unicode characters for the most common languages in the world and applications that were aware of how to lay out their writing systems.

As things are, even with a Persian font installed, most applications still don’t display Persian text properly because of directionality and glyph-shaping problems. I’ve included an option for the Persian Soft Keyboard to output Unicode presentation forms, i.e., glyphs which are already shaped and joined. Even though this option does not comply with the Unicode standard, it allows readable Persian text to be entered into and sent through the default SMS application, for example. (Whether the recipient will be able to read the message at the other end is another issue.)

Currently, I’m bundling a simple note pad and a translator application with the Persian Soft Keyboard package. At the moment, the available note pad applications can’t handle right-to-left text, and the available translators don’t do glyph-shaping correctly. I hope that more Android software authors make their applications aware of languages other than English, because I don’t really want to support or maintain applications which are redundant.

– davinci 11843

  • RSS
  • email
  • Facebook
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Google Bookmarks
  • Yahoo! Bookmarks
  • StumbleUpon
  • Technorati
  • Reddit

28 Responses to “Persian Soft Keyboard and Applications for Android”


  • Hello,

    How could I use Farsi/Persian font on new Motorola Droid phone which run with Google android? I mostly interested in using this font for the web browser?
    Thanks in advance for the information

  • Hi, Hassan,

    The options available for using Persian on Android phones will depend on the particular combination of hardware, software, and provider/contract.

    Generally speaking, however, you’ll need root access to install a Persian font. And if you want to browse Persian language web sites, you’ll need a browser that supports bidirectional text and glyph-shaping.

    – davinci

  • Hello Davinci,

    Is there any browser that supports bidirectional text and glyph-shaping available on Motorola Droid phone use has Android 2.0 OS?

    • Well, yes and no. Since Android is open source, anyone can download the browser source code and add those features. But it takes some technical expertise as well as time and effort. There are browsers which are not open source which have those features built-in, available from providers or software companies in the Middle East, aimed primarily at the Arabic language market. I can’t help you beyond this, as the availability of the software and the legality of installing them depends on your contract with your provider.

      – davinci

  • Hello davinci ,
    We can not Download This Program With Market Because Market Is Not available For Iranian !?
    Please Upload This Program in 4shared & … and tell us That`s Download Link !
    very Thanks !

  • Looks great but both links (market://search?q=pname:net.stargrads.android.inputmethod.persiansoftkeyboard) and 4share end up in “Not Found” dead ends. I’d loved to be able to use my newly acquired Motorola Droid (Verizon) in sweet Persian mode (Farsi shekar-ast!)

    • Are you accessing the market link with your actual mobile device? It’s working for me, but maybe it’s blocked in Iran.

      Sorry that the previous 4shared link doesn’t work any more, when I updated the app 4shared changed the URL. Try this link instead.

      – davinci

  • thank you for your persian keyboard its perfect ,i had a question regarding character seperation on persian fonts in other application ,i realazie that you had made some kind of string reshaping in your applications right ?is there any way to do the same for other applications to (like sms) ? i would appretiate if you could provide me with your sources so i can get a better grip what going on and then if there is not to make the sms fonts work im going to write on my self .

    Regards Amin
    
    • The answer to your question is rather complicated. I’ll try to explain things briefly. For a fuller explanation, see Chapter 8 of the Unicode Standard.

      Basically, each Perso-Arabic character should be mapped to one code point when a string is stored in memory, regardless of the character’s context or appearance. It is up to the renderer (text editor, browser, etc.) to convert the characters to their “presentation forms”, or how they are displayed, i.e., initial, medial, final, etc. There are a number of advantages of separating encoding from display, such as being able to search for a sequence of characters in the middle of a word. (For example, if you wanted to search for the character “ye”, you don’t have to worry about whether it occurs at the beginning, middle, or end, or how many dots it has.)

      Since it affects text display throughout the system, rendering and layout should ideally be handled by the operating system. Unfortunately, the Android OS (as it is released on many devices) does not do glyph-shaping or complex text layout.

      One way to get around this is to encode a string using the codes for the presentation forms. Leaving aside for the moment the directionality of the text, the individual characters will have the right shapes when they are displayed. Note that the Unicode Standards specifically says NOT to do this — it breaks all kinds of things and is generally a bad idea. When you turn on the “Join characters” option in my soft keyboard app, it basically activates this hack (after it displays a warning).

      Because the glyph shaping is happening at the input, there’s no need for any apps to do any special processing. So you should be able to send messages in Persian using the default SMS app without any problems. I’ve been using it for a while and it works very smoothly. The only reason I bundled a notepad and a translator is because I couldn’t find any notepads that recognised when text should be displayed right-to-left, or any translation app that converted Unicode output to their presentation forms for display. Strangely, the default SMS app (at least on my phone) is able to recognise that Perso-Arabic text should be displayed right-to-left, as are some other bundled apps.

      If you’re unable to enter Persian using the soft keyboard in the SMS app, let me know what problem you’re having exactly, and I may be able to help you.

      I can’t release the source code right now, because I’m actually trying to get complex text layout (including Perso-Arabic glyph shaping) included in a future official release of Android. However, when I have some time, I plan to write a blog post about what I did that should include enough detail and code snippets for anyone else to be able to do similar things.

      – davinci

  • Where is the “jeh” on the persian keyboard?

  • any thing new on BIDIac implementation for android ?

  • Hello All,

    Persian VOA has a new application for Android. They recommend to install Farsi font for that application. Does anybody have any idea how to install that font and where to get the font.

    Thanks in advance.

  • Thanks Davinci for the reply,

    if I install either the DejaVu Sans font or the Free Persian Font. Does the browser for my phone will be able to read Farsi font also.

    Thanks in advance for the information.

  • Hi, everyone,

    I found out a way to get Persian mostly working in Android. Download and install Cyanogen with Arabic WebCore, and the appropriate Arabic Android image for your phone, from here, and install it. Note that the download includes the DejaVu font. This will allow the display of Arabic, but you will see squares for some Persian-only letters in some applications, because the Arabic Android’s glyph-shaping does not handle Persian correctly. However, the VOA PNN app on Android market has its own glyph-shaper which does handle Persian correctly. You’ll have a mostly functional Persian-enabled Android phone if you follow these steps!

    – davinci

  • Hello Davinci,

    Does it include internet browser? Does Persian BBC show farsi font correctly?

    Thanks in advance.

  • Hello Davinci,

    How do you like Nexus One? I have given up on Iphone to come to Verizon and I plan to buy Nexus One next month when Nexus One comes to Verizon. Do you recommend Nexus One?

    Best Regards

  • Salam
    I new to android phones, can one of you please explain how I can install the persian fonts and a browser to view bbc farsi and VOA
    regrads

  • nice work boy
    check it out http://www.androlib.com/android.application.net-stargrads-android-inputmethod-persiansoftkeyboard-zAit.aspx
    may need you submit your app.

    i need your app. but cant find it anywhere

  • hello mr.

    can you read or speak farsi?? or persian??

    we have a forum for iranian people, and we need to make android farsi,

    i mean we want be able to read and write farsi in android. we know we can count on your knowledge.
    we trying to collect a good number of donation. its about 40$ now, but so soon its getting to be more.
    we need your help, its not about money for us its about to be able to be a human in our country. we very pleased if you help us

    we need you to write a program for us, or teach us how to write.

    thank you,

    واقعأ ممنوتون میشیم

Leave a Reply

Subscribe without commenting