From: erg Date: Thu, 14 Oct 2010 16:03:08 +0000 (+0000) Subject: Redo textpara_t to use a separate font object allowing flags for X-Git-Tag: LAST_LIBGRAPH~32^2~1169 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=211bd75586e035586df7516a8b906eb1d9a84448;p=graphviz Redo textpara_t to use a separate font object allowing flags for underline, italics, etc.; hook-in font flags from HTML text to the attributes go to the renderer --- diff --git a/lib/common/htmlparse.y b/lib/common/htmlparse.y index 3d0fb79d0..00a102a24 100644 --- a/lib/common/htmlparse.y +++ b/lib/common/htmlparse.y @@ -115,7 +115,7 @@ static Dtdisc_t cellDisc = { typedef struct { Dtlink_t link; - textitem_t ti; + textpara_t ti; } fitem; typedef struct { @@ -136,7 +136,7 @@ free_fitem(Dt_t* d, fitem* p, Dtdisc_t* ds) static void free_fpara(Dt_t* d, fpara* p, Dtdisc_t* ds) { - textitem_t* ti; + textpara_t* ti; if (p->lp.nitems) { int i; @@ -213,7 +213,7 @@ appendFLineList (int v) ln->lp.just = v; if (cnt) { int i = 0; - ln->lp.items = N_NEW(cnt, textitem_t); + ln->lp.items = N_NEW(cnt, textpara_t); fi = (fitem*)dtflatten(ilist); for (; fi; fi = (fitem*)dtlink(fitemList,(Dtlink_t*)fi)) { diff --git a/lib/common/htmltable.c b/lib/common/htmltable.c index 73e52e063..f7ae240cf 100644 --- a/lib/common/htmltable.c +++ b/lib/common/htmltable.c @@ -119,7 +119,7 @@ emit_htextparas(GVJ_t* job, int nparas, htextpara_t* paras, pointf p, char *fname_ , *fcolor_; textpara_t tl; pointf p_ = {0.0, 0.0}; - textitem_t* ti; + textpara_t* ti; center_x = p.x; left_x = center_x - halfwidth_x; @@ -549,7 +549,7 @@ void free_html_data(htmldata_t * dp) void free_html_text(htmltxt_t* t) { htextpara_t *tl; - textitem_t *ti; + textpara_t *ti; int i, j; if (!t) return; @@ -762,13 +762,21 @@ size_html_txt(graph_t *g, htmltxt_t* ftxt, htmlenv_t* env) int i, j, w, width; char *fname; textpara_t lp; + htmlfont_t lhf; + lp.font = &lhf; for (i = 0; i < ftxt->nparas; i++) { width = w = 0; mxfsize = 0; for (j = 0; j < ftxt->paras[i].nitems; j++) { lp.str = strdup_and_subst_obj (ftxt->paras[i].items[j].str, env->obj); if (ftxt->paras[i].items[j].font) { + if(ftxt->paras[i].items[j].font->flags) + lp.font->flags = ftxt->paras[i].items[j].font->flags; + else if(env->finfo.flags > 0) + lp.font->flags = env->finfo.flags; + else + lp.font->flags = 0; if (ftxt->paras[i].items[j].font->size > 0) fsize = ftxt->paras[i].items[j].font->size; else diff --git a/lib/common/htmltable.h b/lib/common/htmltable.h index b62eee0df..f88419fc2 100644 --- a/lib/common/htmltable.h +++ b/lib/common/htmltable.h @@ -38,41 +38,14 @@ extern "C" { #define UNSET_ALIGN 0 -/* Bold, Italic, Underline */ -#define HTML_BF 1 -#define HTML_IF 2 -#define HTML_UL 4 - - /* font information - * If name or color is NULL, or size < 0, that attribute - * is unspecified. - */ - typedef struct { - char* name; - char* color; - int flags:7; /* HTML_UL, HTML_IF, HTML_BF */ - int cnt; /* reference count */ - double size; - } htmlfont_t; - /* paras of text within a cell * NOTE: As required, the str field in para is utf-8. * This translation is done when libexpat scans the input. */ - /* atomic unit of text emitted using a single htmlfont_t */ - typedef struct { - char *str; - PostscriptAlias *postscript_alias; - void *layout; - void (*free_layout) (void *layout); - htmlfont_t *font; - double size, yoffset_layout, yoffset_centerline; - } textitem_t; - - /* line of textitems_t */ + /* line of textpara_t's */ typedef struct { - textitem_t *items; + textpara_t *items; short nitems; char just; double size; /* width of para */ diff --git a/lib/common/textpara.h b/lib/common/textpara.h index cb194d8dc..4f54cf144 100644 --- a/lib/common/textpara.h +++ b/lib/common/textpara.h @@ -21,6 +21,23 @@ extern "C" { #endif +/* Bold, Italic, Underline */ +#define HTML_BF 1 +#define HTML_IF 2 +#define HTML_UL 4 + + /* font information + * If name or color is NULL, or size < 0, that attribute + * is unspecified. + */ + typedef struct { + char* name; + char* color; + int flags:7; /* HTML_UL, HTML_IF, HTML_BF */ + int cnt; /* reference count */ + double size; + } htmlfont_t; + typedef struct _PostscriptAlias { char* name; char* family; @@ -33,14 +50,18 @@ extern "C" { char* svg_font_style; } PostscriptAlias; - typedef struct textpara_t { + /* atomic unit of text emitted using a single htmlfont_t */ + typedef struct { char *str; /* stored in utf-8 */ - char *fontname; - PostscriptAlias *postscript_alias; + PostscriptAlias *postscript_alias; void *layout; void (*free_layout) (void *layout); /* FIXME - this is ugly */ - double fontsize, width, height, yoffset_layout, yoffset_centerline; - char just; /* 'l' 'n' 'r' */ + htmlfont_t *font; + char *fontname; /* FIXME - use htmlfont_t */ + double fontsize; /* FIXME - use htmlfont_t */ + double size, yoffset_layout, yoffset_centerline; + double width, height; /* FIXME */ + char just; /* 'l' 'n' 'r' */ /* FIXME */ } textpara_t; #ifdef __cplusplus