ltkx

GUI toolkit for X11 (WIP)
git clone git://lumidify.org/ltkx.git
Log | Files | Refs | README | LICENSE

commit 9c62c13ad2f58414b7de5dd1b928c9dd780df8cc
parent 6dd04b169616da62128fa4e952b005d6139c9100
Author: lumidify <nobody@lumidify.org>
Date:   Thu, 21 May 2020 22:09:45 +0200

Fix wrapping (was off by a few pixels)

Diffstat:
Mtext_buffer.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/text_buffer.c b/text_buffer.c @@ -127,8 +127,6 @@ ltk_text_line_wrap(struct ltk_text_line *tl, int max_width) { glyph = &cur->glyphs[i]; int cur_w = sl->w + cur_start - glyph->x_abs; if (cur_w > max_width) { - /* FIXME: fix behavior when line isn't wide enough for single char - (currently causes infinite loop) */ for (int j = i; j < cur->num_glyphs; j++) { if (cur->glyphs[j].cluster != glyph->cluster || j == cur->num_glyphs - 1 || sl->len == 0) { @@ -172,7 +170,10 @@ ltk_text_line_wrap(struct ltk_text_line *tl, int max_width) { int i = 0; while (i < cur->num_glyphs) { glyph = &cur->glyphs[i]; - int cur_w = sl->w + glyph->x_abs + glyph->info->w - cur_start; + /* FIXME: This uses x_advance instead of glyph width so it works correctly + together with the current shaping, but should it maybe take the largest + of the two? What if the glyph width is actually larger than x_advance? */ + int cur_w = sl->w + glyph->x_abs + glyph->x_advance - cur_start; if (cur_w > max_width) { for (int j = i; j >= 0; j--) { if (cur->glyphs[j].cluster != glyph->cluster ||