1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/***************************************************************
SVGC EXAMPLE: STYLESHEET FILE
This example reads CSS once and embeds its contents into SVG defs.
***************************************************************/
#include <stdio.h>
#include <svgc.h>
int
main( void )
{
struct __svg_sheet *sheet;
struct __svg_scene *scene;
struct __svg_node *text;
sheet = (struct __svg_sheet *)__svg_new_sheet( 640, 160, 16, 16, 16, 16 );
if( !sheet ) return( 1 );
/* File content is copied into the sheet; no external CSS is needed later. */
if( __svg_sheet_add_css_file( sheet, "fonts.css" ) != 1 )
{
__svg_free_node( sheet );
fprintf( stderr, "Cannot add fonts.css to the SVG sheet\n" );
return( 1 );
}
scene = __svg_new_scene( sheet );
if( !scene )
{
__svg_free_node( sheet );
return( 1 );
}
text = __svg_new_text( 36, 90, "SVG fonts from CSS", "Roboto", 28 );
if( !text || __svg_scene_add_node( scene, text ) != 1 )
{
if( text ) __svg_free_node( text );
__svg_free_scene( scene );
return( 1 );
}
__svg_paint_scene( scene, 0, "example.svg" );
__svg_free_scene( scene );
return( 0 );
}
|