Exemple #1
0
void 
emit_textlines(GVJ_t* job, int nlines, textline_t lines[], pointf p,
              double halfwidth_x, char* fname, double fsize, char* fcolor)
{
    int i, linespacing;
    double tmp, center_x, left_x, right_x;

    center_x = p.x;
    left_x = center_x - halfwidth_x;
    right_x = center_x + halfwidth_x;

    /* set linespacing to an exact no. of pixelrows */
    linespacing = (int) (fsize * LINESPACING);

    /* position for first line */
    p.y += (linespacing * (nlines - 1) / 2)	/* cl of topline */
	-fsize / 3.0;	/* cl to baseline */

    tmp = ROUND(p.y);  /* align with interger points */
    p.y = (double)tmp;

    gvrender_begin_context(job);
    gvrender_set_pencolor(job, fcolor);
    gvrender_set_font(job, fname, fsize);

    for (i = 0; i < nlines; i++) {
	switch (lines[i].just) {
	case 'l':
	    p.x = left_x;
	    break;
	case 'r':
	    p.x = right_x;
	    break;
	default:
	case 'n':
	    p.x = center_x;
	    break;
	}
	gvrender_textline(job, p, &(lines[i]));

	/* position for next line */
	p.y -= linespacing;
    }

    gvrender_end_context(job);
}
Exemple #2
0
static void 
emit_htextparas(GVJ_t* job, int nparas, htextpara_t* paras, pointf p,
         double halfwidth_x, char* fname, double fsize, char* fcolor, box b)
{
    int i,j;
    double tmp, center_x, left_x, right_x, fsize_;
    double offset;
    char *fname_ , *fcolor_;
    textpara_t tl;
    pointf p_ = {0.0, 0.0};
    textitem_t* ti;
	
    center_x = p.x;
    left_x = center_x - halfwidth_x;
    right_x = center_x + halfwidth_x;

	/* Initial p is in center of text block; set initial baseline
 	 * to top of text block.
	 */
    p_.y = p.y + (double)(b.UR.y-b.LL.y)/2.0;
    tmp = ROUND(p_.y);  /* align with integer points */
    p_.y = (double)tmp;

    gvrender_begin_context(job);
    for(i=0; i<nparas; i++) {
	switch (paras[i].just) {
	case 'l':
	    p_.x = left_x;
	    p.x = left_x;
	    break;
	case 'r':
	    p_.x = right_x;
	    p.x = right_x;		
	    break;
	default:
	case 'n':
	    p_.x = center_x;
	    p.x = center_x;
	    break;
	}
	p_.y -= paras[i].lfsize;  /* move to current base line */

	ti = paras[i].items;
	offset = 0.0;
	for(j=0; j<paras[i].nitems; j++) {
	    if (ti->font && (ti->font->size > 0))
		fsize_ = ti->font->size;
	    else
	        fsize_ = fsize;
	    if (ti->font && ti->font->name)
		fname_ = ti->font->name;
	    else
	        fname_ = fname;
	    if (ti->font && ti->font->color)
		fcolor_ = ti->font->color;
	    else
	        fcolor_ = fcolor;

    	    gvrender_set_pencolor(job, fcolor_);
   	    gvrender_set_font(job, fname_, fsize_);

	    tl.str = ti->str;
	    tl.fontname = fname_;
	    tl.fontsize = fsize_;
	    tl.xshow = ti->xshow;
	    tl.postscript_alias = ti->postscript_alias;
	    tl.layout = ti->layout;
	    tl.width = paras[i].size;
	    tl.height = paras[i].lfsize;
	    tl.just = paras[i].just;

	    gvrender_textpara(job, p_, &tl);
	    offset += ti->size;
	    p_.x = p.x + offset;
            ti++;
	}
    }

    gvrender_end_context(job);
}