xbf font use

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • xbf font use

    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);
    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 ().

  • Its almost done but still two problems there: I can use font on my button or text staff but when i just touch the screen(anywhere even not on button), the system hard fault(when its runing GUI_CURSOR_SetpostionEx function that i can see it from assemble code) but when i use emwin default font all good, whats going wrong? and another problem is should keep font file open all the time? if my ui need open another file it may cause some problem i think

    The post was edited 2 times, last by jimmjimm ().

  • Hello,

    Unfortunately I am not able to reproduce the problem. I would recommend to verify your file system works ok. emWin works very simple regarding GetData()-functions. Either the data is fetched ok, or it is not. If it is not, emWin just cancels the drawing process and returns. It should never come to a hard fault when displaying bitmaps.

    Best regards,
    Adrian
  • SEGGER - Adrian wrote:

    Hello,

    Unfortunately I am not able to reproduce the problem. I would recommend to verify your file system works ok. emWin works very simple regarding GetData()-functions. Either the data is fetched ok, or it is not. If it is not, emWin just cancels the drawing process and returns. It should never come to a hard fault when displaying bitmaps.

    Best regards,
    Adrian
    Hi Adrian i'm pretty sure my file system works fine. and when i try to close font file which means getdata function will return 1 for error its still hard fault after running (GUI_getchardistx)