aboutsummaryrefslogtreecommitdiff
path: root/libstorycode/stylesheet.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-01-25 19:45:04 +0100
committerThomas White <taw@physics.org>2020-01-25 19:45:04 +0100
commite5c7702870a1bddac6b46ae82c90864f94172ca9 (patch)
tree86cfd03cdce7bf6e397f1effb7dd1a29cbe9e44a /libstorycode/stylesheet.c
parent2293dfdc93c9c97e26cecc674325e18f8bc6c246 (diff)
Implement loading stylesheets
Diffstat (limited to 'libstorycode/stylesheet.c')
-rw-r--r--libstorycode/stylesheet.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c
index bc22852..16cf218 100644
--- a/libstorycode/stylesheet.c
+++ b/libstorycode/stylesheet.c
@@ -593,6 +593,23 @@ int stylesheet_set_from_storycode(Stylesheet *ss, const char *sc)
}
+int stylesheet_set_from_file(Stylesheet *ss, GFile *file)
+{
+ GBytes *bytes;
+ const char *text;
+ size_t len;
+ int r = 0;
+
+ bytes = g_file_load_bytes(file, NULL, NULL, NULL);
+ if ( bytes == NULL ) return 0;
+
+ text = g_bytes_get_data(bytes, &len);
+ r = stylesheet_set_from_storycode(ss, text);
+ g_bytes_unref(bytes);
+ return r;
+}
+
+
double lcalc(struct length l, double pd)
{
if ( l.unit == LENGTH_UNIT ) {