我正在尝试在位图上绘制阿拉伯文本以进行显示:
Bitmap img = Bitmap.createBitmap( (int) f+100, 300, Config.RGB_565);
Canvas c = new Canvas();
c.setBitmap( img );
mFace = Typeface.createFromAsset(getAssets(),"DejaVuSansCondensed.ttf");
mPaint.setTypeface(mFace);
content = "يجري";
content = ArabicUtilities.reshape( content );
System.out.println("Drawing text: " + content);
c.drawText(content, 30, 30, mPaint);
ArabicUtilities类是一个工具,用于重塑unicode文本,使字母连接起来。参见:http://github.com/agawish/Better-Arabic-Reshaper/ 然而,生成的位图看起来像这样: alt text http://imagebin.ca/img/J1EB8DWc.jpg 当它应该看起来像يجري 我认为问题在于,与TextView不同,Bitmap类不具备双向文本处理能力,因此它从左到右绘制字母。
尽管我尝试了很多次,但我仍然无法弄清如何以正确的顺序绘制文本。