0

From what I understand, it's up to fonts to turn Arabic (and Persian) characters from their canonical forms (Unicode around 600) to their glyph forms (Unicode around FB00) where appropriate.

(Arabic letters can be connected to their last and/or next character so they usually have 4 different glyph forms)

I am now trying to draw charts using Vaadin with labels which may contain such letters and some specific letters (like 'ک' or 'ی') stay in their base form no matter where they appear in the word, like what I expect is "الکتاب" and what I get is "ال‍‌ک‌‍تاب".

The solution I thought of was to manually change every letter into its appropriate glyph form using a HashMap of base forms to an array of glyph forms, but I believe there should be a way to do this in java's libraries. I have seen this answer which does a similar thing using GlyphVector on a font but it's kind of complicated for my case.

Thanks in advance.

  • Trying to manually fix the faults of your text layouting engine *could* work, but (as you realized) is pretty complicated (that's why we usually leave that work to the text layouting engine). Before I'd go down that route I'd try to figure out why the characters don't get displayed correctly and if it's everywhere ... can you display the same text just fine in a boring old text field? Is it just when doing charts? In all parts of the chart? – Joachim Sauer Jun 22 '22 at 08:44
  • @JoachimSauer I tested labels and chart headers for my pie charts and both had this problem. And I don't know if there is such a thing as normal text field in Vaadin... although I kind of don't get how it could be different? Also thanks for the quick reply – Gilded Json Jun 22 '22 at 09:23
  • I don't know about charts, but this right-to-left Vaadin demo shows Farsi alphabet (very similar to Arabic) just fine: https://github.com/vaadin/bookstore-example/tree/rtl-demo. This is a live demo of the code: https://demo.vaadin.com/bookstore-example-rtl/. – Tarek Oraby Jul 06 '22 at 08:17

0 Answers0