views:

35

answers:

0

Hi all,

I've figured out how to draw Arabic characters properly (connected and right to left) using string literals like this:

textView.setTypeFace(Typeface.createFromAssets(getAssets(),"DejaVuSans.ttf"));
textView.setText("\uFEB3\uFE92\uFE98\uFE94");

But for some reason I cannot get the arabic to format properly if I read anything from a file using InputStreams like this:

arabictext.txt:

سبتة

and the code:

InputStream istream = as.open("arabictext.txt");

     String string;
        BufferedInputStream bis = new BufferedInputStream(istream);

        /* Read bytes to the Buffer until
         * there is nothing more to read(-1). */
        ByteArrayBuffer baf = new ByteArrayBuffer(50);
        int current = 0;
        while((current = bis.read()) != -1){
                baf.append((byte)current);
        }

        /* Convert the Bytes read to a String. */
        string = new String(baf.toByteArray(), 0, baf.length(), "UTF-8");

and then displaying the string in a textview. The letters are ordered correctly but are not connected nor are they in the proper form for end of word/middle of word. This makes no sense to me because I thought that each form of each letter is a different Unicode code point.

2) Putting the actual code values in the file just causes the textview to display the code point values as a string.

Any help would be appreciated! I started to make a custom view to just draw the text, but it got complicated, fast.