diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-07-14 11:18:38 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-07-14 11:18:38 +0300 |
commit | 1ee3fd5f9168ac080f7ab2558a6e6cb5cf9657c4 (patch) | |
tree | 93752f1162a9a81d90140977d1edf38d34cc58b8 /src/ui/text.c | |
parent | ddf6c998bf3be91bc72be5d2258577c46e60b0ad (diff) |
Text: Ordering runs vs. paragraph/run direction
Diffstat (limited to 'src/ui/text.c')
-rw-r--r-- | src/ui/text.c | 37 |
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 |