About XBF used question

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

  • About XBF used question

    HI i used xbf file from sd card, used open file and reference FONT_ShowXBF.c(From segger.com/emwin-samples.html )

    my code :

    /**XBF**/
    static int _cbGetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer) {
    unsigned long NumBytesRead;
    FILE *hFile;
    U32 fpos;

    hFile = (FILE *)pVoid;
    if ( fseek(pVoid, (long )Off, SEEK_CUR ))
    {
    return 1; /* Error */
    }

    if (ftell (pVoid) == 0xFFFFFFFF) {
    return 1; /* Error */
    }

    fread (&pBuffer, sizeof(NumBytes), NumBytesRead, hFile);

    return 0; /* Ok */
    }

    static void _ShowXBF(void * pVoid) {
    GUI_FONT Font;
    GUI_XBF_DATA XBF_Data;

    /* Create XBF font */
    GUI_XBF_CreateFont(&Font, /* 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 */
    _cbGetData, /* Pointer to callback function */
    pVoid); /* Pointer to be passed to GetData function */
    /* Show 'Hello world!' */
    GUI_DispStringHCenterAt("中文", 160, 80);
    /* Display hint */
    GUI_SetFont(&GUI_Font13_ASCII);
    GUI_DispStringHCenterAt("Press any key to continue...", 160, 120);

    /* Delete XBF font and clear display */
    GUI_XBF_DeleteFont(&Font);
    }
    main{

    FILE *fin;
    fin = fopen ("M:\\cht.bdf","r");
    if (fin != NULL)
    {
    _ShowXBF(&fin);
    fclose (fin);
    }else{
    printf ("\nFile not found!\n");
    fclose (fin);
    }
    }

    but it run in _cbGetData will be crash ,but if i del all code in _cbGetData

    ex:
    static int _cbGetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer) {
    unsigned long NumBytesRead;
    FILE *hFile;
    U32 fpos;


    return 0; /* Ok */
    }

    it will not crash

    i use cortex m3 EA-board lpc1788 EVB

    Can you help me ,please
    thank you