commit 314d62ddd8c698b01e5f97dce74189beeee3e010
parent 5fd0eb1d2fa742e6ea257992acb0edee773b6f24
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:
3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/test1.c b/test1.c
@@ -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();
}
diff --git a/text-hb.c b/text-hb.c
@@ -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);
diff --git a/text_buffer.c b/text_buffer.c
@@ -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)
@@ -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);