Supporting Chinese and Korean in STemwin

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

    • Supporting Chinese and Korean in STemwin

      Hi,
      I need to use Chinese and Korean languages in the GUI. Size of .c files generated using Font Cvt software is huge and the flash is not enough to accommodate.
      Is there any other way to handle such languages ?

      In the user manual, another technique is suggested i.e using .XBF files . How to use such file?
    • Hi,

      Fonts can get really big and might exceed the limits of embedded hardware.

      You have multiple options to save memory. First might be to use an xbf file placed on external memory and access it by a file system.

      For this purpose you have to use a GetData() function to access the file. Below is an example on how to access a xbf file on your HD using window FS API:

      C Source Code

      1. #include <windows.h>
      2. #include "DIALOG.h"
      3. static int _cbGetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer) {
      4. DWORD NumBytesRead;
      5. HANDLE hFile;
      6. hFile = *(HANDLE *)pVoid;
      7. /* Set file pointer to the requested position */
      8. if (SetFilePointer(hFile, Off, 0, FILE_BEGIN) == 0xFFFFFFFF) {
      9. return 1; /* Error */
      10. }
      11. /* Read font data */
      12. if (!ReadFile(hFile, pBuffer, NumBytes, &NumBytesRead, 0)) {
      13. return 1; /* Error */
      14. }
      15. if (NumBytesRead != NumBytes) {
      16. return 1; /* Error */
      17. }
      18. return 0; /* Ok */
      19. }
      20. void MainTask(void) {
      21. GUI_FONT Font;
      22. GUI_XBF_DATA XBF_Data;
      23. HANDLE hFile;
      24. GUI_Init();
      25. hFile = CreateFile("c:\\temp\\Arial32.xbf", GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
      26. GUI_XBF_CreateFont(&Font, /* Pointer to GUI_FONT structure in RAM */
      27. &XBF_Data, /* Pointer to GUI_XBF_DATA structure in RAM */
      28. GUI_XBF_TYPE_PROP, /* Font type to be created */
      29. _cbGetData, /* Pointer to callback function */
      30. &hFile); /* Pointer to be passed to GetData function */
      31. GUI_DispString("Das ist ein Test!");
      32. while (1) {
      33. GUI_Delay(100);
      34. }
      35. }
      Display All

      Another method is to use a pattern file which includes any string used in your application and can be used to redruce the content of font to only the required characters.

      THis is described in chapter 12.11 Pattern files of the emWin user manual.

      The advantage of the first method is that you have always all characters available and should be used if you have dynamic strings.
      The second one might be the method which saves more memory but can't b used for dynamic strings because it might happen that required characters are not included.

      Regards,
      Sven
    • Hi,

      xbf fonts require almost no additional RAM. Just a few bytes for the GUI_XBF_DATA and the GUI_FONT structures.



      HulkHogan wrote:

      when in use does it only create the characters you need or does it create the entire font?
      Yes, only those characters are getting loading which are required. When displaying a string emWin only loads those characters required to display this string.

      Of course, you could use a pattern file while creating the font with the Font Converter. This would reduce the number of available characters in the font file itself and helps to keep it small.

      Regards,
      Sven
    • HI,

      Unfortunately, there is no example available for fonts inside QSPI flash.

      Attached is an example which shows how to use XBF files from a file system and how to read XBF data from memory. The example is made to be used in the emWin Simulation (using Windows FS) but it should be quite easy to port it to any other file system.

      Depending on where you place the file 'ExtBinFont.xbf' you have to adapt the variable acPath in MainTask().

      Regards,
      Sven
      Files