* Contributors: See CVS logs. Details at http://www.graphviz.org/
*************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cdt.h"
#include "render.h"
static double timesFontWidth[] = {
free(tf);
}
}
+
+#if 0
+typedef struct {
+ /* key */
+ char *name;
+ char *color;
+ unsigned int flags;
+ /* non key */
+ char *postscript_alias;
+} font_t;
+
+Void_t* font_makef(Dt_t* dt, Void_t* obj, Dtdisc_t* disc)
+{
+ font_t *f1 = (font_t*)obj;
+ font_t *f2 = calloc(1,sizeof(font_t));
+
+ /* key */
+ if (f1->name) f2->name = strdup(f1->name);
+ if (f1->color) f2->color = strdup(f1->color);
+ f2->flags = f1->flags;
+
+ /* non key */
+ f2->postscript_alias = f1->postscript_alias;
+
+ return f2;
+}
+
+void font_freef(Dt_t* dt, Void_t* obj, Dtdisc_t* disc)
+{
+ font_t *f = (font_t*)obj;
+
+ if (f->name) free(f->name);
+ if (f->color) free(f->color);
+ free(f);
+}
+
+int font_comparf (Dt_t* dt, Void_t* key1, Void_t* key2, Dtdisc_t* disc)
+{
+ int rc;
+ font_t *f1 = (font_t*)key1, *f2 = (font_t*)key2;
+
+ rc = strcmp(f1->name, f2->name);
+ if (rc) return rc;
+ rc = strcmp(f1->color, f2->color);
+ if (rc) return rc;
+ return (f1->flags - f2->flags);
+}
+
+Dtdisc_t fontdisc = {
+ 0,sizeof(font_t),-1,font_makef,font_freef,font_comparf,NULL,NULL,NULL
+};
+
+#define TEST 1
+#ifdef TEST
+
+font_t font1 = { "Times", "black", 0 };
+font_t font2 = { "Arial", "black", 0 };
+font_t font3 = { "Arial", "black", 4 };
+font_t font4 = { "Arial", "black", 0 }; /* dup of 2 */
+font_t font5 = { "Arial", "red", 0 };
+font_t font6 = { "Times", "black", 0 }; /* dup of 1 */
+
+int main (void)
+{
+ Dt_t *fontname_dt;
+ font_t *f1 = &font1, *f2 = &font2, *f3 = &font3, *f4 = &font4, *f5 = &font5, *f6 = &font6;
+
+ fprintf(stderr,"%p %p %p %p %p %p\n", f1, f2, f3, f4, f5, f6);
+ fprintf(stderr,"%s %s %s %s %s %s\n", f1->name, f2->name, f3->name, f4->name, f5->name, f6->name);
+
+ fontname_dt = dtopen( &fontdisc, Dtoset);
+
+ f1 = dtinsert(fontname_dt, f1);
+ f2 = dtinsert(fontname_dt, f2);
+ f3 = dtinsert(fontname_dt, f3);
+ f4 = dtinsert(fontname_dt, f4);
+ f5 = dtinsert(fontname_dt, f5);
+ f6 = dtinsert(fontname_dt, f6);
+
+ fprintf(stderr,"%p %p %p %p %p %p\n", f1, f2, f3, f4, f5, f6);
+ fprintf(stderr,"%s %s %s %s %s %s\n", f1->name, f2->name, f3->name, f4->name, f5->name, f6->name);
+
+ dtclose(fontname_dt);
+
+ return 0;
+}
+
+#endif
+#endif
return img;
}
-static textfont_t *mkFont(char **atts, int flags, int ul)
+static textfont_t *mkFont(GVC_t *gvc, char **atts, int flags, int ul)
{
textfont_t *font = new_textfont();
static void startElement(void *user, const char *name, char **atts)
{
+ GVC_t *gvc = (GVC_t*)user;
+
if (strcasecmp(name, "TABLE") == 0) {
htmllval.tbl = mkTbl(atts);
state.inCell = 0;
htmllval.cell = mkCell(atts);
state.tok = T_cell;
} else if (strcasecmp(name, "FONT") == 0) {
- htmllval.font = mkFont(atts, 0, 0);
+ htmllval.font = mkFont(gvc, atts, 0, 0);
state.tok = T_font;
} else if (strcasecmp(name, "B") == 0) {
- htmllval.font = mkFont(0, HTML_BF, 0);
+ htmllval.font = mkFont(gvc, 0, HTML_BF, 0);
state.tok = T_bold;
} else if (strcasecmp(name, "S") == 0) {
- htmllval.font = mkFont(0, HTML_S, 0);
+ htmllval.font = mkFont(gvc, 0, HTML_S, 0);
state.tok = T_s;
} else if (strcasecmp(name, "U") == 0) {
- htmllval.font = mkFont(0, HTML_UL, 1);
+ htmllval.font = mkFont(gvc, 0, HTML_UL, 1);
state.tok = T_underline;
} else if (strcasecmp(name, "I") == 0) {
- htmllval.font = mkFont(0, HTML_IF, 0);
+ htmllval.font = mkFont(gvc, 0, HTML_IF, 0);
state.tok = T_italic;
} else if (strcasecmp(name, "SUP") == 0) {
- htmllval.font = mkFont(0, HTML_SUP, 0);
+ htmllval.font = mkFont(gvc, 0, HTML_SUP, 0);
state.tok = T_sup;
} else if (strcasecmp(name, "SUB") == 0) {
- htmllval.font = mkFont(0, HTML_SUB, 0);
+ htmllval.font = mkFont(gvc, 0, HTML_SUB, 0);
state.tok = T_sub;
} else if (strcasecmp(name, "BR") == 0) {
mkBR(atts);
}
#endif
-int initHTMLlexer(char *src, agxbuf * xb, int charset)
+int initHTMLlexer(char *src, agxbuf * xb, htmlenv_t *env)
{
#ifdef HAVE_EXPAT
state.xb = xb;
state.currtoklen = 0;
state.prevtoklen = 0;
state.inCell = 1;
- state.parser = XML_ParserCreate(charsetToStr(charset));
+ state.parser = XML_ParserCreate(charsetToStr(GD_charset(env->g)));
+ XML_SetUserData(state.parser, GD_gvc(env->g));
XML_SetElementHandler(state.parser,
(XML_StartElementHandler) startElement,
endElement);
#include <agxbuf.h>
- extern int initHTMLlexer(char *, agxbuf *, int);
+ extern int initHTMLlexer(char *, agxbuf *, htmlenv_t *);
extern int htmllex(void);
extern int htmllineno(void);
extern int clearHTMLlexer(void);
* Set warn to 0 on success; 1 for warning message; 2 if no expat.
*/
htmllabel_t*
-parseHTML (char* txt, int* warn, int charset)
+parseHTML (char* txt, int* warn, htmlenv_t *env)
{
unsigned char buf[SMALLBUF];
agxbuf str;
agxbinit (&str, SMALLBUF, buf);
HTMLstate.str = &str;
- if (initHTMLlexer (txt, &str, charset)) {/* failed: no libexpat - give up */
+ if (initHTMLlexer (txt, &str, env)) {/* failed: no libexpat - give up */
*warn = 2;
l = NULL;
}
#define DEFAULT_CELLPADDING 2
#define DEFAULT_CELLSPACING 2
-typedef struct {
- pointf pos;
- textfont_t finfo;
- void *obj;
- graph_t *g;
- char *imgscale;
- char *objid;
- boolean objid_set;
-} htmlenv_t;
-
typedef struct {
char *url;
char *tooltip;
return 0;
}
-static int size_html_txt(graph_t * g, htmltxt_t * ftxt, htmlenv_t * env)
+static int size_html_txt(GVC_t *gvc, htmltxt_t * ftxt, htmlenv_t * env)
{
double xsize = 0.0; /* width of text block */
double ysize = 0.0; /* height of text block */
}
lp.font->name = fname;
lp.font->size = fsize;
- sz = textspan_size(GD_gvc(g), &lp);
+ sz = textspan_size(gvc, &lp);
free(ftxt->spans[i].items[j].str);
ftxt->spans[i].items[j].str = lp.str;
ftxt->spans[i].items[j].size.x = sz.x;
rv = size_html_img(cp->child.u.img, env);
child_sz = cp->child.u.img->box.UR;
} else {
- rv = size_html_txt(g, cp->child.u.txt, env);
+ rv = size_html_txt(GD_gvc(g), cp->child.u.txt, env);
child_sz = cp->child.u.txt->box.UR;
}
env.finfo.name = lp->fontname;
env.finfo.color = lp->fontcolor;
env.finfo.flags = 0;
- lbl = parseHTML(lp->text, &rv, GD_charset(env.g));
+ lbl = parseHTML(lp->text, &rv, &env);
if (!lbl) {
/* Parse of label failed; revert to simple text label */
agxbuf xb;
lp->dimen.x = box.UR.x - box.LL.x;
lp->dimen.y = box.UR.y - box.LL.y;
} else {
- rv |= size_html_txt(g, lbl->u.txt, &env);
+ rv |= size_html_txt(GD_gvc(g), lbl->u.txt, &env);
wd2 = lbl->u.txt->box.UR.x / 2;
ht2 = lbl->u.txt->box.UR.y / 2;
box = boxfof(-wd2, -ht2, wd2, ht2);
unsigned char ruled;
} pitem;
- extern htmllabel_t *parseHTML(char *, int *, int);
+ typedef struct {
+ pointf pos;
+ textfont_t finfo;
+ void *obj;
+ graph_t *g;
+ char *imgscale;
+ char *objid;
+ boolean objid_set;
+ } htmlenv_t;
+
+ extern htmllabel_t *parseHTML(char *, int *, htmlenv_t *);
extern int make_html_label(void *obj, textlabel_t * lp);
extern void emit_html_label(GVJ_t * job, htmllabel_t * lp, textlabel_t *);
-mkdir -p $(DESTDIR)@LUA_INSTALL_DIR@;
if test -w $(DESTDIR)@LUA_INSTALL_DIR@; then \
(cd $(DESTDIR)@LUA_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgluadir)/gv.so; \
mv -f $(DESTDIR)$(pkgluadir)/libgv_lua.so gv.so;) \
else \
echo "Warning: @LUA_INSTALL_DIR@ is not writable."; \
-mkdir -p $(DESTDIR)@PERL_INSTALL_DIR@;
if test -w $(DESTDIR)@PERL_INSTALL_DIR@; then \
(cd $(DESTDIR)@PERL_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgperldir)/gv.so; \
mv -f $(DESTDIR)$(pkgperldir)/libgv_perl.so gv.so; \
mv -f $(DESTDIR)$(pkgperldir)/gv.pm gv.pm;) \
else \
-mkdir -p $(DESTDIR)@PHP_INSTALL_DIR@;
if test -w $(DESTDIR)@PHP_INSTALL_DIR@; then \
(cd $(DESTDIR)@PHP_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgphpdir)/gv.so; \
mv -f $(DESTDIR)$(pkgphpdir)/libgv_php.so gv.so;) \
else \
echo "Warning: @PHP_INSTALL_DIR@ is not writable."; \
-mkdir -p $(DESTDIR)@PYTHON_INSTALL_DIR@;
if test -w $(DESTDIR)@PYTHON_INSTALL_DIR@; then \
(cd $(DESTDIR)@PYTHON_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgpythondir)/_gv.so; \
mv -f $(DESTDIR)$(pkgpythondir)/libgv_python.so _gv.so; \
mv -f $(DESTDIR)$(pkgpythondir)/gv.py gv.py;) \
else \
-mkdir -p $(DESTDIR)@PYTHON23_INSTALL_DIR@;
if test -w $(DESTDIR)@PYTHON23_INSTALL_DIR@; then \
(cd $(DESTDIR)@PYTHON23_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgpython23dir)/_gv.so; \
mv -f $(DESTDIR)$(pkgpython23dir)/libgv_python23.so _gv.so; \
mv -f $(DESTDIR)$(pkgpython23dir)/gv.py gv.py;) \
else \
-mkdir -p $(DESTDIR)@PYTHON24_INSTALL_DIR@;
if test -w $(DESTDIR)@PYTHON24_INSTALL_DIR@; then \
(cd $(DESTDIR)@PYTHON24_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgpython24dir)/_gv.so; \
mv -f $(DESTDIR)$(pkgpython24dir)/libgv_python24.so _gv.so; \
mv -f $(DESTDIR)$(pkgpython24dir)/gv.py gv.py;) \
else \
-mkdir -p $(DESTDIR)@PYTHON25_INSTALL_DIR@;
if test -w $(DESTDIR)@PYTHON25_INSTALL_DIR@; then \
(cd $(DESTDIR)@PYTHON25_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgpython25dir)/_gv.so; \
mv -f $(DESTDIR)$(pkgpython25dir)/libgv_python25.so _gv.so; \
mv -f $(DESTDIR)$(pkgpython25dir)/gv.py gv.py;) \
else \
-mkdir -p $(DESTDIR)@PYTHON26_INSTALL_DIR@;
if test -w $(DESTDIR)@PYTHON26_INSTALL_DIR@; then \
(cd $(DESTDIR)@PYTHON26_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgpython26dir)/_gv.so; \
mv -f $(DESTDIR)$(pkgpython26dir)/libgv_python26.so _gv.so; \
mv -f $(DESTDIR)$(pkgpython26dir)/gv.py gv.py;) \
else \
-mkdir -p $(DESTDIR)@PYTHON27_INSTALL_DIR@;
if test -w $(DESTDIR)@PYTHON27_INSTALL_DIR@; then \
(cd $(DESTDIR)@PYTHON27_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgpython27dir)/_gv.so; \
mv -f $(DESTDIR)$(pkgpython27dir)/libgv_python27.so _gv.so; \
mv -f $(DESTDIR)$(pkgpython27dir)/gv.py gv.py;) \
else \
-mkdir -p $(DESTDIR)@RUBY_INSTALL_DIR@;
if test -w $(DESTDIR)@RUBY_INSTALL_DIR@; then \
(cd $(DESTDIR)@RUBY_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgrubydir)/gv.so; \
mv -f $(DESTDIR)$(pkgrubydir)/libgv_ruby.so gv.so;) \
else \
echo "Warning: @RUBY_INSTALL_DIR@ is not writable."; \
-mkdir -p $(DESTDIR)@TCL_INSTALL_DIR@;
if test -w $(DESTDIR)@TCL_INSTALL_DIR@/; then \
(cd $(DESTDIR)@TCL_INSTALL_DIR@; \
- rm -f $(DESTDIR)$(pkgtcldir)/*.so; \
mv -f $(DESTDIR)$(pkgtcldir) @PACKAGE_NAME@;) \
else \
echo "Warning: @TCL_INSTALL_DIR@ is not writable."; \