views:

395

answers:

3

Hello,

I have a bunch of lines of Arabic text in UTF-8. The device I am trying to display this one does not support arabic text being displayed. Therefore, I need to convert the text into images.

I would like to save each line of text as an image with a specific width. I need to use a specific font as well. What is the best way to do this? Does anybody know of a tool that can be helpful here?

Problems I've run into so far:

PHP + GD: Arabic letters appear seperated and not in cursive as they should. VB.net: I can dump each line of text into a richtextbox... but I don't know how to export the image of just that control. Flash: no support for right to left text.

A: 

Try using imageloadfont() before the imagestring() in PHP, so you can choose a better font for your text.

Havenard
+1  A: 

There are many ways; using Windows.Forms for example, I think you:

  • Create an empty Image instance; I think that at this point you define the image's dimensions
  • Create a Graphics instance from the Image, using the Graphics.FromImage method
  • Invoke the method of the Control (the RichTextBox) which tells it to paint itself: and to that method, pass the Graphics instance associated with your image, so that it paints itself onto the image.
ChrisW
+1  A: 

I've heard that pango handles Arabic layout pretty well. haven't used it though.

Update:

The utility pango-view can render text in any language and output it as an image

$ pango-view input_file.txt --no-display --output=image.png

or you can supply the text as an option as well:

$ pango-view --no-display --output=image.png --text="your sentence"

You can also specify a width:

--width=50 -wrap=word

<< end of update

Alternatively, there are a few programs that use unicode characters that represent contextual Arabic letter forms and process text and make it render properly on systems that can't render Arabic text properly.

Here are the ones I know of:

They're all open source, so even if you don't use any of these languages, you can study the code and create a solution in your programming language of choice.

hasen j