Hi,
Here is a small example code to check the width and the address of the characters. The structure has some defines added compared to the programmers guide as the structure is shown for illustration but would not compile directly as it has more than one array in it. We have updated the Programmers Guide for this and are also releasing a short application note soon with this code and some background explanation (as well as a similar application note on doing the same with standard ASCII).
You can cycle through each character getting its width and add them up. You can then calculate the start and end points for your highlight within this data.
Best Regards, BRT Community
#define XF_GPTR(xf) ( (unsigned int*)&(((int*)xf)[10]) )
#define XF_WPTR(xf) ( (unsigned int*) &(((char*)xf)[40 + 4 * (xf->number_of_characters / 128)]))
#define XF_WIDTH(xf) ( (unsigned char*)&(((char*)xf)[0]))
typedef struct
{
uint32_t signature;// Must be 0x0100AAFF
uint32_t size;// Total size of the font block, in bytes
uint32_t format;// Bitmap format, as defined in BITMAP_EXT_FORMAT, except TextVGA,Tex
uint32_t swizzle;// Bitmap swizzle value
uint32_t layout_width;//Font bitmap line stride, in bytes
uint32_t layout_height;//Font bitmap height, in pixels
uint32_t pixel_width;//Font screen width, in pixels
uint32_t pixel_height;//Font screen height, in pixels
uint32_t start_of_graphic_data;//Pointer to font graphic data in memory, including flash.
uint32_t number_of_characters;//Total number of characters in font: N(multiple of 128)
//uint32_t gptr[];//Offsets to glyph data
//uint32_t wptr[];//Offsets to width data
//uint8_t width_data[];//Width data, one byte per character
} XFONT_EXTENDED;
uint8_t cp_width(const XFONT_EXTENDED * xf, uint32_t cp)
{
uint32_t offset = XF_WPTR(xf)[cp / 128] + (cp % 128);
return XF_WIDTH(xf)[offset];
}
uint32_t cp_address(const XFONT_EXTENDED * xf, uint32_t cp)
{
uint32_t bytes_per_glyph;
bytes_per_glyph = xf->layout_width * xf->layout_height;
if (xf->start_of_graphic_data >= 0x800000)
//if the graphic data is in flash
return (xf->start_of_graphic_data +
(XF_GPTR(xf)[cp / 128] +
bytes_per_glyph * (cp % 128)) / 32);
else
//if the graphic data is in RAM_G
return (xf->start_of_graphic_data +
XF_GPTR(xf)[cp / 128] +
bytes_per_glyph * (cp % 128));
}
// Load the glyph data to RAM_G + 4096
EVE_LIB_WriteDataToRAMG(glyph_data, sizeof(glyph_data), 4096);
// Load the xfont data to RAM_G + 0
EVE_LIB_WriteDataToRAMG(xfont_data, sizeof(xfont_data), 0);
// Apply the xf structure to the xfont data array
const XFONT_EXTENDED *xf = (const XFONT_EXTENDED *)xfont_data;
cp_width_G = cp_width(xf, 0x0047); // letter G = 0x0047
cp_address_G = cp_address(xf, 0x0047); // Letter G = 0x0047