17

I'm working on android application and I'm trying to write arabic number inside arabic end of ayah symbol (۝) into textview. I've tried to write the end of ayah symbol then the arabic number without any space but it didn't work. I'm using uthmani font.

I want to display it like this picture:

This is part of the code

    NumberFormat nf = NumberFormat.getInstance(Locale.forLanguageTag("AR"));
    temp+="  "+"\u06DD"+String.valueOf(nf.format(count))+" ";

"\u06DD" is the encoding of (۝) in java.

The result became like this:

ouflak
  • 2,458
  • 10
  • 44
  • 49
shahd
  • 171
  • 1
  • 1
  • 4
  • 1
    Salem how about a textView with the symbol of the ayah as the background. –  Jan 27 '16 at 16:35

7 Answers7

8

You can use font named me_quran with these unicodes U+FD3E + numbers + U+FD3F

﴿ ORNATE RIGHT PARENTHESIS Unicode: U+FD3F, UTF-8: EF B4 BF

﴾ ORNATE LEFT PARENTHESIS Unicode: U+FD3E, UTF-8: EF B4 BE

You can download the font file from here

Example of usage: Quran Verse end with numbers inside

Khaled Annajar
  • 15,542
  • 5
  • 34
  • 45
5

Try something like this ﴾١٩٦﴿ which looks like ﴾١٩٦﴿

Chand
  • 521
  • 5
  • 8
4

I just reversed the format and it worked

NumberFormat nf = NumberFormat.getInstance(Locale.forLanguageTag("AR"));
textView.setText(String.valueOf(nf.format(285))+"\u06DD");

(font was roboto)

Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55
Cem
  • 41
  • 2
4

In Flutter, you can use quran package. getVerseEndSymbol(int verseNumber) function will return aya end symbol with the given verse number.

Example:

Text(
      quran.getVerse(18, index + 1) + getVerseEndSymbol(index + 1),
      textAlign: TextAlign.right,
),

This will return the symbol with the given verse number.

enter image description here

Aqeel
  • 804
  • 1
  • 11
  • 15
3

If you are using uthmanic font "KFGQPC Uthmanic Script HAFS Regular", you just enter a number in arabic like this "٤٤" and it will be rendered as end verse symbol with the number:
just typed the arabic number

ouflak
  • 2,458
  • 10
  • 44
  • 49
Mohammed Safvan
  • 193
  • 1
  • 10
2

for swift use this code for quran aya ending code addition:

let arabicAyaStyle = "\u{FD3F}" + "\(getArabicDigitFor(value:verseObj.verseId))" + "\u{FD3E}"

append arabicAyaStyle to end of any aya text.

func getArabicDigitFor(value:Int) -> String
    {
        let numberToConvert = NSNumber(value: value)

        let formatter = NumberFormatter()

        let arLocale = Locale(identifier: "ar")
        formatter.locale = arLocale

        return formatter.string(from: numberToConvert)!

    }
Usman Nisar
  • 3,031
  • 33
  • 41
  • there are optimisation issues in center positioning and corrupting sometimes end of line. – ATES Jan 29 '21 at 20:11
1

You can use ReplacementSpan to alter how the aya number is rendered

for example this is how I did it

public class EndOfAyaSpan extends ReplacementSpan
{

    public RoundedBackgroundSpan(Context context)
    {
        super();
    }

    @Override
    public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint)
    {
        float textSize = paint.getTextSize();
        canvas.drawText("\u06dd ", 0, 1, x - textSize / 5, (float) y, paint);
        paint.setTextSize(textSize - textSize / 3);
        canvas.drawText(text, start, end, x, y - textSize / 5, paint);
        paint.setTextSize(textSize);
    }

    @Override
    public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm)
    {
        return Math.round(paint.measureText(text, start, end));
    }

}