Grodriguez
Grodriguez

Reputation: 22025

Arabic text in Java AWT

I need to modify an existing Java application to display some (static) text in Arabic. The problem is that this Java application runs on devices that only support Java 1.1 (yes, I know. I have to live with that).

I know that Swing supports RTL languages, however I can only use AWT. The application does not use any heavyweight components; all text is drawn using Graphics.drawString().

Is this possible at all? (without implementing a text rendering engine from scratch, I mean). Can someone point to existing examples? Any useful advice?

Thanks!

Upvotes: 1

Views: 579

Answers (2)

Grodriguez
Grodriguez

Reputation: 22025

I have managed to successfully solve this by combining an arabic "reshaper" algorithm that is used to pre-process each arabic word in the string with a custom BiDi implementation.

Rendering works perfectly well in all cases I've tried so far.

Just in case someone else had the same problem, be it with Java 1.1 or with any other environment not supporting arabic natively (in fact the reshaper linked above was originally written from Android).

Edit:

The original link does not work anymore, but the code is now available in github: https://github.com/agawish/Better-Arabic-Reshaper/

Upvotes: 0

bmargulies
bmargulies

Reputation: 100161

If it's really static, make some bitmaps. You won't get the rendering to work.

Upvotes: 1

Related Questions