diff options
author | Thomas White <taw@bitwiz.org.uk> | 2013-03-16 09:21:46 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2013-03-16 09:21:46 +0100 |
commit | 960695dfa263812c201da2ff4e535ebb82808da3 (patch) | |
tree | e572f8154bcbe8e480e5d5b4b23e027d96284115 /src | |
parent | c2a43e72e4898659cf05bb8e68733f02a249e0a1 (diff) |
More space distribution
Diffstat (limited to 'src')
-rw-r--r-- | src/wrap.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -473,7 +473,7 @@ static void distribute_spaces_last_line(struct wrap_line *l, double w, static void distribute_spaces_normal_line(struct wrap_line *l, double w, - double sp) + double sp, double rho) { int i; int overfull = 0; @@ -482,6 +482,9 @@ static void distribute_spaces_normal_line(struct wrap_line *l, double w, if ( sp < sp_zp(l->boxes[i].space) ) { l->boxes[i].sp = sp_zp(l->boxes[i].space); overfull = 1; + } else if ( sp > sp_yp(l->boxes[i].space, rho) ) { + l->boxes[i].sp = sp_yp(l->boxes[i].space, rho); + printf("underfull.\n"); } else { l->boxes[i].sp = sp; } @@ -491,7 +494,7 @@ static void distribute_spaces_normal_line(struct wrap_line *l, double w, } -static void distribute_spaces(struct wrap_line *l, double w) +static void distribute_spaces(struct wrap_line *l, double w, double rho) { int i; double total; @@ -507,7 +510,7 @@ static void distribute_spaces(struct wrap_line *l, double w) if ( l->last_line ) { distribute_spaces_last_line(l, w, sp); } else { - distribute_spaces_normal_line(l, w, sp); + distribute_spaces_normal_line(l, w, sp, rho); } } @@ -567,12 +570,11 @@ static void output(int a, int i, int *p, struct frame *fr, * supposed to work as well as the full TeX algorithm in almost all of the cases * that we care about here. */ static void knuth_suboptimal_fit(struct wrap_line *boxes, double line_length, - struct frame *fr) + struct frame *fr, double rho) { int a = 0; int *p; double *s; - const double rho = 2.0; struct wrap_box *box; int j; double sigma_prime, sigma_max_prime, sigma_min_prime; @@ -782,6 +784,7 @@ int wrap_contents(struct frame *fr, PangoContext *pc) { struct wrap_line *boxes; int i; + const double rho = 2.0; const double wrap_w = fr->w - fr->lop.pad_l - fr->lop.pad_r; /* Turn the StoryCode into wrap boxes, all on one line */ @@ -791,12 +794,12 @@ int wrap_contents(struct frame *fr, PangoContext *pc) return 1; } - knuth_suboptimal_fit(boxes, wrap_w, fr); + knuth_suboptimal_fit(boxes, wrap_w, fr, rho); free(boxes->boxes); free(boxes); for ( i=0; i<fr->n_lines; i++ ) { - distribute_spaces(&fr->lines[i], wrap_w); + distribute_spaces(&fr->lines[i], wrap_w, rho); calc_line_geometry(&fr->lines[i]); } |