Home > Enterprise >  Arabic font is not displayed correctly in TextView
Arabic font is not displayed correctly in TextView

Time:12-09

trying to add Arabic text to my project, but two problems arise:

  • the glyph for the letters ل and ا is not matched (لا)
  • the vowels aren't spaced correctly

It looks like: enter image description here

This is not a problem with the font, because in other programs it works as it should? textDirection="anyRtl" doesn't help

TextView:

<TextView
    android:id="@ id/text_ayah_text"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:fontFamily="@font/uthman_taha_naskh_regular"
    android:textSize="34sp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@id/barrier"
    app:layout_constraintTop_toTopOf="parent"
    tools:text="اللَّهُ لا إِلٰهَ إِلّا هُوَ الحَيُّ القَيّومُ" />

CodePudding user response:

//Add this code in java file
textview.setTextDirection(View.TEXT_DIRECTION_ANY_RTL).
//And in textview
android:textDirection="anyRtl"

CodePudding user response:

The problem was with the letterSpacing for TextView in the themes. Removed it and everything works fine

  • Related