summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2002-04-25 15:52:26 +0000
committerJames Bursa <james@netsurf-browser.org>2002-04-25 15:52:26 +0000
commitf5044a6d872c5afd90030eed202ff27c0c2b832d (patch)
tree813018979d70790e096a5f2a8abd243c60912272 /render
parent33dc126f5354ce2efd3767c9f96f9d435056d24a (diff)
downloadnetsurf-f5044a6d872c5afd90030eed202ff27c0c2b832d.tar.gz
netsurf-f5044a6d872c5afd90030eed202ff27c0c2b832d.tar.bz2
[project @ 2002-04-25 15:52:26 by bursa]
Interface to fonts. svn path=/import/netsurf/; revision=8
Diffstat (limited to 'render')
-rw-r--r--render/font.c59
-rw-r--r--render/font.h22
2 files changed, 81 insertions, 0 deletions
diff --git a/render/font.c b/render/font.c
new file mode 100644
index 000000000..068687431
--- /dev/null
+++ b/render/font.c
@@ -0,0 +1,59 @@
+/**
+ * $Id: font.c,v 1.1 2002/04/25 15:52:26 bursa Exp $
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "font.h"
+
+/**
+ * internal structures
+ */
+
+struct font_set {
+ /* a set of font handles */
+};
+
+/**
+ * functions
+ */
+
+struct font_set * font_set_create(void)
+{
+ return 0;
+}
+
+font_id font_add(struct font_set * font_set, const char * name, unsigned int weight,
+ unsigned int size)
+{
+ return 0;
+}
+
+void font_set_free(struct font_set * font_set)
+{
+}
+
+/**
+ * find where to split some text to fit it in width
+ */
+
+unsigned long font_split(struct font_set * font_set, font_id id, const char * text,
+ unsigned long width, const char ** end)
+{
+ size_t len = strlen(text);
+ unsigned int i;
+ assert(width >= 1);
+ if (len <= width) {
+ *end = text + len;
+ return len;
+ }
+ /* invariant: no space in text[i+1..width) */
+ for (i = width - 1; i != 0 && text[i] != ' '; i--)
+ ;
+ *end = text + i;
+ return i;
+}
+
+
diff --git a/render/font.h b/render/font.h
new file mode 100644
index 000000000..db10b20b2
--- /dev/null
+++ b/render/font.h
@@ -0,0 +1,22 @@
+/**
+ * $Id: font.h,v 1.1 2002/04/25 15:52:26 bursa Exp $
+ */
+
+/**
+ * structures and typedefs
+ */
+
+struct font_set;
+typedef unsigned int font_id;
+
+/**
+ * interface
+ */
+
+struct font_set * font_set_create(void);
+font_id font_add(struct font_set * font_set, const char * name, unsigned int weight,
+ unsigned int size);
+void font_set_free(struct font_set * font_set);
+unsigned long font_split(struct font_set * font_set, font_id id, const char * text,
+ unsigned long width, const char ** end);
+