aboutsummaryrefslogtreecommitdiffstats
path: root/libskrift_open_font_mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'libskrift_open_font_mem.c')
-rw-r--r--libskrift_open_font_mem.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libskrift_open_font_mem.c b/libskrift_open_font_mem.c
new file mode 100644
index 0000000..3828546
--- /dev/null
+++ b/libskrift_open_font_mem.c
@@ -0,0 +1,18 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+int
+libskrift_open_font_mem(LIBSKRIFT_FONT **fontp, const void *mem, size_t size)
+{
+ *fontp = calloc(1, sizeof(**fontp));
+ if (!*fontp)
+ return -1;
+ (*fontp)->refcount = 1;
+ (*fontp)->font = sft_loadmem(mem, size);
+ if (!(*fontp)->font) {
+ free(*fontp);
+ *fontp = NULL;
+ return -1;
+ }
+ return 0;
+}