NetSurf
fontplot.c
Go to the documentation of this file.
1/*
2 * Copyright 2010 Ole Loots <ole@monochrom.net>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <stdbool.h>
20#include <assert.h>
21#include <stdlib.h>
22#include <mt_gem.h>
23
24#include "netsurf/mouse.h"
25#include "netsurf/plot_style.h"
26
27#include "atari/bitmap.h"
28#include "atari/plot/fontplot.h"
29
31{
32#ifdef WITH_VDI_FONT_DRIVER
33 {"vdi", ctor_font_plotter_vdi, 0},
34#endif
35#ifdef WITH_FREETYPE_FONT_DRIVER
36 {"freetype", ctor_font_plotter_freetype, 0},
37#endif
38#ifdef WITH_INTERNAL_FONT_DRIVER
39 {"internal", ctor_font_plotter_internal, 0},
40#endif
41 {(char*)NULL, NULL, 0}
42};
43
45{
46 int i = 0;
47 while( font_driver_table[i].name != NULL ) {
48 printf("%s -> flags: %d\n", font_driver_table[i].name,
50 i++;
51 }
52}
53
54
55/**
56 * Create an new text plotter object.
57 *
58 * Available: "vdi", "freetype", "internal"
59 *
60 * \param vdihandle the vdi handle to act upon,
61 * \param name selector ID (string) of the font plotter.
62 * \param flags configration flags of the plotter, available flags:
63 * FONTPLOT_FLAG_MONOGLYPH - Enable 1 bit font plotting
64 * \param error set to != 0 when errors occur
65 * \return the new font plotter instance on success, or NULL on failure.
66 */
68 int * error)
69{
70 int i=0;
71 int res = 0-ERR_PLOTTER_NOT_AVAILABLE;
73
74 /* set the default error code: */
76
77
78 /* Find the selector string in the font plotter table, */
79 /* and bail out when the font plotter is not available: */
80 for (i = 0; font_driver_table[i].name != NULL; i++) {
81
82 /* found selector in driver table? */
83 if (strcmp(name, font_driver_table[i].name) == 0) {
84
85 /* allocate the font plotter instance: */
86 fplotter = (FONT_PLOTTER)malloc(sizeof(struct s_font_plotter));
87 if (fplotter == NULL) {
88 *error = 0-ERR_NO_MEM;
89 return(NULL);
90 }
91
92 /* Initialize the font plotter with the requested settings: */
93 memset( fplotter, 0, sizeof(FONT_PLOTTER));
96 fplotter->flags = 0;
98
99 /* Execute the constructor: */
100 assert(font_driver_table[i].ctor);
102
103 /* success? */
104 if (res < 0) {
105 /* NO success! */
106 free(fplotter);
107 *error = res;
108 return(NULL);
109 }
110 *error = 0;
111 break;
112 }
113 }
114
115 return(fplotter);
116}
117
118/*
119 Free an font plotter
120*/
122{
123 if (p) {
124 p->dtor(p);
125 free(p);
126 p = NULL;
127 }
128 else
129 return(-1);
130 return(0);
131}
132
VdiHdl vdihandle
Definition: about.c:46
int ctor_font_plotter_freetype(FONT_PLOTTER self)
#define ERR_NO_MEM
Definition: plot.h:54
#define ERR_PLOTTER_NOT_AVAILABLE
Definition: plot.h:55
const struct s_font_driver_table_entry font_driver_table[]
Definition: fontplot.c:30
void dump_font_drivers(void)
Definition: fontplot.c:44
FONT_PLOTTER new_font_plotter(int vdihandle, char *name, unsigned long flags, int *error)
Create an new text plotter object.
Definition: fontplot.c:67
int delete_font_plotter(FONT_PLOTTER p)
Definition: fontplot.c:121
struct s_font_plotter * FONT_PLOTTER
Definition: fontplot.h:22
Atari bitmap handling implementation.
FONT_PLOTTER fplotter
Definition: plot.c:165
Core mouse and pointer states.
plotter style interfaces, generic styles and style colour helpers.
Definition: fontplot.h:25
int(* ctor)(FONT_PLOTTER self)
Definition: fontplot.h:27
int flags
Definition: fontplot.h:28
const char * name
Definition: fontplot.h:26
_fpmf_dtor dtor
Definition: fontplot.h:61
char * name
Definition: fontplot.h:51
int vdi_handle
Definition: fontplot.h:53