aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2012-12-11 09:23:43 +0100
committerThomas White <taw@bitwiz.org.uk>2012-12-11 09:23:43 +0100
commit56109835bcea6b452fa39737809107754ad2ac3d (patch)
tree3fb58ca1d51d61bd418b7ce396aff9305bd930f1 /src
parent6df7d9f92e515a23d7d00ec989663b8a216d3491 (diff)
Measure height at end
Diffstat (limited to 'src')
-rw-r--r--src/render.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/render.c b/src/render.c
index a1024f6..0caef1e 100644
--- a/src/render.c
+++ b/src/render.c
@@ -59,7 +59,10 @@ struct wrap_box
struct wrap_line
{
- int width; /* Pango units */
+ int width;
+ int height; /* Pango units */
+ double ascent;
+ double descent; /* Cairo units */
int n_boxes;
int max_boxes;
@@ -78,12 +81,6 @@ struct renderstuff
const char *cur_text;
int cur_len;
- double ascent;
- double descent;
-
- double width;
- double height;
-
int wrap_w; /* Pango units */
/* Lines of boxes, where each box can be a load of glyphs, an image,
@@ -257,6 +254,7 @@ static void wrap_text(gpointer data, gpointer user_data)
}
ptr = add_chars_to_line(s, &gitem, pos, ptr);
+
for ( i=0; i<s->n_lines; i++ ) {
printf("Line %2i, width = %i\n", i, s->lines[i].width);
}
@@ -338,12 +336,13 @@ static void render_boxes(struct wrap_line *line, struct renderstuff *s)
static void render_lines(struct renderstuff *s)
{
int i;
- double spacing = (s->ascent+s->descent)/PANGO_SCALE;
- double ascent = s->ascent/PANGO_SCALE;
cairo_set_source_rgba(s->cr, 0.4, 0.0, 0.7, 1.0);
for ( i=0; i<s->n_lines; i++ ) {
+ double spacing = (s->lines[i].ascent+s->lines[i].descent);
+ double ascent = s->lines[i].ascent;
+
/* Move to beginning of the line */
cairo_move_to(s->cr, 0.0, ascent + i*spacing);
@@ -364,6 +363,7 @@ static int render_sc(struct frame *fr, double max_w, double max_h)
SCBlockList *bl;
SCBlockListIterator *iter;
struct scblock *b;
+ int i;
if ( fr->sc == NULL ) return 0;
@@ -400,15 +400,21 @@ static int render_sc(struct frame *fr, double max_w, double max_h)
}
sc_block_list_free(bl);
+ w = 0.0; h = 0.0;
+ for ( i=0; i<s.n_lines; i++ ) {
+ if ( s.lines[i].width > w ) w = s.lines[i].width;
+ h += s.lines[i].height;
+ }
+ w /= PANGO_SCALE;
+ h /= PANGO_SCALE;
+
/* Determine width */
- w = s.width / PANGO_SCALE;
w += fr->lop.pad_l + fr->lop.pad_r;
- if ( fr->lop.use_min_w && (s.width < fr->lop.min_w) ) {
+ if ( fr->lop.use_min_w && (w < fr->lop.min_w) ) {
w = fr->lop.min_w;
}
if ( w > max_w ) w = max_w;
- h = s.height / PANGO_SCALE;
h += fr->lop.pad_t + fr->lop.pad_b;
if ( fr->lop.use_min_h && (h < fr->lop.min_h) ) {
h = fr->lop.min_h;