Problems with Persian(Farsi) text,display characters separately


Guys i have problems with display Persian(Farsi) strings.
There was an example in the github for Arabic fonts with unicode strings.
The first thing Arabic is different with Persian(Farsi) they haven’t at least 4 characters from Persian(Farsi) .

in that example, you guys have converted what you want to Arabic Presentation Forms-B Unicode with 3rd party apps.
this is not suitable and not possible for me to find out a working 3rd party converter that can convert the Persian text to correct unicode.
because (almost) each character in Persian have 4,5 style to show .

  1. if the charter was in binning of word .
  2. if the charter was in middle of word .
  3. if the charter was in end of word .

they are have different look and will make word not separately.

i made a font for Persian text and applied it to text, but if i use plain text (not Arabic Presentation Forms-B Unicode) it shows separately

Font font = Font.getFont(82, 40, Font.STYLE_PLAIN); g.setFont(font); g.setColor(Colors.NAVY); String s = "سلام"; StringBuilder buf = new StringBuilder(); buf.append(s).reverse(); g.drawString(buf.toString(), width / 2, height / 2, GraphicsContext.HCENTER | GraphicsContext.VCENTER); y += font.getHeight() + PADDING_TEXT;

as you see i didnt convert the text because microej is doing it itself to normal unicode table.

but there is 2 problem.

  1. The text should be reverse because Persian(Farsi) is RTL . (that will be problem for thousands of characters)
  2. The text characters displaying desperately not get together as a word, it is because the micrej not detect models Persian characters.

for make this working i need to read the source code of MicroUI and other related things then change it to solve this problem , or what you guys will tell me to solve this problem :slight_smile:

the last things is also i cant convert the string to unicode in microEJ java the out put is not unicode anymore, and also is normal unicode not the Arabic Presentation Forms-B Unicode,it is plain text because of limitation.

private static String toUnicode(char ch) { String s = new String("\\u0" + Integer.toHexString(ch)); return s; }


Hi Armin,

I’m sorry but we do not support Farsi in our UI stack. For now it is also not planned in the near future.

Gaëtan for MicroEJ

1 Like

I can add it myself but i need UI source codes .
Can you help with this?

Hi @Biftor,

Unfortunately this part of the UI stack is closed-source for now so I cannot provide the source.


1 Like

i wish i could have that source and edit it my self because ,i am doing a project with microej in Farsi and i need it.
btw i have only one choice left to solve this problem, that is a Arabic text to Forms-B Unicode converter like exactly what you guys did in github example.

can you give me a converter for Arabic Presentation Forms-B Unicode ?
all what i found is general Unicode converter.

how to do it?

Then your strings must be formed with the characters of this range too (as you can see with the strings of HowToUseArabicFontDisplayable.TITLE and HowToUseArabicFontDisplayable.AVAILABLE_TEXTS, /u0020 corresponds to the space character).

Hi Armin,

The converter you are talking about is embedded in the UI stack that is closed-source. So you cannot add an additional support easily.


Hi Gaëtan
Then why you guys have an example for showing users how to use Arabic strings, if there is no convertor for converting normal arabic text to Arabic Presentation Forms-B Unicode what exactly shows in the github example.

I am looking for a way to use farsi text because my project is farsi, no matter how much that is difficult but i need it, i really like MicroEJ .

I do not think I can help you more on that, the code of the convertor exists but is not available publicly. My hands are tied on this one. If you really want the support for the Farsi language you could ask for a quote from MicroEJ sales department.


Thanks for all your helps,i will try to figure it out :slight_smile: