}
if (i == 0) {
- p_.y = p.y + (double)(b.UR.y-b.LL.y)/2 - paras[i].lfsize * 0.9 ;
+ p_.y = p.y + (double)(b.UR.y-b.LL.y)/2. - paras[i].lfsize;
tmp = ROUND(p_.y); /* align with integer points */
p_.y = (double)tmp;
}
ti++;
}
/* position for next para */
- if(i != nparas-1)
- p_.y -= paras[i+1].lfsize * LINESPACING;
+ p_.y -= paras[i].lfsize * 1.3;
offset = 0.0;
}
fname = env->finfo.name;
}
sz = textsize(g, &lp, fname, fsize);
- w = sz.x;
free (ftxt->paras[i].items[j].str);
ftxt->paras[i].items[j].str = lp.str;
ftxt->paras[i].items[j].size = sz.x;
ftxt->paras[i].items[j].postscript_alias = lp.postscript_alias;
ftxt->paras[i].items[j].layout = lp.layout;
ftxt->paras[i].items[j].free_layout = lp.free_layout;
- width += w;
+ width += sz.x;
ftxt->paras[i].size = (double) width;
- if (fsize > lsize)
- lsize = fsize;
+ lsize = MAX(fsize, lsize);
}
ftxt->paras[i].lfsize = lsize;
- if (width > xsize)
- xsize = width;
- ysize += lsize * LINESPACING;
+ xsize = MAX(width, xsize);
+ ysize += sz.y;
width = w = 0;
lsize = 0;
}
para->just = terminator;
size = textsize(g, para, lp->fontname, lp->fontsize);
lp->u.txt.nparas++;
- /* total width = max line width */
- if (lp->dimen.x < size.x)
- lp->dimen.x = size.x;
- /* recalculate total height */
- lp->dimen.y = lp->u.txt.nparas * (int) (lp->fontsize * LINESPACING);
+ /* width = max line width */
+ lp->dimen.x = MAX(lp->dimen.x, size.x);
+ /* accumulate height */
+ lp->dimen.y += size.y;
}
/* compiles <str> into a label <lp> and returns its bounding box size. */
unsigned char byte = 0x00;
int charset = GD_charset(g);
+ lp->dimen.x = lp->dimen.y = 0.0;
if (*str == '\0')
return lp->dimen;
}
}
-void
-emit_textparas(GVJ_t* job, int nparas, textpara_t paras[], pointf p,
- double halfwidth_x, char* fname, double fsize, char* fcolor)
+void emit_label(GVJ_t * job, emit_state_t emit_state, textlabel_t * lp)
{
- int i, paraspacing, tmp;
- double center_x, left_x, right_x;
+ obj_state_t *obj = job->obj;
+ double halfwidth_x, center_x, left_x, right_x;
+ int i, tmp;
+ pointf p;
+ emit_state_t old_emit_state;
+
+ old_emit_state = obj->emit_state;
+ obj->emit_state = emit_state;
+
+ if (lp->html) {
+ emit_html_label(job, lp->u.html, lp);
+ return;
+ }
+
+ /* make sure that there is something to do */
+ if (lp->u.txt.nparas < 1)
+ return;
+
+ p.x = lp->p.x;
+ p.y = lp->p.y;
+
+ /* dimensions of box for label, no padding, adjusted for resizing */
+ halfwidth_x = (lp->dimen.x + lp->d.x) / 2.0;
center_x = p.x;
left_x = center_x - halfwidth_x;
right_x = center_x + halfwidth_x;
- /* set paraspacing to an exact no. of pixelrows */
- paraspacing = (int) (fsize * LINESPACING);
-
/* position for first para */
- p.y += paraspacing * (nparas - 1) / 2 /* cl of top para */
- - fsize * 0.30; /* Empirically determined fudge factor */
+ p.y += lp->dimen.y / 2. - lp->fontsize;
gvrender_begin_context(job);
- gvrender_set_pencolor(job, fcolor);
- gvrender_set_font(job, fname, fsize);
+ gvrender_set_pencolor(job, lp->fontcolor);
+ gvrender_set_font(job, lp->fontname, lp->fontsize);
- for (i = 0; i < nparas; i++) {
- switch (paras[i].just) {
+ for (i = 0; i < lp->u.txt.nparas; i++) {
+ switch (lp->u.txt.para[i].just) {
case 'l':
p.x = left_x;
break;
p.x = center_x;
break;
}
-
tmp = ROUND(p.x); /* align with integer points */
p.x = (double)tmp;
tmp = ROUND(p.y); /* align with integer points */
p.y = (double)tmp;
- gvrender_textpara(job, p, &(paras[i]));
+ gvrender_textpara(job, p, &(lp->u.txt.para[i]));
- /* position for next para */
- p.y -= paraspacing;
+ /* UL position for next para */
+ p.y -= lp->u.txt.para[i].height;
}
gvrender_end_context(job);
-}
-
-void emit_label(GVJ_t * job, emit_state_t emit_state, textlabel_t * lp)
-{
- obj_state_t *obj = job->obj;
- double halfwidth_x;
- pointf p;
- emit_state_t old_emit_state;
-
- old_emit_state = obj->emit_state;
- obj->emit_state = emit_state;
-
- if (lp->html) {
- emit_html_label(job, lp->u.html, lp);
- return;
- }
-
- /* make sure that there is something to do */
- if (lp->u.txt.nparas < 1)
- return;
-
- p.x = lp->p.x;
- p.y = lp->p.y;
-
- /* dimensions of box for label, no padding, adjusted for resizing */
- halfwidth_x = (lp->dimen.x + lp->d.x) / 2.0;
-
- emit_textparas(job, lp->u.txt.nparas, lp->u.txt.para, p,
- halfwidth_x, lp->fontname, lp->fontsize, lp->fontcolor);
-
obj->emit_state = old_emit_state;
}