Search in sources :

Example 6 with BidiRun

use of com.mta.tehreer.unicode.BidiRun in project Tehreer-Android by mta452.

the class BidiInfoActivity method writeParagraphText.

private void writeParagraphText(SpannableStringBuilder builder, BidiParagraph paragraph, int index) {
    int paragraphStart = paragraph.getCharStart();
    int paragraphEnd = paragraph.getCharEnd();
    int paragraphLength = paragraphEnd - paragraphStart;
    String paragraphText = ((paragraph.getBaseLevel() & 1) == 1 ? RLI : LRI) + mBidiText.substring(paragraphStart, paragraphEnd) + PDI;
    appendText(builder, "Paragraph " + index + "\n", spansFirstHeading());
    appendText(builder, "Paragraph Text:", spansInlineHeading());
    appendText(builder, " “" + paragraphText + "”\n");
    appendText(builder, "Paragraph Range:", spansInlineHeading());
    appendText(builder, " Start=" + paragraphStart + " Length=" + paragraphLength + "\n");
    appendText(builder, "Base Level:", spansInlineHeading());
    appendText(builder, " " + paragraph.getBaseLevel() + "\n\n");
    int counter = 1;
    for (BidiRun bidiRun : paragraph.getLogicalRuns()) {
        writeRunText(builder, bidiRun, counter);
        counter++;
    }
    BidiLine line = null;
    try {
        line = paragraph.createLine(paragraphStart, paragraphEnd);
        writeLineText(builder, line);
        writeMirrorsText(builder, line);
    } finally {
        if (line != null) {
            line.dispose();
        }
    }
    appendText(builder, "\n");
}
Also used : BidiRun(com.mta.tehreer.unicode.BidiRun) BidiLine(com.mta.tehreer.unicode.BidiLine)

Aggregations

BidiRun (com.mta.tehreer.unicode.BidiRun)6 BidiParagraph (com.mta.tehreer.unicode.BidiParagraph)4 BidiLine (com.mta.tehreer.unicode.BidiLine)3 ShapingEngine (com.mta.tehreer.sfnt.ShapingEngine)2 WritingDirection (com.mta.tehreer.sfnt.WritingDirection)2 BaseDirection (com.mta.tehreer.unicode.BaseDirection)2 BidiAlgorithm (com.mta.tehreer.unicode.BidiAlgorithm)2 Paint (android.graphics.Paint)1 SparseIntArray (android.util.SparseIntArray)1 ShapingOrder (com.mta.tehreer.sfnt.ShapingOrder)1 ScriptClassifier (com.mta.tehreer.unicode.ScriptClassifier)1 ScriptRun (com.mta.tehreer.unicode.ScriptRun)1