diff options
author | Thomas White <taw@bitwiz.org.uk> | 2013-03-07 23:28:23 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2013-03-07 23:28:23 +0100 |
commit | b4fa75b9ac5160dae40c4763ba87927762d4e75f (patch) | |
tree | 3e39da4341f93129900a1a22b3ad7f1e92272505 /src | |
parent | d9c5d4dc8b80a151eb36fe47fa13b746103e773c (diff) |
Wrapping and rendering fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/render.c | 15 | ||||
-rw-r--r-- | src/wrap.c | 6 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/render.c b/src/render.c index 3aa3d05..0aaee64 100644 --- a/src/render.c +++ b/src/render.c @@ -106,24 +106,27 @@ static void render_lines(struct frame *fr, cairo_t *cr) for ( i=0; i<fr->n_lines; i++ ) { - double asc = pango_units_to_double(fr->lines[i].ascent); + cairo_save(cr); + + /* Move to beginning of the line */ + cairo_translate(cr, 0.0, y_pos); - cairo_move_to(cr, 0, y_pos+asc+0.5); + cairo_move_to(cr, 0.0, + 0.5+pango_units_to_double(fr->lines[i].ascent)); cairo_line_to(cr, pango_units_to_double(fr->lines[i].width), - y_pos+asc+0.5); + 0.5+pango_units_to_double(fr->lines[i].ascent)); cairo_set_source_rgb(cr, 0.0, 0.0, 1.0); cairo_set_line_width(cr, 1.0); cairo_stroke(cr); - /* Move to beginning of the line */ - cairo_move_to(cr, 0.0, asc+y_pos); - /* Render the line */ render_boxes(&fr->lines[i], cr); /* FIXME: line spacing */ y_pos += pango_units_to_double(fr->lines[i].height) + 0.0; + cairo_restore(cr); + } } @@ -468,7 +468,7 @@ static void output(int a, int i, int *p, struct frame *fr, l->max_boxes = s-q; alloc_boxes(l); - for ( j=q+1; j<=s; j++ ) { + for ( j=q; j<s; j++ ) { l->boxes[l->n_boxes++] = boxes->boxes[j]; } @@ -528,13 +528,13 @@ static void knuth_suboptimal_fit(struct wrap_line *boxes, double line_length, } if ( reject ) return; - p = malloc(boxes->n_boxes*sizeof(int)); + p = calloc(boxes->n_boxes, sizeof(int)); if ( p == NULL ) { fprintf(stderr, "Failed to allocate p_k\n"); return; } - s = malloc(boxes->n_boxes*sizeof(double)); + s = calloc(boxes->n_boxes, sizeof(double)); if ( s == NULL ) { fprintf(stderr, "Failed to allocate s_k\n"); return; |