Quicksearch

Guide to using Thaana on the WWW

Developing Dhivehi web pages is pretty easy and there are quite a few methods to do it. However, information on how to go about it seems to be lacking, leaving newbies stumped. Here is a general overview on the various methods for displaying Thaana on the WWW and should contain enough information to help anyone, designer or programmer, get started.

1. CSS: rtl + bidi-override

This method is applicable only to non-Unicode text. It works on all modern browsers but requires for the user to have atleast one of the fonts specified in the page - otherwise the text would be displayed as a mostly meaningless jumble of English letters.

This is the least-effort route to getting any non-Unicode Thaana text (such as those written using MS Word 97/2000, Accent Express, MLS or Faseyha Thaana) on to the web. The websites of Haveeru and Miadhu currently take this approach.

Usage:
To use this method, apply the following CSS to any HTML elements that contain Thaana text. You may use inline style attributes or CSS class/ids to achieve this. You may change the font names to suit your needs but make sure you list several popular fonts and that the fonts specified are all non-Unicode fonts. You could, of course, also add further CSS styling (font size, font color, line height etc) but the following are the required minimum.
font-family: A_Ilham, A_Randhoo, A_Faruma, A_Waheed;
direction: rtl;
unicode-bidi: bidi-override;

Demo:
View example



2. Unicode Dhivehi

This method is applicable to text in Unicode. It works well on all modern browsers but requires for the user to have atleast one Unicode Thaana font - and unlike method (1) the system defaults to a Thaana font it does have if it cannot find any of the fonts named in the page.

This is the best method for any new and modern Thaana-based website. It is used in the online Radheef, Jazeera Daily and Haama Daily.

Usage:
To use this method, first add the following to the page's HTML HEAD section.


Next, apply the following CSS to any HTML elements that contain Thaana text. You may use inline style attributes or CSS class/ids to achieve this. You may change the font names to suit your needs but make sure that the fonts specified are all Unicode fonts. You could, of course, also add further CSS styling (font size, font color, line height etc) but the following are the required minimum.
font-family: Faruma, "MV Elaaf Normal";
direction: rtl;
text-align: right;

Demo:
View example



3. Image

This approach basically renders the Dhivehi text as an image. This is perhaps the most obvious and was the only method available early on. However, this method is still a pretty lucrative solution especially given that many computers just don't have the required fonts available. Using an image for the text rids the requirement on the client browser/computer to have the proper fonts available.

The basic approach of rendering the text into an image using Photoshop, MS Word etc is pretty tedious as the process is entirely manual. However, there is a more sophisticated approach that renders the text into Dhivehi on-the-fly on the web server side (perhaps coupled with caching to reduce load). A server-side scripting language such as PHP can be used to render text into an image using any font of choice by the designer/programmer. The rendered images (typically PNGs) are of very small size and hence have a negligible effect on the page load time in most cases.

Refer to the imagettftext function for details on how to do it in PHP.



4. Flash

This method uses text loaded in Macromedia Flash with the required font(s) being embedded in the Flash clip. ActionScript and/or Flash variables are used to load the text into text areas in the Flash file. This method has the advantage that it works whether the client computer/browser has Dhivehi font available or not but then again it does require the client to have Flash installed and enabled. If you are only seeking to have nice one-line headline sort of text in Dhivehi then you might consider using sIFR.

Refer to Font Embedding help page at Adobe LiveDocs for details on font embedding in Flash.



5. WEFT

Web Embedding Fonts Tools is a Internet Explorer only solution offered by Microsoft. It involves using the Windows-only WEFT utility to create font "objects" that can then be placed on web pages. This method is not recommended unless the target only involves use of Internet Explorer.

Refer to Microsoft WEFT page for more information.



6. TrueDoc

TrueDoc is a solution offered by Bitstream Inc. It is a solution similar to Microsoft's WEFT in that TrueDoc solutions create a embeddable font resource called a Portable Font Resource. Any font (ie. Dhivehi font) can be loaded once users install a custom font "viewer" (called the Character Shape Player by the company). This solution is NOT free and requires the purchase of special software from BitStream to produce the custom embeddable font packages.

Refer to the TrueDoc site for more information.



Good luck ;-)

Update (24-Nov-2008): Method 1 and 2 rewritten for clarity and demos added.

JavaScript Dhivehi Character Recognition

Here is another of my pet projects brought back from the land of the deceased.

This one is called "JavaScript Dhivehi Character Recognition". It was created early 2003 (or maybe late 2002) and made available on bichoo.net. Basically, it lets you draw a Thaana character using your mouse and then it "recognizes" what you have drawn. The purpose was mostly to satisfy my curiosity into artificial intelligence and pattern recognition at the time, however it also showed promises of the beginnings of a future where Dhivehi documents maybe scanned in and processed by a computer to convert it to text just as Optical Character Recognition technology has been doing for English documents. I think this rudimentary application was the first ever Dhivehi character recognition implementation released to the public. More interestingly, this seems to be the only character recognition implementation programmed in JavaScript floating around on the Internet even now. :-D

I spent a bit of time tonight reworking some bits of the code for clarity. The entire implementation is done using JavaScript and DHTML. You are welcome to study the code to see how it works. The code is well commented and maybe a good starter into AI and pattern recognition basics. It uses a single layer single Perceptron model to really simplify things however it is a good enough practical implementation to work for characters drawn on a 10x10 grid. The grid makes up the input data to the neural network. The neural network is hard-coded into the page and has definitions for each character in the alphabet. I do hope you are surprised by the accurateness of the recognition of this little application.

Have a look at it HERE. Let me know if you find it amusing... or not.

My company - Technova Pvt Ltd - is currently working on bringing a full fledged Dhivehi OCR software to the Maldivian public. It will probably be made available early 2006, as a service for customers requiring bulk OCR processing. We shall be releasing Windows, Linux and Mac versions of the software for home and business use around mid 2006.

Two years with magnetic implants

The 22nd of this December marked the completion of two years since I had magnets implanted into the middle and ring fingers of my left hand in the hopes of developing a new type of human-machine interface while at University. The research was finally published in our paper "A Novel Human-Machine Interface using Subdermal Magnetic Implants" in the Proc. IEEE International Conference on Cybernetic Intelligent Systems in September this year.

Looking back, it is amusing to see that I had made a post on this blog on my initial thoughts on the possibility of an interface being developed from magnetic implants around the time I first came up with the idea for it. And looking further back, it is kind of embarassing to see the over-excited mildly juvenile post I had made after attending a lecture by Prof. Kevin Warwick, with whom I ended up publishing my first paper with!

Anyway, here is a very recent X-ray image of my hand showing the current state of the 3mm diameter, 0.7mm thick neodymium disc magnets I have implanted in my fingers.



As the X-ray image shows, the magnet in the middle finger stands perpendicular to the phalanx while the one in the ring finger lies parallel. I had intended both magnets to lie parallel to the bone but an unfortunate injury in the first few days post-implantation upset the magnet in the middle finger and eventually had it settle in the position it is in now. I had anticipated pain and other potential issues from to the increased pressure levied on tissue by the edge of the magnet during gripping due to the position it had moved to. Luckily, except for a few situations involving a lot of pressure applied on the finger pad it has not been an issue at all.

The ring finger implant has remained without incident and is the most sensitive to external magnetic fields. Hopefully, it will continue to be like that in the years to come!

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.

Flight from Gan to Hulhule in Google Earth

I took the flight operated by Maldivian on the way back to Male' from a little holiday to Fuvahmulah and Addu atolls last month and logged the flight path using the GPS on my phone. I finally had a moment today to pass the track log to Google Earth and look at it inside the program's great 3D visualization of the globe. And it looks atleast as cool as I had hoped!

The journey was logged from boarding to landing, from the Gan International Airport in Addu Atoll to Hulhule International Airport in Male' Atoll. To log the flight path, I used the free and very capable OruxMaps application for Android on my Google Nexus One phone (which was put in flight mode throughout). The track log was exported from OruxMaps as a GPX format file which can be read easily by Google Earth. The free application TourMaker helped convert the GPX data to KML code for a nice Google Earth "tour" of the path, which then I tweaked by hand a little bit to fit my liking.

Anyway, check out the video of the tour I made below. I am putting up for download, the raw GPX data (which contains latitude/longitude, timestamp, altitude, bearing and speed information) and the Google Earth KMZ files I made (one showing the flight path with altitude and the other a tour).

- Gan to Hulhule flight: GPX GPS log (Zip, 54KB)
- Gan to Hulhule flight: Google Earth tour (Kmz, 40KB)
- Gan to Hulhule flight: Google Earth track (Kmz, 37KB)


"We, Machines" lecture

(I am a bit late in posting it here but...) I would like to convey a big thank you to all those who attended my recent lecture, "We, Machines" at the 6th edition of the Buraasfathivaru series, and the organisers "26". I hope the lecture imparted something of value and provided some food for thought.

We, Machines - Lecture promo

Orion: A view from the Maldives

At some point in your life, when you looked up at the night sky, chances are you spotted the unforgettable three bright stars in a line that make up the "belt" in the Orion constellation. It was the first constellation I learnt when I was a kid and started to grow a fascination towards the cosmos. Male' has too much light pollution to take a decent picture of the night sky so I took the chance to snap a shot of the constellation which stood out of the dark night canopy when I made a stopover at GA. Nilandhoo recently. Orion and Hyades are both distinctly visible in the picture.

The three stars which make up the Belt of Orion lie at different distances from the Earth despite appearing to be in the same line-of-sight. The reddish coloured star in the constellation is Betelgeuse (pronounced beetle-juice) and is one of the most brightest stars in the night sky. It is nearing the end of its life and is expected to be so bright when it explodes that it would be visible during the day!

GOCE satellite: Maldives 100 meters below

Being a Maldivian, the thing that jumps out the most on the just recently released gravity model produced from the high resolution measurements of gravitational pull across the Earth, gathered by the European Space Agency's GOCE satellite, is that Maldives is located within a curious blob of colour - the only blob of that colour in the map. The colour blob, it turns out, signifies areas where the difference between the geoid (a hypothetical global mean sea level undisturbed by weather and currents) and the perfect ellipsoid shape that Earth approximates overall, sinks to its lowest of -100m!

Apart from that, this reaffirms that the gravitational pull experienced in the Maldives is lower than most places on Earth...

GOCE Model
Credits: GOCE High Level Processing Facility

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... :-)