1 /****************************************************************************
2 * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2002
3 ****************************************************************************
4 * rrd_gfx.c graphics wrapper for rrdtool
5 **************************************************************************/
10 # define DPRINT(x) (void)(printf x, printf("\n"))
17 #include FT_FREETYPE_H
21 /* lines are better drawn on the pixle than between pixles */
22 #define LINEOFFSET 0.5
25 gfx_node_t *gfx_new_node( gfx_canvas_t *canvas,enum gfx_en type){
26 gfx_node_t *node = art_new(gfx_node_t,1);
27 if (node == NULL) return NULL;
29 node->color = 0x0; /* color of element 0xRRGGBBAA alpha 0xff is solid*/
30 node->size =0.0; /* font size, line width */
31 node->path = NULL; /* path */
34 node->closed_path = 0;
35 node->svp = NULL; /* svp */
36 node->filename = NULL; /* font or image filename */
39 node->y = 0.0; /* position */
41 node->halign = GFX_H_NULL; /* text alignement */
42 node->valign = GFX_V_NULL; /* text alignement */
45 if (canvas->lastnode != NULL){
46 canvas->lastnode->next = node;
48 if (canvas->firstnode == NULL){
49 canvas->firstnode = node;
51 canvas->lastnode = node;
55 gfx_canvas_t *gfx_new_canvas (void) {
56 gfx_canvas_t *canvas = art_new(gfx_canvas_t,1);
57 canvas->firstnode = NULL;
58 canvas->lastnode = NULL;
59 canvas->imgformat = IF_PNG; /* we default to PNG output */
60 canvas->interlaced = 0;
65 /* create a new line */
66 gfx_node_t *gfx_new_line(gfx_canvas_t *canvas,
69 double width, gfx_color_t color){
70 return gfx_new_dashed_line(canvas, X0, Y0, X1, Y1, width, color, 0, 0);
73 gfx_node_t *gfx_new_dashed_line(gfx_canvas_t *canvas,
76 double width, gfx_color_t color,
77 double dash_on, double dash_off){
81 node = gfx_new_node(canvas,GFX_LINE);
82 if (node == NULL) return NULL;
83 vec = art_new(ArtVpath, 3);
84 if (vec == NULL) return NULL;
85 vec[0].code = ART_MOVETO_OPEN; vec[0].x=X0+LINEOFFSET; vec[0].y=Y0+LINEOFFSET;
86 vec[1].code = ART_LINETO; vec[1].x=X1+LINEOFFSET; vec[1].y=Y1+LINEOFFSET;
87 vec[2].code = ART_END;
93 node->dash_on = dash_on;
94 node->dash_off = dash_off;
99 /* create a new area */
100 gfx_node_t *gfx_new_area (gfx_canvas_t *canvas,
101 double X0, double Y0,
102 double X1, double Y1,
103 double X2, double Y2,
108 node = gfx_new_node(canvas,GFX_AREA);
109 if (node == NULL) return NULL;
110 vec = art_new(ArtVpath, 5);
111 if (vec == NULL) return NULL;
112 vec[0].code = ART_MOVETO; vec[0].x=X0; vec[0].y=Y0;
113 vec[1].code = ART_LINETO; vec[1].x=X1; vec[1].y=Y1;
114 vec[2].code = ART_LINETO; vec[2].x=X2; vec[2].y=Y2;
115 vec[3].code = ART_LINETO; vec[3].x=X0; vec[3].y=Y0;
116 vec[4].code = ART_END;
119 node->points_max = 5;
126 /* add a point to a line or to an area */
127 int gfx_add_point (gfx_node_t *node,
129 if (node == NULL) return 1;
130 if (node->type == GFX_AREA) {
131 double X0 = node->path[0].x;
132 double Y0 = node->path[0].y;
134 art_vpath_add_point (&(node->path),
139 art_vpath_add_point (&(node->path),
144 art_vpath_add_point (&(node->path),
149 } else if (node->type == GFX_LINE) {
151 art_vpath_add_point (&(node->path),
155 x+LINEOFFSET,y+LINEOFFSET);
156 art_vpath_add_point (&(node->path),
163 /* can only add point to areas and lines */
169 void gfx_close_path (gfx_node_t *node) {
170 node->closed_path = 1;
173 /* create a text node */
174 gfx_node_t *gfx_new_text (gfx_canvas_t *canvas,
175 double x, double y, gfx_color_t color,
176 char* font, double size,
177 double tabwidth, double angle,
178 enum gfx_h_align_en h_align,
179 enum gfx_v_align_en v_align,
181 gfx_node_t *node = gfx_new_node(canvas,GFX_TEXT);
183 /* currently we only support 0 and 270 */
187 node->text = strdup(text);
189 node->filename = strdup(font);
194 node->tabwidth = tabwidth;
195 node->halign = h_align;
196 node->valign = v_align;
200 int gfx_render(gfx_canvas_t *canvas,
201 art_u32 width, art_u32 height,
202 gfx_color_t background, FILE *fp){
203 switch (canvas->imgformat) {
205 return gfx_render_png (canvas, width, height, background, fp);
207 return gfx_render_svg (canvas, width, height, background, fp);
213 double gfx_get_text_width ( gfx_canvas_t *canvas,
214 double start, char* font, double size,
215 double tabwidth, char* text){
216 switch (canvas->imgformat) {
218 return gfx_get_text_width_libart (canvas, start, font, size, tabwidth, text);
220 return size * strlen(text);
224 double gfx_get_text_width_libart ( gfx_canvas_t *canvas,
225 double start, char* font, double size,
226 double tabwidth, char* text){
230 FT_UInt glyph_index=0;
234 FT_Library library=NULL;
236 FT_Init_FreeType( &library );
237 error = FT_New_Face( library, font, 0, &face );
238 if ( error ) return -1;
239 error = FT_Set_Char_Size(face, size*64,size*64, 100,100);
240 if ( error ) return -1;
242 use_kerning = FT_HAS_KERNING(face);
245 previous = glyph_index;
246 glyph_index = FT_Get_Char_Index( face, *text);
248 if (use_kerning && previous && glyph_index){
250 FT_Get_Kerning( face, previous, glyph_index,
252 text_width += (double)delta.x / 64.0;
255 error = FT_Load_Glyph( face, glyph_index, 0 );
257 FT_Done_FreeType(library);
261 text_width -= (double)slot->metrics.horiBearingX / 64.0; /* add just char width */
263 text_width += (double)slot->metrics.horiAdvance / 64.0;
265 text_width -= (double)slot->metrics.horiAdvance / 64.0; /* remove last step */
266 text_width += (double)slot->metrics.width / 64.0; /* add just char width */
267 text_width += (double)slot->metrics.horiBearingX / 64.0; /* add just char width */
268 FT_Done_FreeType(library);
275 static int gfx_save_png (art_u8 *buffer, FILE *fp,
276 long width, long height, long bytes_per_pixel);
277 /* render grafics into png image */
278 int gfx_render_png (gfx_canvas_t *canvas,
279 art_u32 width, art_u32 height,
280 gfx_color_t background, FILE *fp){
284 gfx_node_t *node = canvas->firstnode;
285 art_u8 red = background >> 24, green = (background >> 16) & 0xff;
286 art_u8 blue = (background >> 8) & 0xff, alpha = ( background & 0xff );
287 unsigned long pys_width = width * canvas->zoom;
288 unsigned long pys_height = height * canvas->zoom;
289 const int bytes_per_pixel = 3;
290 unsigned long rowstride = pys_width*bytes_per_pixel; /* bytes per pixel */
291 art_u8 *buffer = art_new (art_u8, rowstride*pys_height);
292 art_rgb_run_alpha (buffer, red, green, blue, alpha, pys_width*pys_height);
293 FT_Init_FreeType( &library );
295 switch (node->type) {
301 if (node->closed_path) {
302 /* libart uses end==start for closed as indicator of closed path */
303 gfx_add_point(node, node->path[0].x, node->path[0].y);
304 node->closed_path = 0;
306 art_affine_scale(dst,canvas->zoom,canvas->zoom);
307 vec = art_vpath_affine_transform(node->path,dst);
308 if(node->type == GFX_LINE){
309 svp = art_svp_vpath_stroke ( vec, ART_PATH_STROKE_JOIN_ROUND,
310 ART_PATH_STROKE_CAP_ROUND,
311 node->size*canvas->zoom,1,1);
313 svp = art_svp_from_vpath ( vec );
316 art_rgb_svp_alpha (svp ,0,0, pys_width, pys_height,
317 node->color, buffer, rowstride, NULL);
323 float text_width=0.0, text_height = 0.0;
325 art_u8 fcolor[3],falpha;
329 FT_UInt glyph_index=0;
332 float pen_x = 0.0 , pen_y = 0.0;
336 fcolor[0] = node->color >> 24;
337 fcolor[1] = (node->color >> 16) & 0xff;
338 fcolor[2] = (node->color >> 8) & 0xff;
339 falpha = node->color & 0xff;
340 error = FT_New_Face( library,
341 (char *)node->filename,
345 use_kerning = FT_HAS_KERNING(face);
347 error = FT_Set_Char_Size(face, /* handle to face object */
348 (long)(node->size*64),
349 (long)(node->size*64),
350 (long)(100*canvas->zoom),
351 (long)(100*canvas->zoom));
353 pen_x = node->x * canvas->zoom;
354 pen_y = node->y * canvas->zoom;
357 for(text=(unsigned char *)node->text;*text;text++) {
358 previous = glyph_index;
359 glyph_index = FT_Get_Char_Index( face, *text);
361 if (use_kerning && previous && glyph_index){
363 FT_Get_Kerning( face, previous, glyph_index,
365 text_width += (double)delta.x / 64.0;
368 error = FT_Load_Glyph( face, glyph_index, 0 );
371 pen_x -= (double)slot->metrics.horiBearingX / 64.0; /* adjust pos for first char */
372 text_width -= (double)slot->metrics.horiBearingX / 64.0; /* add just char width */
374 if ( text_height < (double)slot->metrics.horiBearingY / 64.0 ) {
375 text_height = (double)slot->metrics.horiBearingY / 64.0;
377 text_width += (double)slot->metrics.horiAdvance / 64.0;
379 text_width -= (double)slot->metrics.horiAdvance / 64.0; /* remove last step */
380 text_width += (double)slot->metrics.width / 64.0; /* add just char width */
381 text_width += (double)slot->metrics.horiBearingX / 64.0; /* add just char width */
383 switch(node->halign){
384 case GFX_H_RIGHT: pen_x -= text_width; break;
385 case GFX_H_CENTER: pen_x -= text_width / 2.0; break;
386 case GFX_H_LEFT: break;
387 case GFX_H_NULL: break;
390 switch(node->valign){
391 case GFX_V_TOP: pen_y += text_height; break;
392 case GFX_V_CENTER: pen_y += text_height / 2.0; break;
393 case GFX_V_BOTTOM: break;
394 case GFX_V_NULL: break;
398 for(text=(unsigned char *)node->text;*text;text++) {
400 previous = glyph_index;
401 glyph_index = FT_Get_Char_Index( face, *text);
403 if (use_kerning && previous && glyph_index){
405 FT_Get_Kerning( face, previous, glyph_index,
407 pen_x += (double)delta.x / 64.0;
410 error = FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER );
412 gr = slot->bitmap.num_grays -1;
413 for (iy=0; iy < slot->bitmap.rows; iy++){
414 long buf_y = iy+(pen_y+0.5)-slot->bitmap_top;
415 if (buf_y < 0 || buf_y >= pys_height) continue;
417 for (ix=0;ix < slot->bitmap.width;ix++){
418 long buf_x = ix + (pen_x + 0.5) + (double)slot->bitmap_left ;
421 if (buf_x < 0 || buf_x >= pys_width) continue;
422 buf_x *= bytes_per_pixel ;
423 font_alpha = *(slot->bitmap.buffer + iy * slot->bitmap.width + ix);
424 font_alpha = (art_u8)((double)font_alpha / gr * falpha);
425 for (iz = 0; iz < 3; iz++){
426 art_u8 *orig = buffer + buf_y + buf_x + iz;
427 *orig = (art_u8)((double)*orig / gr * ( gr - font_alpha) +
428 (double)fcolor[iz] / gr * (font_alpha));
432 pen_x += (double)slot->metrics.horiAdvance / 64.0;
438 gfx_save_png(buffer,fp , pys_width,pys_height,bytes_per_pixel);
440 FT_Done_FreeType( library );
444 /* free memory used by nodes this will also remove memory required for
445 associated paths and svcs ... but not for text strings */
447 gfx_destroy (gfx_canvas_t *canvas){
448 gfx_node_t *next,*node = canvas->firstnode;
451 art_free(node->path);
454 free(node->filename);
461 static int gfx_save_png (art_u8 *buffer, FILE *fp, long width, long height, long bytes_per_pixel){
462 png_structp png_ptr = NULL;
463 png_infop info_ptr = NULL;
465 png_bytep *row_pointers;
466 int rowstride = width * bytes_per_pixel;
472 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL);
477 row_pointers = (png_bytepp)png_malloc(png_ptr,
478 height*sizeof(png_bytep));
480 info_ptr = png_create_info_struct(png_ptr);
482 if (info_ptr == NULL)
484 png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
488 if (setjmp(png_jmpbuf(png_ptr)))
490 /* If we get here, we had a problem writing the file */
491 png_destroy_write_struct(&png_ptr, &info_ptr);
495 png_init_io(png_ptr, fp);
496 png_set_IHDR (png_ptr, info_ptr,width, height,
497 8, PNG_COLOR_TYPE_RGB,
499 PNG_COMPRESSION_TYPE_DEFAULT,
500 PNG_FILTER_TYPE_DEFAULT);
502 text[0].key = "Software";
503 text[0].text = "RRDtool, Tobias Oetiker <tobi@oetike.ch>, http://tobi.oetiker.ch";
504 text[0].compression = PNG_TEXT_COMPRESSION_NONE;
505 png_set_text (png_ptr, info_ptr, text, 1);
507 /* Write header data */
508 png_write_info (png_ptr, info_ptr);
510 for (i = 0; i < height; i++)
511 row_pointers[i] = (png_bytep) (buffer + i*rowstride);
513 png_write_image(png_ptr, row_pointers);
514 png_write_end(png_ptr, info_ptr);
515 png_destroy_write_struct(&png_ptr, &info_ptr);
520 /* ------- SVG -------
522 http://www.w3.org/TR/SVG/
524 static int svg_indent = 0;
525 static int svg_single_line = 0;
526 static const char *svg_default_font = "Helvetica";
528 static void svg_print_indent(FILE *fp)
531 for (i = svg_indent - svg_single_line; i > 0; i--) {
537 static void svg_start_tag(FILE *fp, const char *name)
539 svg_print_indent(fp);
545 static void svg_close_tag_single_line(FILE *fp)
551 static void svg_close_tag(FILE *fp)
554 if (!svg_single_line)
558 static void svg_end_tag(FILE *fp, const char *name)
560 /* name is NULL if closing empty-node tag */
565 svg_print_indent(fp);
575 static void svg_close_tag_empty_node(FILE *fp)
577 svg_end_tag(fp, NULL);
580 static void svg_write_text(FILE *fp, const char *p)
583 const char *start, *last;
586 /* trim leading spaces */
590 /* trim trailing spaces */
592 while ((ch = *p) != 0) {
597 /* encode trimmed text */
602 case '&': fputs("&", fp); break;
603 case '<': fputs("<", fp); break;
604 case '>': fputs(">", fp); break;
605 case '"': fputs(""", fp); break;
606 default: putc(ch, fp);
611 static void svg_write_number(FILE *fp, double d)
613 /* omit decimals if integer to reduce filesize */
615 snprintf(buf, sizeof(buf), "%.2f", d);
616 p = buf; /* doesn't trust snprintf return value */
622 *p = '\0'; /* zap trailing zeros */
626 *p = '\0'; /* zap trailing dot */
632 static int svg_color_is_black(int c)
634 /* gfx_color_t is RRGGBBAA */
635 return c == 0x000000FF;
638 static void svg_write_color(FILE *fp, gfx_color_t c, const char *attr)
640 /* gfx_color_t is RRGGBBAA, svg can use #RRGGBB and #RGB like html */
641 gfx_color_t rrggbb = (int)((c >> 8) & 0xFFFFFF);
642 gfx_color_t opacity = c & 0xFF;
643 fprintf(fp, " %s=\"", attr);
644 if ((rrggbb & 0x0F0F0F) == ((rrggbb >> 4) & 0x0F0F0F)) {
645 /* css2 short form, #rgb is #rrggbb, not #r0g0b0 */
646 fprintf(fp, "#%03lX",
647 ( ((rrggbb >> 8) & 0xF00)
648 | ((rrggbb >> 4) & 0x0F0)
649 | ( rrggbb & 0x00F)));
651 fprintf(fp, "#%06lX", rrggbb);
654 if (opacity != 0xFF) {
655 fprintf(fp, " stroke-opacity=\"");
656 svg_write_number(fp, opacity / 255.0);
661 static void svg_common_path_attributes(FILE *fp, gfx_node_t *node)
663 fputs(" stroke-width=\"", fp);
664 svg_write_number(fp, node->size);
666 svg_write_color(fp, node->color, "stroke");
667 fputs(" fill=\"none\"", fp);
668 if (node->dash_on != 0 && node->dash_off != 0) {
669 fputs(" stroke-dasharray=\"", fp);
670 svg_write_number(fp, node->dash_on);
672 svg_write_number(fp, node->dash_off);
677 static int svg_is_int_step(double a, double b)
679 double diff = fabs(a - b);
680 return floor(diff) == diff;
683 static int svg_path_straight_segment(FILE *fp,
684 double lastA, double currentA, double currentB,
686 int segment_idx, int isx, char absChar, char relChar)
688 if (!svg_is_int_step(lastA, currentA)) {
690 svg_write_number(fp, currentA);
693 if (segment_idx < node->points - 1) {
694 ArtVpath *vec = node->path + segment_idx + 1;
695 if (vec->code == ART_LINETO) {
696 double nextA = (isx ? vec->x : vec->y) - LINEOFFSET;
697 double nextB = (isx ? vec->y : vec->x) - LINEOFFSET;
698 if (nextB == currentB
699 && ((currentA >= lastA) == (nextA >= currentA))
700 && svg_is_int_step(currentA, nextA)) {
701 return 1; /* skip to next as it is a straight line */
706 svg_write_number(fp, currentA - lastA);
710 static void svg_path(FILE *fp, gfx_node_t *node, int multi)
713 double lastX = 0, lastY = 0;
714 /* for straight lines <path..> tags take less space than
715 <line..> tags because of the efficient packing
716 in the 'd' attribute */
717 svg_start_tag(fp, "path");
719 svg_common_path_attributes(fp, node);
721 /* specification of the 'd' attribute: */
722 /* http://www.w3.org/TR/SVG/paths.html#PathDataGeneralInformation */
723 for (i = 0; i < node->points; i++) {
724 ArtVpath *vec = node->path + i;
725 double x = vec->x - LINEOFFSET;
726 double y = vec->y - LINEOFFSET;
728 case ART_MOVETO_OPEN: /* fall-through */
731 svg_write_number(fp, x);
733 svg_write_number(fp, y);
736 /* try optimize filesize by using minimal lineto commands */
737 /* without introducing rounding errors. */
739 if (svg_path_straight_segment(fp, lastY, y, x, node, i, 0, 'V', 'v'))
741 } else if (y == lastY) {
742 if (svg_path_straight_segment(fp, lastX, x, y, node, i, 1, 'H', 'h'))
746 svg_write_number(fp, x);
748 svg_write_number(fp, y);
751 case ART_CURVETO: break; /* unsupported */
752 case ART_END: break; /* nop */
757 if (node->closed_path)
760 svg_close_tag_empty_node(fp);
763 static void svg_multi_path(FILE *fp, gfx_node_t **nodeR)
765 /* optimize for multiple paths with the same color, penwidth, etc. */
767 gfx_node_t *node = *nodeR;
768 gfx_node_t *next = node->next;
770 if (next->type != node->type
771 || next->size != node->size
772 || next->color != node->color
773 || next->dash_on != node->dash_on
774 || next->dash_off != node->dash_off)
780 svg_path(fp, node, 0);
783 svg_start_tag(fp, "g");
784 svg_common_path_attributes(fp, node);
786 while (num && node) {
787 svg_path(fp, node, 1);
793 svg_end_tag(fp, "g");
796 static void svg_area(FILE *fp, gfx_node_t *node)
799 double startX = 0, startY = 0;
800 svg_start_tag(fp, "polygon");
802 svg_write_color(fp, node->color, "fill");
803 fputs(" points=\"", fp);
804 for (i = 0; i < node->points; i++) {
805 ArtVpath *vec = node->path + i;
806 double x = vec->x - LINEOFFSET;
807 double y = vec->y - LINEOFFSET;
809 case ART_MOVETO_OPEN: /* fall-through */
811 svg_write_number(fp, x);
813 svg_write_number(fp, y);
818 if (i == node->points - 2
819 && node->path[i + 1].code == ART_END
820 && fabs(x - startX) < 0.001 && fabs(y - startY) < 0.001) {
821 break; /* poly area always closed, no need for last point */
824 svg_write_number(fp, x);
826 svg_write_number(fp, y);
828 case ART_CURVETO: break; /* unsupported */
829 case ART_END: break; /* nop */
833 svg_close_tag_empty_node(fp);
836 static void svg_text(FILE *fp, gfx_node_t *node)
838 double x = node->x - LINEOFFSET;
839 double y = node->y - LINEOFFSET;
840 if (node->angle != 0) {
841 svg_start_tag(fp, "g");
842 fputs(" transform=\"translate(", fp);
843 svg_write_number(fp, x);
845 svg_write_number(fp, y);
846 fputs(") rotate(", fp);
847 svg_write_number(fp, node->angle);
852 switch (node->valign) {
853 case GFX_V_TOP: y += node->size; break;
854 case GFX_V_CENTER: y += node->size / 2; break;
855 case GFX_V_BOTTOM: break;
856 case GFX_V_NULL: break;
858 svg_start_tag(fp, "text");
860 svg_write_number(fp, x);
861 fputs("\" y=\"", fp);
862 svg_write_number(fp, y);
863 if (strcmp(node->filename, svg_default_font))
864 fprintf(fp, " font-family=\"%s\"", node->filename);
865 fputs("\" font-size=\"", fp);
866 svg_write_number(fp, node->size);
868 if (!svg_color_is_black(node->color))
869 svg_write_color(fp, node->color, "fill");
870 switch (node->halign) {
871 case GFX_H_RIGHT: fputs(" text-anchor=\"end\"", fp); break;
872 case GFX_H_CENTER: fputs(" text-anchor=\"middle\"", fp); break;
873 case GFX_H_LEFT: break;
874 case GFX_H_NULL: break;
876 svg_close_tag_single_line(fp);
877 /* support for node->tabwidth missing */
878 svg_write_text(fp, node->text);
879 svg_end_tag(fp, "text");
880 if (node->angle != 0)
881 svg_end_tag(fp, "g");
884 int gfx_render_svg (gfx_canvas_t *canvas,
885 art_u32 width, art_u32 height,
886 gfx_color_t background, FILE *fp){
887 gfx_node_t *node = canvas->firstnode;
889 "<?xml version=\"1.0\" standalone=\"no\"?>\n"
890 "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\"\n"
891 " \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"
893 " SVG file created by RRDtool,\n"
894 " Tobias Oetiker <tobi@oetike.ch>, http://tobi.oetiker.ch\n"
896 " The width/height attributes in the outhermost svg node\n"
897 " are just default sizes for the browser which is used\n"
898 " if the svg file is openened directly without being\n"
899 " embedded in an html file.\n"
900 " The viewBox is the local coord system for rrdtool.\n"
902 svg_start_tag(fp, "svg");
903 fputs(" width=\"", fp);
904 svg_write_number(fp, width * canvas->zoom);
905 fputs("\" height=\"", fp);
906 svg_write_number(fp, height * canvas->zoom);
907 fputs("\" x=\"0\" y=\"0\" viewBox=\"", fp);
908 svg_write_number(fp, -LINEOFFSET);
910 svg_write_number(fp, -LINEOFFSET);
912 svg_write_number(fp, width - LINEOFFSET);
914 svg_write_number(fp, height - LINEOFFSET);
915 fputs("\" preserveAspectRatio=\"xMidYMid\"", fp);
916 fprintf(fp, " font-family=\"%s\"", svg_default_font); /* default font */
917 fputs(" stroke-linecap=\"round\" stroke-linejoin=\"round\"", fp);
919 svg_start_tag(fp, "rect");
920 fprintf(fp, " x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"", width, height);
921 svg_write_color(fp, background, "fill");
922 svg_close_tag_empty_node(fp);
924 switch (node->type) {
926 svg_multi_path(fp, &node);
936 svg_end_tag(fp, "svg");