2013-09-15 03:44:04 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Ole Loots <ole@monochrom.net>
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2012-08-24 02:47:37 +04:00
|
|
|
*/
|
|
|
|
|
2014-10-17 13:48:50 +04:00
|
|
|
#include "desktop/mouse.h"
|
|
|
|
|
2012-07-14 00:19:04 +04:00
|
|
|
#include "atari/plot/fontplot.h"
|
|
|
|
|
2013-09-15 03:44:04 +04:00
|
|
|
const struct s_font_driver_table_entry font_driver_table[] =
|
2012-07-14 00:19:04 +04:00
|
|
|
{
|
2013-09-15 03:44:04 +04:00
|
|
|
#ifdef WITH_VDI_FONT_DRIVER
|
|
|
|
{"vdi", ctor_font_plotter_vdi, 0},
|
2012-07-14 00:19:04 +04:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_FREETYPE_FONT_DRIVER
|
|
|
|
{"freetype", ctor_font_plotter_freetype, 0},
|
|
|
|
#endif
|
2013-09-15 03:44:04 +04:00
|
|
|
#ifdef WITH_INTERNAL_FONT_DRIVER
|
2012-07-14 00:19:04 +04:00
|
|
|
{"internal", ctor_font_plotter_internal, 0},
|
2013-09-15 03:44:04 +04:00
|
|
|
#endif
|
|
|
|
{(char*)NULL, NULL, 0}
|
2012-07-14 00:19:04 +04:00
|
|
|
};
|
|
|
|
|
2013-09-15 03:44:04 +04:00
|
|
|
void dump_font_drivers(void)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
while( font_driver_table[i].name != NULL ) {
|
2013-09-16 04:26:43 +04:00
|
|
|
printf("%s -> flags: %d\n", font_driver_table[i].name,
|
|
|
|
font_driver_table[i].flags);
|
2013-09-15 03:44:04 +04:00
|
|
|
i++;
|
|
|
|
}
|
2012-07-14 00:19:04 +04:00
|
|
|
}
|
|
|
|
|
2013-09-15 03:44:04 +04:00
|
|
|
|
2013-09-15 06:15:26 +04:00
|
|
|
/**
|
2013-09-15 03:44:04 +04:00
|
|
|
* Create an new text plotter object
|
2013-09-15 06:15:26 +04:00
|
|
|
*
|
|
|
|
* Available: "vdi", "freetype", "internal"
|
|
|
|
* \param vdihandle the vdi handle to act upon,
|
|
|
|
* \param name selector ID (string) of the font plotter.
|
|
|
|
* flags flags configration flags of the plotter,
|
2013-09-15 03:44:04 +04:00
|
|
|
* available flags:
|
|
|
|
* FONTPLOT_FLAG_MONOGLYPH - Enable 1 bit font plotting
|
2013-09-15 06:15:26 +04:00
|
|
|
* \param error set to != 0 when errors occur
|
|
|
|
* \return the new font plotter instance on success, or NULL on failure.
|
2013-09-15 03:44:04 +04:00
|
|
|
*/
|
2013-09-15 06:15:26 +04:00
|
|
|
FONT_PLOTTER new_font_plotter(int vdihandle, char * name, unsigned long flags,
|
2013-09-15 03:44:04 +04:00
|
|
|
int * error)
|
|
|
|
{
|
|
|
|
int i=0;
|
|
|
|
int res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
2013-09-15 06:15:26 +04:00
|
|
|
FONT_PLOTTER fplotter = NULL;
|
2013-09-15 03:44:04 +04:00
|
|
|
|
2013-09-15 06:15:26 +04:00
|
|
|
/* set the default error code: */
|
|
|
|
*error = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
2013-09-15 03:44:04 +04:00
|
|
|
|
2013-09-15 06:15:26 +04:00
|
|
|
|
|
|
|
/* Find the selector string in the font plotter table, */
|
|
|
|
/* and bail out when the font plotter is not available: */
|
|
|
|
for (i = 0; font_driver_table[i].name != NULL; i++) {
|
|
|
|
|
|
|
|
/* found selector in driver table? */
|
|
|
|
if (strcmp(name, font_driver_table[i].name) == 0) {
|
|
|
|
|
|
|
|
/* allocate the font plotter instance: */
|
|
|
|
fplotter = (FONT_PLOTTER)malloc(sizeof(struct s_font_plotter));
|
|
|
|
if (fplotter == NULL) {
|
|
|
|
*error = 0-ERR_NO_MEM;
|
|
|
|
return(NULL);
|
2013-09-15 03:44:04 +04:00
|
|
|
}
|
2013-09-15 06:15:26 +04:00
|
|
|
|
|
|
|
/* Initialize the font plotter with the requested settings: */
|
|
|
|
memset( fplotter, 0, sizeof(FONT_PLOTTER));
|
|
|
|
fplotter->vdi_handle = vdihandle;
|
|
|
|
fplotter->name = name;
|
|
|
|
fplotter->flags = 0;
|
|
|
|
fplotter->flags |= flags;
|
|
|
|
|
|
|
|
/* Execute the constructor: */
|
|
|
|
assert(font_driver_table[i].ctor);
|
|
|
|
res = font_driver_table[i].ctor(fplotter);
|
|
|
|
|
|
|
|
/* success? */
|
|
|
|
if (res < 0) {
|
|
|
|
/* NO success! */
|
|
|
|
free(fplotter);
|
|
|
|
*error = res;
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
*error = 0;
|
|
|
|
break;
|
2013-09-15 03:44:04 +04:00
|
|
|
}
|
|
|
|
}
|
2013-09-15 06:15:26 +04:00
|
|
|
|
|
|
|
return(fplotter);
|
2012-07-14 00:19:04 +04:00
|
|
|
}
|
|
|
|
|
2013-09-15 03:44:04 +04:00
|
|
|
/*
|
|
|
|
Free an font plotter
|
|
|
|
*/
|
|
|
|
int delete_font_plotter(FONT_PLOTTER p)
|
|
|
|
{
|
2013-09-15 06:15:26 +04:00
|
|
|
if (p) {
|
2013-09-15 03:44:04 +04:00
|
|
|
p->dtor(p);
|
2013-09-15 06:15:26 +04:00
|
|
|
free(p);
|
2013-09-15 03:44:04 +04:00
|
|
|
p = NULL;
|
|
|
|
}
|
|
|
|
else
|
2013-09-15 06:15:26 +04:00
|
|
|
return(-1);
|
|
|
|
return(0);
|
2012-07-14 00:19:04 +04:00
|
|
|
}
|
|
|
|
|