summaryrefslogtreecommitdiff
path: root/atari/plot/fontplot.c
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2012-07-13 22:19:04 +0200
committerOle Loots <ole@monochrom.net>2012-07-13 22:19:04 +0200
commit37b8c5d83da69a13ce155c040a90cc6a850dc456 (patch)
tree880da99da6f1adf828cca663dcf94d436504a3ac /atari/plot/fontplot.c
parentbc9d29f00ae84ae8fc9963f789358e4953100ea6 (diff)
downloadnetsurf-37b8c5d83da69a13ce155c040a90cc6a850dc456.tar.gz
netsurf-37b8c5d83da69a13ce155c040a90cc6a850dc456.tar.bz2
Plotter refactor: removed one plotter abraction layer.
Diffstat (limited to 'atari/plot/fontplot.c')
-rw-r--r--atari/plot/fontplot.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/atari/plot/fontplot.c b/atari/plot/fontplot.c
new file mode 100644
index 000000000..ba4e26776
--- /dev/null
+++ b/atari/plot/fontplot.c
@@ -0,0 +1,88 @@
+#include "atari/plot/fontplot.h"
+
+const struct s_font_driver_table_entry font_driver_table[] =
+{
+#ifdef WITH_VDI_FONT_DRIVER
+ {"vdi", ctor_font_plotter_vdi, 0},
+#endif
+#ifdef WITH_FREETYPE_FONT_DRIVER
+ {"freetype", ctor_font_plotter_freetype, 0},
+#endif
+#ifdef WITH_INTERNAL_FONT_DRIVER
+ {"internal", ctor_font_plotter_internal, 0},
+#endif
+ {(char*)NULL, NULL, 0}
+};
+
+void dump_font_drivers(void)
+{
+ int i = 0;
+ while( font_driver_table[i].name != NULL ) {
+ printf("%s -> flags: %d\n",
+ font_driver_table[i].name,
+ font_driver_table[i].flags
+ );
+ i++;
+ }
+}
+
+
+/*
+ Create an new text plotter object
+*/
+FONT_PLOTTER new_font_plotter( int vdihandle, char * name, unsigned long flags,
+ int * error)
+{
+ int i=0;
+ int res = 0-ERR_PLOTTER_NOT_AVAILABLE;
+ FONT_PLOTTER fplotter = (FONT_PLOTTER)malloc( sizeof(struct s_font_plotter) );
+ if( fplotter == NULL ) {
+ *error = 0-ERR_NO_MEM;
+ return( NULL );
+ }
+ memset( fplotter, 0, sizeof(FONT_PLOTTER));
+ fplotter->vdi_handle = vdihandle;
+ fplotter->name = name;
+ fplotter->flags = 0;
+ fplotter->flags |= flags;
+ for( i = 0; ; i++) {
+ if( font_driver_table[i].name == NULL ) {
+ res = 0-ERR_PLOTTER_NOT_AVAILABLE;
+ break;
+ } else {
+ if( strcmp(name, font_driver_table[i].name) == 0 ) {
+ if( font_driver_table[i].ctor ) {
+ res = font_driver_table[i].ctor( fplotter );
+ *error = 0;
+ } else {
+ res = 0-ERR_PLOTTER_NOT_AVAILABLE;
+ *error = res;
+ return (NULL);
+ }
+ break;
+ }
+ }
+ }
+ if( res < 0 ) {
+ free( fplotter );
+ *error = res;
+ return( NULL );
+ }
+ return( fplotter );
+}
+
+/*
+ Free an font plotter
+*/
+int delete_font_plotter(FONT_PLOTTER p)
+{
+ if( p ) {
+ p->dtor(p);
+ free( p );
+ p = NULL;
+ }
+ else
+ return( -1 );
+ return( 0 );
+}
+