Thursday, May 30, 2013

Arabic support on non-rooted Nook Simple Touch



Nook simple touch is the second generation of e-readers made by B&N, although it's released in 2011, it’s based on Android 2.1 (released in 2009!), and hence its native support for Arabic eBooks is very poor, combined with fact you can't change system fonts , all you will see is bunch of ? A square here is a sample of Arabic Epub book on NST:


So, is there any way to overcome this problem?
Rooting is the easy and the best way , once the device is rooted , you can replace certain files with patched ones +replacing DroidSansFallback.ttf with any Arabic font ( I use DroidSansNaskh (don't forget to rename it )  in /system/fonts to have proper support of Arabic, once done you will see Arabic texts  in most apps (ES file explorer, EzpdfReader , etc)



For Arabic Eups reading I highly recommend using moon reader+ pro 1.6 or any version that supports RTL (Right to left texts) .



 Even with this method B&N stock reader won't display Arabic texts properly  as its engine doesn't understand/support RTL . 

So, all mentioned above is for rooted devices, what about poor non-rooted NST users?
Well, here what I did
 [css font hack]
  1. first we are gonna use sigil as epub creator tool ...
  2. create a new epub file 
  3. add Droid Sans Naskh font to your Fonts folder
  4. edit the html source and add the following 

 
@namespace h "http://www.w3.org/1999/xhtml";
@font-face {  
 font-family: "Droid Sans Naskh"  
 font-weight: normal;  
 font-style: normal;  
 src: url('../Fonts/DroidSansNaskh.ttf');  
 }  




Now the hard part,
By default, as you can see above, NST reader displays the Arabic words reversed and with un-connected letters, so we need to modify the text in a form NST can display properly
They are different way to do it but the most accurate way is to use php class called PHP-AR
To use the script, I will assume you use Linux,
·         Install php on your system
·         Extract the file to any folder you like
·         Create 1.php file in the I18N folder and paste the following code

  <?php  
  include 'Arabic.php';  
 $lines = @file("1.txt");  
 $obj = new I18N_Arabic('Glyphs');  
 foreach($lines as $line ){  
 $text = $obj->utf8Glyphs($line);  
 echo "$text \n" ;  
 }  
 ?>  
Paste your Arabic text in a txt file named 1.txt
In your terminal cd to the I18N directory
cd /home/live/Downloads/Arabic-3.6.0/I18N
Execute the following command
php a.php >2.txt
The converted Arabic text will be saved in 2.txt
Open the file and copy the incomprehensible back to sigil, save your work.
This is how the file will be displayed using NST reader
.
The result is satisfying =) , thanks to the php-Ar class , diacritics handled and displayed properly on the NST., but alef-lam combinations needs some work from the developer.
You can download all the files needed from this link

If you have a question, or want a clarification, leave a comment

7 comments:

  1. Hi brother, Thanks for the great post.

    The post you have linked about adding Arabic support, is quite old and the NST's firmware is updated since then. So I was wondering, does that change anything?

    Also, I want this for Farsi, which has a few additional letters to Arabic. What exactly should I change? Just the font or is there more?

    Last thing, I mostly want the Farsi language for my web browsing. Does this method work for the mini opera browser as well?

    ReplyDelete
  2. hi Shahab, it is true the firmware was updated but it didn't bring any change to supporting RTL languages, if you are using a newer firmware , downgrade and follow the guide.
    the php class supports Farsi letter as well, so you don't have to change anything, using the pathced files will cover Mini Opera browser too.

    ReplyDelete
    Replies
    1. Thanks for the reply. I think I left a reply to your comment but it doesnt seem to have gone through. so again:

      So if I downgrade, go through the above procedure and the nook upgrades the firmware, wouldn't that update the Framework and hence undo whatever we have done?

      Delete
    2. you can't apply the patched files without rooting, so you will downgrade->root the device-> apply the patches .
      using CSS font hack requires no rooting but it's not practical to do it on every Arabic/Farsi Epub. so again , I recommend rooting and patching.
      thank you

      Delete
    3. Hi there, just wanted to let you know that I contacted the guy who had modded the patch for RTL support and got him to do it for 1.2.1 version. here are the files: http://www.mediafire.com/?4kfa162xd7e7d42

      thanks again,
      Shahab

      Delete
    4. Thanks for sharing the link Shahab , it is good to know the developer still working on keeping the fix up to date .

      Delete
    5. Hi abjdiaty, as you have said I add the command @namespace h "http://www.w3.org/1999/xhtml";
      @font-face {
      font-family: "Droid Sans Naskh"
      font-weight: normal;
      font-style: normal;
      src: url('../Fonts/DroidSansNaskh.ttf');
      sigil doesn't recognize it and I tried your rtl.epub in my NST it doesn't show the Arabic fonts at all would you please elaborate or upload a epub that can be shown properly in nook thanks reza from Iran

      Delete