Quicksearch

Thaana on Android: Font Installer update

Early last year, I posted a font installer for Android that replaces the default fallback font with the free FreeSerif font that includes Thaana glyphs. That installer should still work on most older devices.

Here is a repackaged version of that installer which should work on most of the new devices with more recent versions of Android. This version has been tested on a Samsung Galaxy Note running Android 2.3.6 and a Samsung Galaxy S2 running the recently released Android 4.0 Ice Cream Sandwich.

Steps


1. As before, the device needs to be rooted. You can easily root your device using SuperOneClick (free/donationware).

2. Put the update zip file (see below) somewhere on your device. You could do this by downloading the file straight from the web on to the SD card of your device.

3. Power off your phone and boot into recovery mode. The specifics of how you do this depends on which recovery tool was installed during rooting of your phone. Try VolumeUp+Center Button+Power. If that doesn't work, use Google. If you have the CWM app installed, then you could just flash the zip through that.

4. Select the update from Zip option in your recovery tool and select the update_thaanafont_v2_jaa.zip file from the list and OK it.

5. The update should progress and will ask you to reboot once completed.

6. Congratulations you have a Thaana font installed. Thaana text on the Facebook, Twitter and other apps should appear OK now!


- Download update_thaanafont_v2_jaa.zip

Do drop me a message, here or on Twitter, if it works and if there are issues. Enjoy!

Thaana Text Render class for PHP 5 - v1.0

A (long) while back, I demoed a Thaana text rendering class for PHP I had written years ago that dynamically converts any given Thaana text into a formatted image of given dimensions with configuration options for important properties like font, font size and color. I am now releasing it, slightly improved, publicly for developers to use it in their applications.

Overview

The rationale for the class was that the use of images to display Thaana means that the information can be viewed on a large variety of devices and does away with the requirement for the device to support Thaana fonts. It can also be used for any purpose that requires dynamically generating an image with Thaana text in it, for example watermarking images or nice headings with your Thaana font of choice.

The class makes use of the powerful image manipulation services provided by the GD library to create images from text and hence inherits the wide range of features it offers. However, since the GD library does not support right-to-left scripts and does not offer line wrapping to fit text within a bounding box, the class requires the use of non-Unicode Thaana fonts and non-Unicode Thaana text. You can make use of my Thaana conversions class for PHP to dynamically convert Unicode Thaana text to ASCII Thaana text before passing it to this class for rendering.

Functions exposed

- render()
- renderImage()
- setFontPath()
- setFont()
- setFontSize()
- setTextColor()
- setTextLineSpacing()
- setBgColor()
- setShadow()

Requirements

- PHP 5
- GD for PHP

Usage


The class is well commented so have a look through the code for more details on the functions and their arguments.

The class takes ASCII Thaana text and an optional width, filename, filetype for the render functions. The render() function returns a handle that can be used with the PHP image functions for further processing if required. The renderImage() allows the output to be returned directly or saved to a file.

If the width is specified, the resultant image will be constraint to that width and text will be wrapped around and split into lines as appropriate. Specify either "gif", "png" or "jpg" for the class to save the rendered output. If the filename is omitted, then it will return the output directly.

The class will accept any HTML/CSS color specification (i.e. "#FFF000", "red", "rgb(127, 127, 127)") as a valid color for use as text color, background color and shadow color. You can also specify alpha values to accompany them in order to have transparency effects. Set the background alpha to 127 to produce text on a transparent background.

All fonts have to be placed in the font path directory and should be named, in lower case, exactly as the font names passed to the class.

Examples


Saving to a file:
This example shows how to render the text and save the output. It sets all the properties for font, background and shadows at object initialization. The renderImage() function has the filename and filetype specified for saving the rendered output.
<?php
// Load the class
include('thaanaTextRender.php');

// Initialize object
$ttr = new ThaanaTextRender('./fonts/', 'a_waheed', 20, 'white', 0, 50, 'rgb(0,0,0)', 0, 2, '#555555', 80);

// Render image and save output
$ttr->renderImage('swaincsc', 300, 'output.png', 'png');


Output directly to browser:
This example is ideal for use in scripts that dynamically generate the required rendering and return the output directly to the browser.
<?php
// Load the class
include('thaanaTextRender.php');

// Initialize object
$ttr = new ThaanaTextRender('./fonts/', 'a_waheed', 16, 'white', 0, 50, 'rgb(0,0,0)', 127);

// Render image and save output
$ttr->renderImage('gUgulunc aepwlc awaimUvIaW vWdwkurW kwhwlw aeve. gUgulc aencDcroaiDc fOnutwkwSc mihWru vwnI mUvI scTUDiaOaeac dIfw aeve.', 300, NULL, 'png');


You could use it by, for example, calling it via the image tag.
<img src="script.php" />


Demo

You can check out the original demo I posted to see it in action.

For a real-world application of the class, check out the Muraasil mobile site which has been making good use of it for almost 2 years now.

License

This script is released under the Open Source MIT License, allowing its use in both personal and commercial applications as long as the copyright and license permission notice remains intact.

Download

- ThaanaTextRender.zip (v1.0, 4.43KB)

Enjoy!

Page to Unicode Thaana 1.0

Here's a nifty little tool I made a few years ago that automatically and intelligently picks out the bits of text that use a non-Unicode Thaana font on any web page and converts it to Unicode. That probably doesn't make much sense to most of you but read on - there's a section for general web users and one for developers.

General users


Take the website of Haveeru Daily as an example. It uses a now-archaic method of displaying Thaana. Browsers cannot and will not substitute an alternative workable font if your computer does not have the exact Thaana fonts it requires and will display as non-sensical English text. But then take Miadhu Daily, which relies on something called Unicode. Browsers can and will load up the site perfectly readable as long as you have any one of the many Unicode Thaana fonts on your system. And in many situations, like at public libraries or on some phones and devices like the Kindle, Unicode-based Thaana web pages will load up just fine as there usually is some Thaana-supporting Unicode font on it while those that use the more archaic method will fail.

I came across this problem a few years ago while at the university lab one day and there was some interesting events taking place in the Maldives which I wanted to read about. Haveeru had the most news articles and was the most up-to-date but I couldn't read any of it as the Thaana fonts were not on the system and I was not allowed to install the fonts. So I wrote some quick code, specifically a bookmarklet, that converted the text on the site on-the-fly to use Unicode.

Anyway, if you find yourself in a similar situation, here is what you could do. Right click the PUT bookmarklet link below and choose to bookmark the link. When on a page, just click the PUT bookmark and the page should convert to Unicode and display Thaana.

Page to Unicode Thaana bookmarklet v1.0

Demo

Haveeru before


Haveeru after


Developers


Here's a slightly different version of the above script that can be used on web pages that do not use Unicode Thaana to offer the pages in Unicode without requiring any change to the content management system, editor etc that you have in place already. Add the script to your non-Unicode Thaana based web pages where appropriate and your visitors will get a Unicode-based web page as long they have Javascript enabled.

Usage
I would recommend that it be added towards the end of your page HTML, right before the closing BODY tag.



Download:
- put-1.0.min.js (minified, for production use)
- put-1.0.js (full source)

Enjoy :-)

Thaana on Android: Font installation

I have owned a Google Nexus One device since it came out early this year and I love it for the great hardware specifications of the phone and the customizability of Android. As usual, one of the first things I did when I got it was to explore Thaana usage on the Android OS. I have been meaning to do a write up since, so after almost a year here it is finally! This post addresses getting Thaana to display by installing a Thaana font.

Overview


With a healthy ecosystem of phones and tablets running Android now available, the free and open-source Android mobile operating system seem to be getting more and more popular across the world and in Maldives. Its official app-store hosts a large number of applications, a lot of which are free, and there are a number of third-party app-stores with more relaxed rules around as well. There is a healthy and growing developer community that's taking advantage of the open code to add new features and hack in interesting modifications - like the Nexus One does not officially have a FM radio or support HD video but developers have added code hacks for both into a custom ROM!

As awesome as Android is, unfortunately, all versions of the official Android OS (including the latest version 2.2 (Froyo) release) has limited support for international scripts, which is bad news for Thaana. Android can display Thaana characters as it supports Unicode fonts but it looks all jumbled up when diplayed as Android lacks support for bi-directional text rendering, both in the OS and the included web browser. The lack of BiDi support means Thaana input is also impossible as Thaana is a right-to-left script.

The next version of Android, version 2.3 (Gingerbread), is scheduled to have BiDi support and better support for international scripts, so hopefully that fixes things although it still wouldn't officially support Thaana.

The only easy way currently, as far as I am aware of, of viewing Thaana on Android correctly is by using Opera Mobile browser with Thaana fonts installed in Android. Now, none of the Android-based devices on the market seem to ship with a Thaana-supporting Unicode font preinstalled and Android does not currently provide a mechanism for user installation of fonts which means the process of installing a Thaana font is a little bit convoluted.

Installing Thaana fonts


Next, you need to install the Thaana font. Chopey has already posted a guide on how to do it manually and Gaanagaa has posted a Windows-based software to do automatically for you. I favour a different approach which relies on using a special Zip file to update your Android with the Thaana fonts in a manner similar to how Android devices update themselves with new releases. This method is, in my opinion, a lot easier and you do not need anything other than a rooted phone and the zip file I have prepared to do it. I have packaged the free FreeSerif font which includes beautiful Thaana glyphs as well as a large number of other characters from other writing systems.

Using my Thaana fonts update for Android
1. Make sure your device is rooted. You will need a rooted device to install any font via any method, including this one. There are a number of guides and free software available on the web for various Android phones (try xda-developers.com or modaco.com or samdroid.net) to help you do just that.

2. Put update_thaanafonts(jaa)_signed.zip to the root of the SD card in your device. You can do this by downloading the file straight from the web on to the SD card of your device OR download the file to your computer first and copy it to your device using a cable or Bluetooth.

3. Power off your phone and boot into recovery mode. The specifics of how you do this depends on which recovery tool was installed during rooting of your phone but involves pressing some combination of keys at the same time to start your device in recovery mode. Try the methods listed here if you aren't sure.

4. Select the update from Zip option in your recovery tool and select the update_thaanafonts(jaa)_signed.zip file from the list and OK it.

5. The update should progress and will ask you to reboot once completed.

6. Congratulations you now have a Thaana font installed! To make any practical use of it, you will need to install the Opera Mobile browser application available for free on the Android Market.



Enjoy :-)

Thaana on Amazon Kindle

I tinkered with the Amazon Kindle ebook reader device a few nights back and explored the use of Thaana on it. Here are my findings.

Overview


The Kindle is an amazing product - the screen is extremely easy on the eyes, the device is light and comfortable to handle and the battery lasts for a few weeks without a charge. The software supports MOBI, PRC, TXT, TPZ, AAX and PDF format books and documents and also includes a web browser.

Kindle 2 devices do not come with any Thaana Unicode fonts bundled in, hence making it impossible to view Thaana documents on a vanilla device. Kindle 3 does come with the impressive Code2000 Unicode font bundled in. This is good news for Thaana support as Code2000 currently contains over 61,000 glyphs from a huge range of writing systems and has supported Thaana for what must be close to a decade. However, the use of Code2000 seems to be limited to the web browser and is not involved in rendering ebooks.

It is possible to use either of the Kindle font hacks (see "Adding a Thaana font" below) to replace the system's ebook reader font to get Thaana to display within the reader component for all of the supported ebook formats. But this turns out to be pointless as neither device has proper support for handling right-to-left scripts like Thaana and hence words and paragraphs are all jumbled up in reverse.

Kindle screenshot: No Thaana characters in a vanilla device
Kindle screenshot: No Thaana characters in a vanilla device

Kindle screenshot: Thaana characters display after hack
Kindle screenshot: Thaana characters display after hack


PDF with font-embedding: The only thing that works!


The only ebook format that worked for Thaana was PDF with font-embedding (PDFs without the fonts embedded fails to render Thaana correctly even when the device was loaded with a Thaana Unicode font). Many of the existing Thaana PDF documents work just fine (see the screenshots below) as most of them have the required Thaana fonts embedded.

Kindle screenshot: PDF with Thaana fonts embedded
Kindle screenshot: PDF with Thaana fonts embedded

Kindle screenshot: Thaana Quran translation PDF
Kindle screenshot: Thaana Quran translation PDF.


Thaana in the browser


Thaana viewing via the WebKit-based web browser in Kindle was flawless in websites using Unicode Thaana (hence Haveeru Daily website is excluded). Code2000 has decent Thaana glyphs and looks very much readable on the device.

Kindle screenshot: Muraasil.com on Kindle
Kindle screenshot: Muraasil.com on Kindle


Unlike desktop systems, there is no native option to switch to a Thaana keyboard but because Javascript works, Thaana entry on websites using my Javascript Thaana Keyboard handler works just fine.

Kindle screenshot: Thaana entry using JTK
Kindle screenshot: Thaana entry using JTK


Adding a Thaana font


There are two ways of loading a Kindle with a Thaana font, though it is quite pointless for ebook reading purposes due to the reasons above. The rooted device method can be used to replace Code2000 with a font of your liking within the browser but keep in mind that Kindle will use the same font for the glyphs for English, numbers and puncuation and hence the font should be easy on the eye. In my opinion, this rules out most of the existing Thaana fonts, especially the common ones such as Faruma and the MV series of Thaana Unicode fonts. The best font I could find was the opensourced GNU Freefont which has very nice English glyphs and also includes the Thaana glyphs from Mohamed Ishan's Thaana Unicode Akeh font.

Rooted device + font replacement method
This method makes permanent changes to the Kindle and requires that you root your Kindle through a very simple procedure and install an associated custom fonts hack. The details are available here.

User fonts method
This method only works for Kindle 3 devices and does not require rooting the device and makes temporary changes to the Kindle by enabling a hidden user font mode in the device. The changes persist as long as you do not alter the font-face settings on the Kindle. Details on how to do this are available here.

Creating Thaana ebooks


For now, the only method for getting Thaana to work on Kindle devices seem to be via font-embedding in PDF documents. The easiest, and perhaps the most cost effective, method of producing such documents would be to prepare the document using your choice of document editor (like MS Word or OpenOffice) and printing out the document to the virtual printer provided by print-to-PDF software such as the free PDFCreator applications.

How-to for Windows:
1. Download and install the PDFCreator application.
2. Go to the print function in whichever software you are using and select the PDFCreator virual printer.



3. When the PDFCreator print window comes up, click the "Options" button.



4. On the PDFCreator print options window that comes up. Select "PDF" under "Formats" from the left, switch the "Fonts" tab and make sure "Embed all fonts" is ticked. Customise the "Subset font..." option if you would like and click "Save".


5. You only need to set font embedding as above once and the program will use it in future prints. When you are back at the print screen, set the Document title and other details as you please and click "Save".

To ensure that the PDF you saved (or any other PDF that you may have) has the Thaana fonts embedded, load it up your favourite PDF viewer software and check the document properties.



Conclusion?


Thaana on Kindle is very limited for now. The only option to produce and read Thaana ebooks is using the PDF ebook format with the Thaana fonts embedded in the PDF. This does mean that Kindle devices can be used to read Thaana without rooting or any hacks. Thaana usage on the web browser in Kindle matches that of a mobile device or even a desktop or laptop computer.

Toodles.

Domain names in Thaana?

The Internationalized Domain Names for Applications (IDNA) standard which allows non-Latin alphabet to be used as domain names has been around for a few years and many of the top domain registries do support IDN registration now. ICANN, the corporation responsible for the management of the domain name system, also recently approved the creation of country-code top level domains in non-Latin alphabet. Hence, countries can now use top-level domains in their own language. Egypt, for example, now has adopted "‏مصر" as an option in addition to the usual Latin-based top level domain "eg".

The IDNA standard, along with the recent ICANN approval, means that there is now a framework allowing domain names to be written entirely written in Thaana. Before one gets too excited, there are a few issues to be aware of though. First, unfortunately the use of fili (diacritics) in the name seems to be not supported by IDNA (I've yet to read up to see whether this is an issue with the current implementations of IDN or something inherent in the IDNA standards). So, any domain name will be just a jumble of Thaana letters for now. I had to choose the address "ޖ.com" instead of "ޖާ.com" because the latter is unsupported. Second, for us to be able to have fully Thaana domain names, the government has to first adopt a suitable top-level domain (perhaps "ދވހރއޖ" or "ރއޖ"?), get ICANN approval and then wait for licensed Maldivian domain registrars (only Dhiraagu as far as I am aware) to start accepting registrations under the new top-level domain. This might seem quite pointless but given the increasing number of Thaana-based websites, I think we are soon going to see an explosion in the number of websites with domain names in Thaana.

Let's see how it all goes... :-)

Thaana text rendering: A solution for devices without the required fonts

A few years ago I wrote a PHP-based Thaana text rendering class while investigating solutions to the problem of displaying Thaana text in web browsers on various devices. The class dynamically converts any given Thaana text into a formatted image of given dimensions and type. The use of images to display Thaana means that the information can be viewed on a large variety of devices and does away with the demand for the device to support Thaana fonts. On the flip side, the use of images does mean that this approach has higher bandwidth and data transfer requirements than text.

Features

The class makes use of the powerful image manipulation services provided by the GD library to create images from text and hence inherits the wide of features it offers. However, since the GD library does not (or atleast did not, back then) support right-to-left scripts and does not offer line wrapping to fit text within a bounding box, custom code had to be written to handle the unsupported text direction and formatting. The class also supports use of any Thaana font, made possible by GD support for loading TrueType fonts.

Applications

This piece of code was briefly put to live use around 2004 on the (now defunct) MUnet.net's Radheef service. More recently, it has been put to great use by Muraasil.com to display Thaana on their mobile service so that user's can read news in Thaana on mobile devices, including Windows Mobile-based phones and the iPhone.

Demo

Give it a go and play around: Thaana text rendering demo.

I am not releasing the code publicly just yet...