You are not logged in.
This printf function works almost exactly like the standard printf function, except it takes a font as well.
Keep in mind that I used Crayon's Printf as the base for this, and have not yet tested it (but it should work!)
int _GRRLIB_global_x;
int _GRRLIB_global_y;
int _GRRLIB_global_simple_printf_uninitialized=1;
void GRRLIB_SimplePrintf(u8 font[], const char *text,...)
{
int i, size, n = 0;
char tmp[1024];
u16 charHeight = 8, charWidth = 8;
if(_GRRLIB_global_simple_printf_uninitialized)
{
_GRRLIB_global_x=-1*charHeight;
_GRRLIB_global_y=0;
_GRRLIB_global_simple_printf_uninitialized=0;
}
va_list argp;
va_start(argp, text);
size = vsprintf(tmp, text, argp);
va_end(argp);
GXColor col = GRRLIB_Splitu32(0xFF000000);
for(i=0; i<size; i++, n++)
{
_GRRLIB_global_x+=charWidth;
if(tmp[i] == '\n')
{
_GRRLIB_global_y += (charHeight);
n = -1;
_GRRLIB_global_x=-charHeight;
}
else
{
GRRLIB_DrawChar(_GRRLIB_global_x+n*charWidth*zoom, _GRRLIB_global_y, charWidth, charHeight, data, 0, 1, 1, tmp[i], 128, col );
}
}
}Offline
always nice too see contributions ![]()
btw what a grrlib+ for ?? why dont you join us ?? (in fact me
) to help me maintenaing grrlib ?? ![]()
Offline
SquidMan if you really want to make something more general, you could add (not tested):
else if(tmp[i] == '\t')
{ // Tabs are 4 spaces
GRRLIB_DrawChar(_GRRLIB_global_x+n*charWidth*zoom, _GRRLIB_global_y, charWidth, charHeight, data, 0, 1, 1, ' ', 128, col );
GRRLIB_DrawChar(_GRRLIB_global_x+n*charWidth*zoom, _GRRLIB_global_y, charWidth, charHeight, data, 0, 1, 1, ' ', 128, col );
GRRLIB_DrawChar(_GRRLIB_global_x+n*charWidth*zoom, _GRRLIB_global_y, charWidth, charHeight, data, 0, 1, 1, ' ', 128, col );
GRRLIB_DrawChar(_GRRLIB_global_x+n*charWidth*zoom, _GRRLIB_global_y, charWidth, charHeight, data, 0, 1, 1, ' ', 128, col );
}NoNameNo I've been trying to help for months, what append to the repository? What I see is nonameno logged in 21 days ago! I sent you an email with a suggestion on how to use fonts and you never replied. I still want to help and I look forward to use a new release of GRRLIB.
Last edited by Crayon (2008-09-17 20:59:07)
Offline