Exemplo n.º 1
0
/* emit_html_label:
 */
void
emit_html_label(GVJ_t * job, htmllabel_t * lp, textlabel_t * tp)
{
    htmlenv_t env;

    env.p = tp->p;
    env.finfo.color = tp->fontcolor;
    env.finfo.name = tp->fontname;
    env.finfo.size = tp->fontsize;
    if (lp->kind == HTML_TBL) {
	htmltbl_t *tbl = lp->u.tbl;

	/* set basic graphics context */
	gvrender_begin_context(job);
	/* Need to override line style set by node. */
	gvrender_set_style(job, job->gvc->defaultlinestyle);
	if (tbl->data.pencolor)
	    gvrender_set_pencolor(job, tbl->data.pencolor);
	else
	    gvrender_set_pencolor(job, DEFAULT_COLOR);
	emit_html_tbl(job, tbl, &env);
	gvrender_end_context(job);
    } else {
	emit_html_txt(job, lp->u.txt, &env);
    }
}
Exemplo n.º 2
0
/* doBorder:
 * Draw rectangle of width border inside rectangle given
 * by box. If border is 1, we call use a single call to gvrender_polygon.
 * (We have set linewidth to 1 below.) Otherwise, we use four separate
 * filled rectangles. We could use a richer graphics model, as things
 * can go wrong when cell spacing and borders are small.
 * We decrement the border value by 1, as typically a filled rectangle
 * from x to x+border will all pixels from x to x+border, and thus have
 * width border+1.
 */
static void doBorder(GVJ_t * job, char *color, int border, box B)
{
    pointf pt;
    boxf BF;
    double wd, ht;

    gvrender_begin_context(job);

    if (!color)
	color = "black";
    gvrender_set_fillcolor(job, color);
    gvrender_set_pencolor(job, color);

    B2BF(B, BF);
    if (border == 1) {
	gvrender_box(job, BF, 0);
    } else {
	border--;
	ht = BF.UR.y - BF.LL.y;
	wd = BF.UR.x - BF.LL.x;
	doSide(job, BF.LL, border, ht);
	pt.x = BF.LL.x;
	pt.y = BF.UR.y;
	doSide(job, pt, wd, -border);
	doSide(job, BF.UR, -border, -ht);
	pt.x = BF.UR.x;
	pt.y = BF.LL.y;
	doSide(job, pt, -wd, border);
    }

    gvrender_end_context(job);
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
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);
}