Yeah, if anything is going to cause trouble it is the fact that TextOut() changed and people had of some reason not used a multiple of 8 as the Y coordinate. ; )
I tried it out, works fine. It is a bit of a workaround though if you ask me, so it would be more nice to be able to just pass the array.
I guess you could actually just use the same FontTextOut() call and pass the array instead. It is pretty easy to tell whether it is a filename or an array, a RIC-font cannot be smaller than 50 bytes and a filename certainly can't get that long. Or you could look at the first two bytes, the first will always be a non-printable character followed by 0.
Code: Select all
byte fontarr[] = { 0x48, 0x02, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, 0x48, 0x00, 0x00, 0x8D, 0x80, 0x43, 0x20, 0x18, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x87, 0x1C, 0x13, 0xE3, 0x3E, 0x71, 0xC0, 0x00, 0x10, 0x04, 0x1C, 0x71, 0xCF, 0x1C, 0xF3, 0xEF, 0x9C, 0x89, 0xC0, 0xA2, 0x82, 0x28, 0x9C, 0xF1, 0xCF, 0x1C, 0xFA, 0x28, 0xA2, 0x8A, 0x2F, 0x1C, 0x01, 0xC2, 0x00, 0x20, 0x08, 0x00, 0x08, 0x03, 0x00, 0x80, 0x81, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x21, 0x85, 0x02, 0x01, 0xCD, 0x94, 0x73, 0x23, 0x18, 0x40, 0x85, 0x08, 0x00, 0x00, 0x02, 0x89, 0x88, 0xA2, 0x32, 0x04, 0x02, 0x8A, 0x20, 0x00, 0x20, 0x02, 0x22, 0x8A, 0x28, 0xA2, 0x8A, 0x08, 0x22, 0x88, 0x80, 0xA4, 0x83, 0x6C, 0xA2, 0x8A, 0x28, 0xA2, 0x22, 0x28, 0xA2, 0x8A, 0x21, 0x10, 0x80, 0x45, 0x00, 0x50, 0x08, 0x00, 0x08, 0x04, 0x00, 0x80, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x4A, 0x02, 0x01, 0xC9, 0x3E, 0x80, 0x44, 0x10, 0x40, 0x87, 0x08, 0x00, 0x00, 0x04, 0x98, 0x80, 0x82, 0x52, 0x08, 0x04, 0x8A, 0x26, 0x18, 0x43, 0xE1, 0x02, 0xBA, 0x28, 0xA0, 0x8A, 0x08, 0x20, 0x88, 0x80, 0xA8, 0x82, 0xAA, 0xA2, 0x8A, 0x28, 0xA0, 0x22, 0x28, 0xAA, 0x52, 0x22, 0x10, 0x40, 0x48, 0x80, 0x21, 0xCF, 0x1C, 0x79, 0xC4, 0x1E, 0xE0, 0x83, 0x24, 0x23, 0x4E, 0x1C, 0xF1, 0xEB, 0x1C, 0xF2, 0x48, 0xA2, 0x92, 0x4F, 0x10, 0x20, 0x40, 0x02, 0x00, 0x80, 0x14, 0x60, 0x84, 0x00, 0x40, 0x8F, 0xBE, 0x03, 0xE0, 0x08, 0xA8, 0x83, 0x1C, 0x93, 0xCF, 0x08, 0x71, 0xE6, 0x18, 0x80, 0x00, 0x8C, 0xAA, 0x2F, 0x20, 0x8B, 0xCF, 0x2E, 0xF8, 0x80, 0xB0, 0x82, 0x29, 0xA2, 0xF2, 0x2F, 0x1C, 0x22, 0x28, 0xAA, 0x21, 0x44, 0x10, 0x20, 0x40, 0x00, 0x00, 0x28, 0xA2, 0x8A, 0x2F, 0x22, 0x90, 0x81, 0x28, 0x22, 0xA9, 0x20, 0x8A, 0x24, 0xA0, 0x42, 0x48, 0xA2, 0x92, 0x41, 0x30, 0x00, 0x60, 0x04, 0x00, 0x80, 0x14, 0x11, 0x0A, 0x80, 0x40, 0x87, 0x08, 0x00, 0x00, 0x10, 0xC8, 0x84, 0x02, 0xF8, 0x28, 0x90, 0x88, 0x20, 0x00, 0x40, 0x01, 0x08, 0xBB, 0xE8, 0xA0, 0x8A, 0x08, 0x22, 0x88, 0x88, 0xA8, 0x82, 0x28, 0xA2, 0x82, 0xA9, 0x02, 0x22, 0x28, 0xAA, 0x50, 0x88, 0x10, 0x10, 0x40, 0x00, 0x01, 0xE8, 0xA0, 0x8B, 0xC4, 0x22, 0x90, 0x81, 0x30, 0x22, 0xA9, 0x22, 0x8A, 0x24, 0x1C, 0x42, 0x48, 0xAA, 0x62, 0x46, 0x10, 0x20, 0x40, 0x24, 0x00, 0x00, 0x3E, 0xE2, 0x69, 0x00, 0x40, 0x85, 0x08, 0x60, 0x06, 0x20, 0x88, 0x88, 0x22, 0x12, 0x28, 0x90, 0x88, 0x46, 0x18, 0x23, 0xE2, 0x00, 0x82, 0x28, 0xA2, 0x8A, 0x08, 0x22, 0x88, 0x88, 0xA4, 0x82, 0x28, 0xA2, 0x82, 0x48, 0xA2, 0x22, 0x25, 0x2A, 0x88, 0x88, 0x10, 0x08, 0x40, 0x00, 0x02, 0x28, 0xA2, 0x8A, 0x04, 0x1E, 0x90, 0x81, 0x28, 0x22, 0x29, 0x22, 0x8A, 0x24, 0x02, 0x52, 0xC5, 0x3E, 0x91, 0xC8, 0x10, 0x20, 0x40, 0x14, 0x00, 0x80, 0x14, 0x22, 0x66, 0x80, 0x21, 0x00, 0x00, 0x60, 0x06, 0x00, 0x71, 0xCF, 0x9C, 0x11, 0xC7, 0x10, 0x71, 0x86, 0x18, 0x10, 0x04, 0x08, 0x72, 0x2F, 0x1C, 0xF3, 0xE8, 0x1E, 0x89, 0xC7, 0x22, 0xFA, 0x28, 0x9C, 0x81, 0xA8, 0x9C, 0x21, 0xC2, 0x14, 0x88, 0x8F, 0x1C, 0x01, 0xC0, 0x3E, 0x01, 0xEF, 0x1C, 0x79, 0xC4, 0x02, 0x90, 0xC9, 0x24, 0x32, 0x29, 0x1E, 0xF1, 0xEE, 0x1C, 0x21, 0x42, 0x14, 0x90, 0x8F, 0x0C, 0x21, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x20, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x3A, 0x02, 0x0E, 0x00, 0x02, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x12, 0x00, 0x02, 0x00, 0x04, 0x00, 0x03, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x20, 0x00, 0x06, 0x00, 0x63, 0x00, 0x06, 0x00, 0x0E, 0x00, 0x02, 0x00, 0x05, 0x00, 0x02, 0x00, 0x20, 0x00, 0x08, 0x00, 0x63, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x80, 0x06, 0x00, 0x08, 0x00, 0x12, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x12, 0x00, 0x13, 0x00, 0x14, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00 };
#define FONTNAME "tempfont.ric"
unsigned int LoadFont( byte &arr[], string filename ){
byte handle;
unsigned int size = ArrayLen( arr );
unsigned int result = CreateFileLinear( FONTNAME, size, handle );
if( result == LDR_SUCCESS ){
result = Write( handle, arr );
CloseFile( handle );
}
ArrayInit( arr, 0, 0 );
return result;
}
unsigned int UnloadFont( string filename ){
return DeleteFile( filename );
}
task main(){
LoadFont( fontarr, FONTNAME );
FontTextOut( 0,LCD_LINE1, FONTNAME, "Testing-font", DRAW_OPT_FONT_DIR_T2BL | DRAW_OPT_FONT_WRAP );
Wait( SEC_5 );
UnloadFont( FONTNAME );
}