I have arabic content which is compound of words like ضضضضضضض
. I want to get the width of the first letter of a given word ( which is not the same as the width of an independent letter i.e. ض
).
I used getBoundingClientRect()
method and tried to get the width , but it is giving the width of an independent character , not the compound one which's thiner than the returned value
by getBoundingClientRect
method
In the above word , the width of ض (first letter) given by getBoundingClientRect()
is 16.109375 , but the character is compound one i.e. visibily it is truncated as you see. It is less than the given value.
I tried and got the EXACT(visible) width of first letter by subtracting width given getBoundingClientRect()
by of first two characters and width of first character which would be 12px which is correct.
Is there any better method than this so that I can get exact visible width of every character like this in any word?
You should know that the unicode of what you see is not the unicode stored. All letters in your example ضضضضضضض
are stored as a standard Dhad ض
\u0636
but shown as:
ﺿ
\ufebf
(start)ﻀ
\ufec0
(middle)ﺾ
\ufebe
(end)ﺽ
\ufebd
(independent)So to get the real length, you should apply your length function on those representation unicodes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With