summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/text.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index a2d9f681..3683aee4 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -1526,19 +1526,36 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) {
1526 wrapAdvance += advance_GlyphBuffer_(at_Array(&buffers, i), wrapPosRange); 1526 wrapAdvance += advance_GlyphBuffer_(at_Array(&buffers, i), wrapPosRange);
1527 } 1527 }
1528 } 1528 }
1529 /* Reorder the run indices according to text direction. */
1530 iArray runOrder; 1529 iArray runOrder;
1531 init_Array(&runOrder, sizeof(size_t)); 1530 init_Array(&runOrder, sizeof(size_t));
1532 size_t rtlStartIndex = iInvalidPos; 1531 /* Reorder the run indices according to text direction. */ {
1533 for (size_t runIndex = wrapRuns.start; runIndex < wrapRuns.end; runIndex++) { 1532 size_t oppositeInsertIndex = iInvalidPos;
1534 if (attrText.isBaseRTL) { 1533 for (size_t runIndex = wrapRuns.start; runIndex < wrapRuns.end; runIndex++) {
1535 if (rtlStartIndex == iInvalidPos) { 1534 const iAttributedRun *run = at_Array(&attrText.runs, runIndex);
1536 rtlStartIndex = size_Array(&runOrder); 1535 if (!attrText.isBaseRTL) { /* left-to-right */
1536 if (run->flags.isRTL) {
1537 if (oppositeInsertIndex == iInvalidPos) {
1538 oppositeInsertIndex = size_Array(&runOrder);
1539 }
1540 insert_Array(&runOrder, oppositeInsertIndex, &runIndex);
1541 }
1542 else {
1543 pushBack_Array(&runOrder, &runIndex);
1544 oppositeInsertIndex = iInvalidPos;
1545 }
1546 }
1547 else { /* right-to-left */
1548 if (!run->flags.isRTL) {
1549 if (oppositeInsertIndex == iInvalidPos) {
1550 oppositeInsertIndex = 0;
1551 }
1552 insert_Array(&runOrder, oppositeInsertIndex++, &runIndex);
1553 }
1554 else {
1555 pushFront_Array(&runOrder, &runIndex);
1556 oppositeInsertIndex = iInvalidPos;
1557 }
1537 } 1558 }
1538 insert_Array(&runOrder, rtlStartIndex, &runIndex);
1539 }
1540 else {
1541 pushBack_Array(&runOrder, &runIndex);
1542 } 1559 }
1543 } 1560 }
1544#if 0 1561#if 0