在ayah结束阿拉伯语unicode符号内写数字

问题描述 投票:6回答:4

我正在研究android应用程序,我正在尝试在ayah符号(۝)的阿拉伯语结尾写入阿拉伯语数字到textview。我试图写一个ayah符号的结尾然后是没有任何空间的阿拉伯数字,但它没有用。我正在使用uthmani字体。

我想像这张图片一样显示:

这是代码的一部分

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

“\ u06DD”是java中(۝)的编码。

结果变成这样:

android ios unicode arabic
4个回答
2
投票

您可以使用名为me_quran的字体与这些unicodes U + FD3E +数字+ 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

用法示例:Quran Verse end with numbers inside


1
投票

试试像这样的﴾١٩٦﴿看起来像(196)


0
投票

您可以使用ReplacementSpan来更改aya数字的呈现方式

例如,这就是我做到的

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));
    }

}

0
投票

快速使用此代码为古兰经aya结束代码添加:

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

将arabicAyaStyle追加到任何aya文本的末尾。

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)!

    }
© www.soinside.com 2019 - 2024. All rights reserved.