diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-02-14 21:23:10 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-02-14 21:23:10 +0100 |
commit | 28c89670f4352ef8392f2719afeace5a949052cb (patch) | |
tree | ec843a205a68a51cec8385f68699df7920ac7312 | |
parent | e960f56772d7b94349038efa1d733b6759eeefda (diff) |
Actually upgrade the box
-rw-r--r-- | src/sc_editor.c | 14 | ||||
-rw-r--r-- | src/shape.c | 6 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c index ddfe2df..48235c2 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -855,7 +855,17 @@ static void insert_text(char *t, SCEditor *e) if ( sbox->type == WRAP_BOX_NOTHING ) { printf("Upgrading nothing box to Pango box\n"); - return; + sbox->type = WRAP_BOX_PANGO; + sbox->col[0] = 0.0; + sbox->col[1] = 0.0; + sbox->col[2] = 0.0; + sbox->col[3] = 0.0; + sbox->n_segs = 1; + sbox->segs = malloc(sizeof(struct text_seg)); + sbox->len_chars = 0; + sbox->segs[0].glyphs = NULL; + sbox->segs[0].offs_char = sbox->offs_char; + sbox->segs[0].len_chars = 0; } sseg = which_segment(sbox, sps, &err); @@ -885,6 +895,8 @@ static void insert_text(char *t, SCEditor *e) struct wrap_box *nbox; + printf("Adding line break\n"); + /* Add a new box containing the text after the break */ insert_box(&e->cursor_frame->lines[sln], sbx); nbox = &e->cursor_frame->lines[sln].boxes[sbx]; diff --git a/src/shape.c b/src/shape.c index 08ca8d1..3664780 100644 --- a/src/shape.c +++ b/src/shape.c @@ -42,13 +42,15 @@ static void shape_segment(struct wrap_box *box, struct text_seg *seg) const char *ep; tp = g_utf8_offset_to_pointer(sc_block_contents(box->scblock), - box->offs_char); + box->offs_char + seg->offs_char); ep = g_utf8_offset_to_pointer(sc_block_contents(box->scblock), - box->offs_char+box->len_chars); + box->offs_char + seg->offs_char + + seg->len_chars); if ( seg->glyphs != NULL ) { pango_glyph_string_free(seg->glyphs); } + printf("shaping '%s' (%i chars)\n", tp, seg->len_chars); seg->glyphs = pango_glyph_string_new(); pango_shape(tp, ep-tp, &seg->analysis, seg->glyphs); |