Hi, i'm new for emwin i got some problem with xbf font use
there is my code about xbf:
#include "GUI.h"
#include "ff.h"
#include "GUI_Private.h"
GUI_FONT XBFFont;
GUI_XBF_DATA XBF_Data;
static int _cbGetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer) {
FIL fsrc; //
FRESULT res; //
UINT br;
char string[30];
int flag=0;
fsrc = *(FIL *)pVoid;
/* Set file pointer to the requested position */
// res = f_lseek(&fsrc,Off); //
// if (res != FR_OK) {
// res = f_open(&fsrc, "0:/sys/Font18.xbf", FA_OPEN_EXISTING | FA_READ);
// if (res != FR_OK) {
// return 1; /* Error */
// }
res = f_lseek(&fsrc,Off);
if (res != FR_OK) {
return 1; /* Error */
}
// flag=1;
// }
res=f_read(&fsrc,pBuffer,NumBytes,&br);
return 1; /* Error */
}
return 1; /* Error */
}
// if(flag==1){
// res = f_close(&fsrc); //
// }
return 0; /* Ok */
}
void readFontfromXBFSD(void){
FIL fsrc;
FRESULT res;
GUI_FONTINFO fontinfo;
GUI_CHARINFO_EXT charinfo;
int i;
int string2;
res = f_open(&fsrc, "0:/sys/Font18std.xbf", FA_OPEN_EXISTING | FA_READ);
// res = f_open(&fsrc, "0:/sys/NEW12.xbf", FA_OPEN_EXISTING | FA_READ);
GUI_XBF_CreateFont(&XBFFont, /* Pointer to GUI_FONT structure in RAM */
&XBF_Data, /* Pointer to GUI_XBF_DATA structure in RAM */
GUI_XBF_TYPE_PROP, /* Font type to be created */
// GUI_XBF_TYPE_PROP_AA4_EXT,
_cbGetData, /* Pointer to callback function */
&fsrc); /* Pointer to be passed to GetData function */
// GUI_XBF__GetFontInfo(&XBFFont,&fontinfo);
// GUI_XBF__GetCharInfo(0x4E2D,&charinfo);
GUI_SetFont(&XBFFont);
GUI_UC_SetEncodeUTF8();
GUI_DispString(string);
//GUI_ClearRect(0, 40, 319, 239);
res = f_close(&fsrc);
}
I got confuse that when i display string "Hello world 中文 の" Hello world is fine but the "
there is my code about xbf:
#include "GUI.h"
#include "ff.h"
#include "GUI_Private.h"
GUI_FONT XBFFont;
GUI_XBF_DATA XBF_Data;
static int _cbGetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer) {
FIL fsrc; //
FRESULT res; //
UINT br;
char string[30];
int flag=0;
fsrc = *(FIL *)pVoid;
/* Set file pointer to the requested position */
// res = f_lseek(&fsrc,Off); //
// if (res != FR_OK) {
// res = f_open(&fsrc, "0:/sys/Font18.xbf", FA_OPEN_EXISTING | FA_READ);
// if (res != FR_OK) {
// return 1; /* Error */
// }
res = f_lseek(&fsrc,Off);
if (res != FR_OK) {
return 1; /* Error */
}
// flag=1;
// }
res=f_read(&fsrc,pBuffer,NumBytes,&br);
if (res != FR_OK) {
return 1; /* Error */
}
if (br != NumBytes) {
return 1; /* Error */
}
// if(flag==1){
// res = f_close(&fsrc); //
// }
return 0; /* Ok */
}
void readFontfromXBFSD(void){
FIL fsrc;
FRESULT res;
GUI_FONTINFO fontinfo;
GUI_CHARINFO_EXT charinfo;
int i;
char string[80]="Hello world 中文 の";
int string2;
res = f_open(&fsrc, "0:/sys/Font18std.xbf", FA_OPEN_EXISTING | FA_READ);
// res = f_open(&fsrc, "0:/sys/NEW12.xbf", FA_OPEN_EXISTING | FA_READ);
GUI_XBF_CreateFont(&XBFFont, /* Pointer to GUI_FONT structure in RAM */
&XBF_Data, /* Pointer to GUI_XBF_DATA structure in RAM */
GUI_XBF_TYPE_PROP, /* Font type to be created */
// GUI_XBF_TYPE_PROP_AA4_EXT,
_cbGetData, /* Pointer to callback function */
&fsrc); /* Pointer to be passed to GetData function */
// GUI_XBF__GetFontInfo(&XBFFont,&fontinfo);
// GUI_XBF__GetCharInfo(0x4E2D,&charinfo);
GUI_SetFont(&XBFFont);
GUI_UC_SetEncodeUTF8();
GUI_DispString(string);
//GUI_ClearRect(0, 40, 319, 239);
res = f_close(&fsrc);
}
I got confuse that when i display string "Hello world 中文 の" Hello world is fine but the "
中文 の" part turned into blue background and brown font color, how it happen? and when i try to use aa4 xbf font all the
characters' font color become blue with red spot on it, i cant see it clearly.
another question is how i can use it into WM item?
i try to call:
BUTTON_SetDefaultFont(&XBFFont);
TEXT_SetDefaultFont(&XBFFont);
but it makes all my gui disappear when my program is still running, i found it maybe file get font file data error so i try to use open file in _cbdata function (which i comment) then the system will goto hardfault error when its run GUI_GetCharDistX of WM item text display
when i try to open font file in _cbgetdata function
My file system is fatfs version R0.09b
Please someone help me? I'm really need it. thanks
The post was edited 2 times, last by jimmjimm ().