summaryrefslogtreecommitdiff
path: root/examples/css-file/main.c
diff options
context:
space:
mode:
authorkx <kx@radix-linux.su>2026-10-17 16:39:23 +0300
committerkx <kx@radix-linux.su>2026-10-17 16:39:23 +0300
commitec1891d58b9514b621725620453cec0e31e18389 (patch)
tree6721f92c0afae3d933343b4a573ac8e5389827c6 /examples/css-file/main.c
parent73d23259a690cd29c0ac74a4de963e23ecfebfac (diff)
downloadsvgc-trunk.tar.xz
Version 1.1.0HEAD1.1.0trunk
Diffstat (limited to 'examples/css-file/main.c')
-rw-r--r--examples/css-file/main.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/examples/css-file/main.c b/examples/css-file/main.c
new file mode 100644
index 0000000..5f56cd1
--- /dev/null
+++ b/examples/css-file/main.c
@@ -0,0 +1,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 );
+}