use of com.mta.tehreer.unicode.BidiLine in project Tehreer-Android by mta452.
the class ParagraphCollection method forEachLineRun.
public void forEachLineRun(int lineStart, int lineEnd, @NonNull RunConsumer runConsumer) {
int paragraphIndex = binarySearch(lineStart);
BidiParagraph directionalParagraph = get(paragraphIndex);
boolean isRTL = (directionalParagraph.getBaseLevel() & 1) == 1;
if (isRTL) {
int paragraphEnd = directionalParagraph.getCharEnd();
if (paragraphEnd < lineEnd) {
paragraphIndex = binarySearch(lineEnd - 1);
}
}
int next = (isRTL ? -1 : 1);
int feasibleStart;
int feasibleEnd;
do {
BidiParagraph bidiParagraph = get(paragraphIndex);
feasibleStart = Math.max(bidiParagraph.getCharStart(), lineStart);
feasibleEnd = Math.min(bidiParagraph.getCharEnd(), lineEnd);
BidiLine bidiLine = bidiParagraph.createLine(feasibleStart, feasibleEnd);
List<BidiRun> bidiRuns = bidiLine.getVisualRuns();
int runCount = bidiRuns.size();
for (int i = 0; i < runCount; i++) {
runConsumer.accept(bidiRuns.get(i));
}
bidiLine.dispose();
paragraphIndex += next;
} while (isRTL ? feasibleStart != lineStart : feasibleEnd != lineEnd);
}
use of com.mta.tehreer.unicode.BidiLine in project Tehreer-Android by mta452.
the class Typesetter method addContinuousLineRuns.
private void addContinuousLineRuns(int charStart, int charEnd, BidiRunConsumer runConsumer) {
int paragraphIndex = indexOfBidiParagraph(charStart);
int feasibleStart;
int feasibleEnd;
do {
BidiParagraph bidiParagraph = mBidiParagraphs.get(paragraphIndex);
feasibleStart = Math.max(bidiParagraph.getCharStart(), charStart);
feasibleEnd = Math.min(bidiParagraph.getCharEnd(), charEnd);
BidiLine bidiLine = bidiParagraph.createLine(feasibleStart, feasibleEnd);
for (BidiRun bidiRun : bidiLine.getVisualRuns()) {
runConsumer.accept(bidiRun);
}
bidiLine.dispose();
paragraphIndex++;
} while (feasibleEnd != charEnd);
}
use of com.mta.tehreer.unicode.BidiLine 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");
}
Aggregations