Пример #1
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);
}
Пример #2
0
static void 
emit_htextparas(GVJ_t* job, int nparas, htextpara_t* paras, pointf p,
         double halfwidth_x, htmlfont_t finfo, boxf b)
{
    int i,j;
    double center_x, left_x, right_x, fsize_;
    char *fname_ , *fcolor_;
    textpara_t tl;
    pointf p_ = {0.0, 0.0};
    textpara_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 + (b.UR.y-b.LL.y)/2.0;

    gvrender_begin_label(job, LABEL_HTML);
    for(i=0; i<nparas; i++) {
	/* set p.x to leftmost point where the line of text begins */
	switch (paras[i].just) {
	case 'l':
	    p.x = left_x;
	    break;
	case 'r':
	    p.x = right_x - paras[i].size;
	    break;
	default:
	case 'n':
	    p.x = center_x - paras[i].size/2.0;
	    break;
	}
	p_.y -= paras[i].lfsize;  /* move to current base line */

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

    	    gvrender_set_pencolor(job, fcolor_);

	    tl.str = ti->str;
	    tl.fontname = fname_;
	    tl.fontsize = fsize_;
	    tl.font = ti->font;
	    tl.yoffset_layout = ti->yoffset_layout;
	    /* tl.yoffset_centerline = ti->yoffset_centerline; */
	    tl.yoffset_centerline = 1;
	    tl.postscript_alias = ti->postscript_alias;
	    tl.layout = ti->layout;
	    tl.width = ti->size;
	    tl.height = paras[i].lfsize;
	    tl.just = 'l';

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

    gvrender_end_label(job);
}