Google
 

Friday, April 03, 2009

Fixing Nepali Unicode in Ubuntu

Setting up to type Unicode Nepali in Ubuntu is easy (just add Keyboard Indicator applet and add Nepali Layout). For more, follow this article in Ubuntu Nepali wiki. However there are few glitches.

Incomplete keyboard layout
The Nepali Romanized Keyboard layout shipped with Ubuntu (located at /usr/share/X11/xkb/symbols/np) is incomplete. The definition for the whole upper row (1-0 keys) are missing. Also, more importantly, zero-width joiner (ZWJ) and zero-width non-joiner (ZWNJ) characters are wrongly defined (ref: standard layout map).

You can find the working version here: http://www.nepalinux.org/input/ne. So lets, fix it. Fire up your terminal


$ cd /usr/share/X11/xkb/symbols/
$ sudo mv np np.bak
$ sudo wget http://www.nepalinux.org/input/ne -O np
Glyph missing
The devanagari fonts included in the standard Ubuntu installation has few Nepali specific glyphs missing. Most notably, 'pareli ra' or 'samyukta ra' (whatever it is called, the one you use in the word 'paryo').

Well, the fix is to install a font file which has this glyph. My recommendation is Lohit Nepali, available at http://nepalinux.org/fonts/. At terminal,

$ cd /usr/share/fonts/truetype
$ sudo wget http://nepalinux.org/fonts/Lohit-Nepali.ttf
$ sudo fc-cache -fv
Now if you want a specific font file (say, Kalimati) to be used as default devanagari font file, follow the following procedure.

Create a file in /etc/fonts/conf.avail/

$ sudo gedit /etc/fonts/conf.avail/64-ttf-nepali.conf
and paste the following content

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>serif</family>
<prefer>
<family>Kalimati</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Kalimati</family>
</prefer>
</alias>
</fontconfig>
Now, create a symbolic link to it in /etc/fonts/conf.d/

$ sudo ln -s /etc/fonts/conf.avail/64-ttf-nepali.conf /etc/fonts/conf.d/64-ttf-nepali.conf
You might have to restart X to see the changes.

22 comments:

  1. Hats off ! यो पोष्ट मलाई मन पर्‍यो है ।

    ReplyDelete
  2. Thanks for the detailed description in the very useful topic. Keep on posting more like this!

    ReplyDelete
  3. in my case there is no conf.avail directory in the font directory

    ReplyDelete
  4. I updated from Intrepid to Jaunty and after the update I end up with terminal and GDM fails to start. When I use startx, I ends up with a blank screen and mouse and keyboard doesnt' seem to work then.
    I had setup Nepali Unicode in Ubuntu as suggested by you above and during the updation process it had issued a note that there were some incompatibility issues with my xkb layout. It this the problem with Jaunty? Any idea how do i resolve this issue?

    Saurav

    ReplyDelete
  5. @anonymous: which distro are you using?

    @saurav: the method works on clean jaunty installation. maybe there's some issues with upgrade process.

    ReplyDelete
  6. Jwalanta:
    Can I repair my Jaunty? I have a live CD? This might resolve the issue?

    ReplyDelete
  7. @saurav:
    i'm not sure, but give it a shot.

    ReplyDelete
  8. Thank you :-)
    How can I install traditional nepali unicode in ubuntu? I am new to linux. I used to use traditional unicode in windows.. now i have completely switched to ubuntu and I find romanized quite hard to understand. I would be grateful to know. I have bookmarked you. Cheers!!

    ReplyDelete
  9. Thanks for the post. This one still has a problem though. The latest Romanized keyboard layout has a few changes to the version posted above. For example, 'च' and 'छ' are swapped and a '.' has been added. It would be great if the link was updated. Thanks again!

    ReplyDelete
  10. I recently migrated to ubuntu and the chrome web browser doesn't seem to fully support unicode as the 'े','ै' and 'ु' and 'ू' are out of place. take a look at this: http://oi56.tinypic.com/2u900uw.jpg

    any help would be great! thanks.

    oh and it works fine in firefox and elsewhere.

    ReplyDelete
  11. @alok:
    it's a known bug: http://is.gd/fwFzJ
    infact this is a regression, there was no problem prior to 4.0
    the bug's been fixed, will reflect in upcoming newer versions after the tests are complete.

    ReplyDelete
  12. i need some help here. i installed unicode that way and it worked fine. but later i noticed that messages in terminal are written in nepali fonts. also, my empathy chat client shows 'offline, away,chat, edit, help and rooms' in nepali fonts as 'offline, tadha, kurakani, sampadan garnus, madat and kotha' (sorry i couldnt write in devanagari font as i uninstalled unicode)

    now i didnt want this change. i was trying to install only the keyboard layout. i dont know if this was created by the installation of unicode, but to check it i uninstalled unicode, the problem is still not solved.

    can anyone help? maybe jwalanta ji? is it because of any other setting?

    ReplyDelete
  13. @Bidur ji:
    Try System > Administration > Language Support

    ReplyDelete
  14. that was the first thing i tried when i discovered it. and then i tried again, and again, no recovery. its all right, i re installed ubuntu (it was really irksome to see 'lock screen' as 'parda ma talcha marnus' and all other things)

    all i m concerned about now is, if i install unicode, will things go that way again?
    i need unicode. but i dont like my terminal displaying 'pyakage haru kholdai' in devanagari :(

    is there any link between installing unicode by the above method and the appearance of devanagari fonts everywhere? i just want to install the keyboard layout. any specific dos and donts?

    ReplyDelete
  15. @Bidur ji,
    you dont need to install Nepali locale just to type in Nepali. Devaganari fonts are installed by default in Ubuntu. Use iBus to enable Nepali typing (keyboard layout).
    See this thread:
    http://groups.google.com/group/foss-nepal/browse_thread/thread/5f7fad3de1fc0b10?pli=1

    ReplyDelete
  16. Three cheers for that. I just needed to know that it was called 'locale' (not so much of a genius here :(


    all set done now.

    thx

    ReplyDelete
  17. @jwalanta: Awesome!! Thanks.

    ReplyDelete
  18. If I would want to type in traditional बकमन, how would i do this? I mean not in romanized but in unicode.

    ReplyDelete
  19. @starx: try iBus. System > Preferences > iBus. Choose Nepali Traditional.

    ReplyDelete
  20. Fixing Unicodes has always been a place where I find myself trapped...I am so thankful to Jwalanta for his efforts to resolve this issue...Great effort!!

    ReplyDelete
  21. my ZWNJ is working fine but instead of ZWJ it just types "=".
    how can i solve this?

    ReplyDelete
  22. can not tye छ ट ठ ड in nepali traditional (Ubuntu)

    ReplyDelete