justify fix
This commit is contained in:
parent
8f4f76b0c5
commit
e327979831
|
@ -1422,9 +1422,17 @@ int line_empty(struct line *line)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct word *next_word(struct word *w)
|
||||||
|
{
|
||||||
|
while (w->next && w->next->img_align) /* skip margins */
|
||||||
|
w = w->next;
|
||||||
|
return w->next;
|
||||||
|
}
|
||||||
|
|
||||||
void line_justify(struct line *line, int width)
|
void line_justify(struct line *line, int width)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
int last_margin = 0;
|
||||||
struct word *w;
|
struct word *w;
|
||||||
int sp, spm, lw = 0;
|
int sp, spm, lw = 0;
|
||||||
int lnum = 0;
|
int lnum = 0;
|
||||||
|
@ -1433,8 +1441,11 @@ void line_justify(struct line *line, int width)
|
||||||
w = line->words;
|
w = line->words;
|
||||||
while (w) {
|
while (w) {
|
||||||
lw += w->w;
|
lw += w->w;
|
||||||
|
if (last_margin)
|
||||||
|
w->unbrake = 0;
|
||||||
if (!w->unbrake && !w->img_align)
|
if (!w->unbrake && !w->img_align)
|
||||||
lnum ++;
|
lnum ++;
|
||||||
|
last_margin = w->img_align;
|
||||||
w = w->next;
|
w = w->next;
|
||||||
}
|
}
|
||||||
if (lnum <=1 )
|
if (lnum <=1 )
|
||||||
|
@ -1445,7 +1456,7 @@ void line_justify(struct line *line, int width)
|
||||||
while (w) {
|
while (w) {
|
||||||
if (!w->img_align) {
|
if (!w->img_align) {
|
||||||
w->x = x;
|
w->x = x;
|
||||||
if (w->next && w->next->unbrake)
|
if (next_word(w) && next_word(w)->unbrake)
|
||||||
x += w->w;
|
x += w->w;
|
||||||
else {
|
else {
|
||||||
x += w->w + sp + ((spm)?1:0);
|
x += w->w + sp + ((spm)?1:0);
|
||||||
|
@ -3320,9 +3331,8 @@ void _txt_layout_add(layout_t lay, char *txt)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m->w = layout->w - x2 - w2 + w;
|
m->w = layout->w - x2 - w2 + w;
|
||||||
|
// fprintf(stderr,"w: %d %d %d\n", width, w, width - w);
|
||||||
width -= w;
|
width -= w;
|
||||||
|
|
||||||
m->h = h;
|
m->h = h;
|
||||||
m->y = line->y;
|
m->y = line->y;
|
||||||
m->align = img_align;
|
m->align = img_align;
|
||||||
|
|
Loading…
Reference in a new issue