para->width = 0.0;
para->height = para->fontsize * LINESPACING;
- para->yoffset = 0.0;
+ para->yoffset_layout = 0.0;
+ para->yoffset_centerline = 0.1 * para->fontsize;
para->xshow = NULL;
para->layout = para->fontname;
para->free_layout = NULL;
tl.fontname = fname_;
tl.fontsize = fsize_;
tl.xshow = ti->xshow;
- tl.yoffset = ti->yoffset;
+ tl.yoffset_layout = ti->yoffset_layout;
+ tl.yoffset_centerline = ti->yoffset_centerline;
tl.postscript_alias = ti->postscript_alias;
tl.layout = ti->layout;
tl.width = paras[i].size;
ftxt->paras[i].items[j].str = lp.str;
ftxt->paras[i].items[j].size = sz.x;
ftxt->paras[i].items[j].xshow = lp.xshow;
- ftxt->paras[i].items[j].yoffset = lp.yoffset;
+ ftxt->paras[i].items[j].yoffset_layout = lp.yoffset_layout;
+ ftxt->paras[i].items[j].yoffset_centerline = lp.yoffset_centerline;
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;
void *layout;
void (*free_layout) (void *layout);
htmlfont_t *font;
- double size, dpi, yoffset; /* size of text item according to font */
+ double size, yoffset_layout, yoffset_centerline;
} textitem_t;
typedef struct {
char *xshow;
void *layout;
void (*free_layout) (void *layout); /* FIXME - this is ugly */
- double fontsize, width, height, yoffset;
+ double fontsize, width, height, yoffset_layout, yoffset_centerline;
char just;
} textpara_t;
ps_set_color(job, &(job->obj->pencolor));
gvdevice_printf(job, "%.2f /%s set_font\n", para->fontsize, para->fontname);
str = ps_string(para->str,isLatin1);
- /* don't use para->yoffset because we don't need the baseline offset */
- p.y += .1 * para->fontsize;
+ p.y += para->yoffset_centerline;
if (para->xshow) {
switch (para->just) {
case 'l':
gvdevice_fputs(job, " text-anchor=\"middle\"");
break;
}
- /* don't use para->yoffset because we don't need the baseline offset */
- p.y += .1 * para->fontsize;
+ p.y += para->yoffset_centerline;
gvdevice_printf(job, " x=\"%g\" y=\"%g\"", p.x, -p.y);
gvdevice_fputs(job, " style=\"");
pA = para->postscript_alias;
else {
spf.x += p.x;
epf.x += p.x;
- epf.y = spf.y = p.y;
+ epf.y = spf.y = p.y - para->yoffset_centerline * job->scale.y;
}
gdgen_text(im, spf, epf,
para->width = 0.0;
para->height = 0.0;
- para->yoffset = 0.0;
+ para->yoffset_layout = 0.0;
para->xshow = NULL;
para->layout = NULL;
para->free_layout = NULL;
fontsize = para->fontsize;
+ para->yoffset_centerline = 0.1 * fontsize;
if (para->fontname) {
if (fontsize <= FONTSIZE_MUCH_TOO_SMALL) {
* see LINESPACING in const.h.
*/
para->height = (int)(para->fontsize * 1.2);
- para->yoffset = 0.0;
}
}
return TRUE;
{
obj_state_t *obj = job->obj;
cairo_t *cr = (cairo_t *) job->context;
- pointf offset;
cairo_set_dash (cr, dashed, 0, 0.0); /* clear any dashing */
cairogen_set_color(cr, &(obj->pencolor));
switch (para->just) {
case 'r':
- offset.x = para->width;
+ p.x -= para->width;
break;
case 'l':
- offset.x = 0.0;
+ p.x -= 0.0;
break;
case 'n':
default:
- offset.x = para->width / 2.0;
+ p.x -= para->width / 2.0;
break;
}
- offset.y = para->yoffset;
+ p.y += para->yoffset_centerline + para->yoffset_layout;
- cairo_move_to (cr, p.x-offset.x, -p.y-offset.y);
+ cairo_move_to (cr, p.x, -p.y);
cairo_save(cr);
cairo_scale(cr, POINTS_PER_INCH / FONT_DPI, POINTS_PER_INCH / FONT_DPI);
pango_cairo_show_layout(cr, (PangoLayout*)(para->layout));
para->width = logical_rect.width * textlayout_scale;
para->height = logical_rect.height * textlayout_scale;
+ /* The y offset from baseline to 0,0 of the bitmap representation */
iter = pango_layout_get_iter (layout);
- para->yoffset = pango_layout_iter_get_baseline (iter) * textlayout_scale
- +.1 * para->fontsize; /* In labels.c y is already midline
- * 0.1 is the distance below midline for y centering */
+ para->yoffset_layout = pango_layout_iter_get_baseline (iter) * textlayout_scale;
+
+ /* The distance below midline for y centering of text strings */
+ para->yoffset_centerline = 0.1 * para->fontsize;
/* determine position of each character in the layout */
para->xshow = NULL;