Width of individual letters in compound Arabic words

I have Arabic content, which is a compound word like ضضضضضضض . I want to get the width of the first letter of the word (which does not match the width of the independent letter ie ض ).

I used the getBoundingClientRect() method and tried to get the width, but it gives the width of the independent character, not the compound one, which is less than the returned value by getBoundingClientRect

In the above word, the width ض (first letter) specified by getBoundingClientRect() is 16.109375, but the character is compound, that is, apparently, it is truncated, as you see. This is less than the set value.

I tried and got the EXACT (visible) width of the first letter, subtracting the width indicated by getBoundingClientRect() , the first two characters and the width of the first character, which would be 12 pixels correct.

Is there any better way than this so that I can get the exact visible width of each character like this in any word?

+5
source share
1 answer

You should be aware that the unicode of what you see is not stored in Unicode. All letters in your example ضضضضضضض are saved as standard Dhad ض \u0636 , but are displayed as:

  • ﺿ \ufebf (start)
  • \ufec0 (medium)
  • \ufebe (end)
  • \ufebd (independent)

So, in order to get the real length, you have to apply your length function to these representation unicode.

+8
source

Source: https://habr.com/ru/post/1261660/


All Articles