URI: 
       tHey, at least it does *something* useful now... - ltkx - GUI toolkit for X11 (WIP)
  HTML git clone git://lumidify.org/ltkx.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 314d62ddd8c698b01e5f97dce74189beeee3e010
   DIR parent 5fd0eb1d2fa742e6ea257992acb0edee773b6f24
  HTML Author: lumidify <nobody@lumidify.org>
       Date:   Thu, 14 May 2020 18:01:25 +0200
       
       Hey, at least it does *something* useful now...
       
       Well, I still don't know why that one character is drawn as a box.
       Oh, and maybe I should make the line wrapping work properly at some time.
       
       Diffstat:
         M test1.c                             |       2 +-
         M text-hb.c                           |       2 +-
         M text_buffer.c                       |      23 +++++++++++++----------
       
       3 files changed, 15 insertions(+), 12 deletions(-)
       ---
   DIR diff --git a/test1.c b/test1.c
       t@@ -38,6 +38,6 @@ int main(int argc, char *argv[])
                //LtkButton *button4 = ltk_create_button(window1, "پَیدایش", NULL);
                LtkTextEdit *edit = ltk_create_text_edit(window1, "ہمارے بارے میں blablabla");
                ltk_grid_widget(button4, grid1, 1, 0, 1, 1, LTK_STICKY_TOP | LTK_STICKY_BOTTOM | LTK_STICKY_RIGHT);
       -        ltk_grid_widget(edit, grid1, 1, 1, 1, 1, LTK_STICKY_LEFT | LTK_STICKY_BOTTOM | LTK_STICKY_TOP | LTK_STICKY_RIGHT);
       +        ltk_grid_widget(edit, grid1, 1, 1, 1, 1, LTK_STICKY_LEFT | LTK_STICKY_BOTTOM | LTK_STICKY_TOP);
                ltk_mainloop();
        }
   DIR diff --git a/text-hb.c b/text-hb.c
       t@@ -225,7 +225,7 @@ ltk_create_text_segment(LtkTextManager *tm, uint32_t *text, unsigned int len, ui
                hb_direction_t dir = hb_script_get_horizontal_direction(script);
                hb_buffer_set_direction(buf, dir);
                hb_buffer_set_script(buf, script);
       -        hb_buffer_add_codepoints(buf, ts->str, len, 0, len);
       +        hb_buffer_add_utf32(buf, ts->str, len, 0, len);
                /* According to https://harfbuzz.github.io/the-distinction-between-levels-0-and-1.html
                 * this should be level 1 clustering instead of level 0 */
                hb_buffer_set_cluster_level(buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
   DIR diff --git a/text_buffer.c b/text_buffer.c
       t@@ -141,21 +141,22 @@ ltk_render_text_line_new(
                   loop in case tl->first_run is NULL, but I should probably decide what
                   to do in that case */
                int index;
       -        cur_x = max_width;
                while (cur) {
                        for (int k = 0; k < cur->num_glyphs; k++) {
                                index = HB_DIRECTION_IS_BACKWARD(cur->dir) ? cur->num_glyphs - k - 1 : k;
                                glyph = &cur->glyphs[index];
       -                        cur_x -= glyph->x_advance;
       -                        if (cur_x < 0) {
       -                                cur_x = max_width - glyph->x_advance;
       +                        x = par_is_rtl ? max_width - ((tl->w - glyph->x_abs) - cur_line_x) : glyph->x_abs - cur_line_x;
       +                        if (par_is_rtl && x < 0) {
                                        cur_line++;
       -                                cur_line_x += glyph->x_abs - cur_line_x;
       -                                x = max_width - (glyph->x_abs - cur_line_x) - glyph->info->w;
       +                                cur_line_x = (tl->w - glyph->x_abs - glyph->info->w);
       +                                x = max_width - ((tl->w - glyph->x_abs) - cur_line_x);
       +                        } else if (!par_is_rtl && x + glyph->info->w > max_width) {
       +                                cur_line++;
       +                                cur_line_x = glyph->x_abs;
       +                                x = glyph->x_abs - cur_line_x;
                                }
       -                        //x = par_is_rtl ? max_width - (glyph->x_abs - cur_line_x) - glyph->info->w : glyph->x_abs - cur_line_x;
       -                        x = cur_x;
                                y = glyph->y_abs + tl->h * cur_line;
       +                        /* FIXME: remove this when everything's fixed */
                                if (x < 0)
                                        x = 0;
                                if (x > max_width - glyph->info->w)
       t@@ -388,10 +389,12 @@ ltk_text_run_shape(LtkTextManager *tm, struct ltk_text_run *tr,
                tr->num_glyphs = 0;
        
                buf = hb_buffer_create();
       -        hb_buffer_set_direction(buf, tr->dir);
       +        //hb_buffer_set_direction(buf, tr->dir);
       +        /* I think FriBidi already mirrors everything */
       +        hb_buffer_set_direction(buf, HB_DIRECTION_LTR);
                hb_buffer_set_script(buf, tr->script);
                /* WARNING: vis_buf has to be normalized (without gap) for this! */
       -        hb_buffer_add_codepoints(buf, tl->vis_buf->buf, tl->len, tr->start_index, tr->len);
       +        hb_buffer_add_utf32(buf, tl->vis_buf->buf, tl->len, tr->start_index, tr->len);
                /* According to https://harfbuzz.github.io/the-distinction-between-levels-0-and-1.html
                 * this should be level 1 clustering instead of level 0 */
                hb_buffer_set_cluster_level(buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);