Added plot_get/set_text_plotter and comments

This commit is contained in:
Ole Loots 2013-09-15 01:44:04 +02:00
parent 569b748172
commit 2c0bcc39bd
3 changed files with 168 additions and 138 deletions

View File

@ -46,23 +46,38 @@ void dump_font_drivers(void)
/*
Create an new text plotter object
* Create an new text plotter object
* Available: "vdi", "freetype"
* @param vdihandle the vdi handle to act upon,
* @param name selector ID (string) of the font plotter.
* @flags flags configration flags of the plotter,
* available flags:
* FONTPLOT_FLAG_MONOGLYPH - Enable 1 bit font plotting
* @param error set to != 0 when errors occur
*/
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) );
FONT_PLOTTER fplotter;
/* allocate the font plotter instance: */
fplotter = (FONT_PLOTTER)malloc( sizeof(struct s_font_plotter) );
if( fplotter == NULL ) {
*error = 0-ERR_NO_MEM;
return( NULL );
}
/* 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;
/* Find the selector string in the font plotter table: */
/* And bail out when the font plotter is not available: */
for( i = 0; ; i++) {
if( font_driver_table[i].name == NULL ) {
res = 0-ERR_PLOTTER_NOT_AVAILABLE;

View File

@ -60,10 +60,15 @@ struct s_font_plotter
};
FONT_PLOTTER plot_get_text_plotter(void);
/* Set the font plotting engine.
*/
void plot_set_text_plotter(FONT_PLOTTER font_plotter);
void dump_font_drivers(void);
FONT_PLOTTER new_font_plotter( int vdihandle, char * name, unsigned long flags,
int * error);
int delete_font_plotter( FONT_PLOTTER p );
#ifdef WITH_VDI_FONT_DRIVER
#include "atari/plot/font_vdi.h"
#endif

View File

@ -1974,6 +1974,16 @@ void plot_get_clip_grect(GRECT * out)
out->g_h = clip.y1 - clip.y0;
}
FONT_PLOTTER plot_get_text_plotter()
{
return(fplotter);
}
void plot_set_text_plotter(FONT_PLOTTER font_plotter)
{
fplotter = font_plotter;
}
static bool plot_text(int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle )
{
fplotter->text(fplotter, x, y, text, length, fstyle);