Create chinese font

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

    • Create chinese font

      Hi,

      I am trying to display chinese characters using emWin. I have been reading and it looks like I have to use font converter to create font files of the required language. I do not see any steps to create one such file. Can anyone here help me understand how to do that?

      I really appreciate all the help.

      Thanks and regards,
      BMD
    • Hi,

      At first you need a font which includes the required characters (e.g. Arial Unicode MS). You could also search the internet for other free fonts.

      When opening the Font Converter select a font type, leave the encoding as is and press ok. I suggest to choose one of the extended format, but be aware that those with a higher AA level require more memory.

      Now select the font, its style and an a size. Press ok.

      After that you should see a preview and you can edit the characters enable/disable specific characters or complete code point ranges. Arial Unicode MS is a pretty huge font and I recommend to remove all characters you don't need. If you already know which characters you need you can also use a pattern file which masks out all characters not found in the pattern file. Just take a look into the emWin manual in the chapter about the Font Converter. There you will find an explanation about pattern files.

      Now you can save the font either as c-file, sif-file or xbf-file. The c-file is easy to use, just add it to your project. The xbf file has the best performance when it comes to large font files, but needs some sort of a file system to access the font being placed in non directly addressable memory.

      When saving the font as c-file it can take a while to save the font. The complete Arial Unicode MS font results in a c-file with a size of about 37MB.

      As said just take a look into the manual of emWin for further information about the Font Converter.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Thank you, Sven. That was very helpful.

      Before I go deep in with the font converter I have a few things to clear up. I would really appreciate it if you can help me understand.

      1. Is there a way to disable inbuilt fonts in emWin? If yes, how? (I am trying to reduce program memory by not using the inbuilt font if possible)
      2. Can you tell me what language characters can I display with the inbuilt font in emWin?
      3. Is there a separate set of API's to be used to display languages other than English using inbuilt fonts in emWin or GUI_DispString() works?

      Answers to these questions will help me understand if there is a need for me to create a font file or not.

      Best regards,
      BMD
    • Hi,

      1.
      In general yes, you would need to remove any references to the standard fonts (e.g. with configuration macros for widgets and by setting another default font).
      Unfortunately, this won't work with a prebuild library. The fonts can be set/removed on compile time which is not possible with an already compiled library, obviuosly.

      2.
      The standard fonts cover the ISO 8859-1 Western Latin character set (0x0020-0x007E and 0x00A0-0x00FF). With this character set you can display most of the western languages.

      3.
      No, since the standard fonts do not cover other characters than mentioned above.

      I forgot one point in my last reply.

      To display characters beyond the ASCII range we recommend to use UTF-8 encoding in emWin. How to do this can be found in the manual 5.12 Language Support. There are also some examples regarding language support in our Wiki:
      wiki.segger.com/emWin_Examples#Language_Support



      These example do not only use UTF8 encoding but also bidirectional strings. Of course BiDi support can be turned of if not required.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Thank you very much, Sven.

      I would like to reduce program memory by not using the inbuilt font. So if I just try to use a font from external memory, does the inbuilt font still get compiled and occupy the program memory or not?

      Thanks and regards,
      BMD
    • Hi,

      All widgets which can have a text set have a default font. As long as you don't reference these widgets it shouldn't be linked to the application.

      Also emWin uses a default font GUI_Font6x8 which can not be changed when using a precompiled library.

      If you have access to the source code you can remove all default fonts.

      With the source code you would also have other options to reduce the footprint by removing unneeded features and set other preprocessor options. For users of emWin provided by a silicon vendor we offer a special discount when purchasing emWin PRO:
      segger.com/products/user-inter…win/emwin-source-upgrade/

      This source code upgrade grants access to the source code of the latest emWin version. You will also receive frequent updates and possible bug fixes and last but not least support directly from the developers with fast response times.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Thank you so much, Sven.

      I have a few questions.
      1. Is there a way to take out characters not being used in a font file and keep the only ones that are being used? What is the best way to do it?
      2. If I decide to use a particular font in a commercial project, how do I go about it? What are the steps need to be followed to make sure I got all the licensing and things like that?

      Best regards,
      BMD
    • Hi,

      1.
      You can use a pattern file.
      - Create a text file with Unicode encoding (in Notepad++ it is under 'Encoding' -> 'Encode in UCS-2 Little Endian')
      - Write the strings used in your application into this file
      - Open a font with the Font Converter.
      - Go to 'Edit' -> 'Disable all characters'
      - Go to 'Edit' -> 'Read pattern file...' and open the pattern file created before

      Now all unused characters of the font are grayed out.

      2.
      Good question. Unfortunately, I have no idea how to proceed here.
      I suggest to contact the creator of the font or you choose one which is explicitly labeled to be used in a commercial product.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Hi,

      for example google fonts are for free use (as far is I understand):
      fonts.google.com/

      Second question under FAQ:
      developers.google.com/fonts/faq2



      bio_med wrote:

      Could you please point me in the direction of finding the list of fonts explicitly to be used in a commercial product?
      Google does this better than me ;)

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • I am trying to use the fonts from SD card. Since you already mentioned that certain widgets have inbuilt fonts, how do I control displaying the fonts from SD card to that of inbuilt ones?

      Thanks and regards,
      BMD
    • Hi,

      Here is an example on how to use an external XBF font:
      wiki.segger.com/Set_external_XBF_font_(Sample)

      It is written to be used either with the Windows FS API in the emWin simulation or with our FS emFile. Of course, it shouldn't be much work to change the example for any other FS.

      If you are using an external font you have to make sure that the font being created with GUI_XBF_CreateFont() stays valid as long as it is used by an object.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Thank you, Sven. Really appreciate all the help.

      I was looking at the sample and wondering two things:
      1. Do I need to create separate font files for each language I use?
      2. How will emWin map the font with respective characters?

      Best regards,
      BMD
    • Hi,

      1.
      This depends on the languages and the fonts. Lets say the languages are German, English and Chinese and the font contains the code points for Latin languages you would be able to display English and German. Obviously you couldn't display Chinese and you would need to use another font for Chinese.

      If your font contains also the desired Chinese characters you could display all three languages.

      With the Font Converter it is also possible to merge two fonts. Just refer to chapter '8.4.10 Merging fonts with existing C font files' of the emWin user manual.

      2.
      Not sure what you mean by 'map'.

      When emWin is about to display a string it checks for each character if it is present in the font currently set. If the character is not found emWin simply shows nothing. By calling the function GUI_ShowMissingCharacters(1) emWin draws a rectangle if a character is not found.

      Regards,

      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Thank you for the explanation, Sven.

      I tried the sample code and was able to display this. Please see attached. I don't understand why I see characters displayed repeatedly. Could you please help me understand this behavior?

      Thanks and regards,
      BMD
      Images
      • XBFImage-min.jpg

        738.48 kB, 3,024×4,032, viewed 507 times
    • Hi,

      No, it's the same procedure. Create a font, e.g. by calling GUI_XBF_CreateFont((GUI_FONT*)&Font, &Data, GUI_XBF_TYPE_PROP_AA4_EXT, _GetData, pFile), and use the initialized GUI_FONT structure for your widget. Just make sure it stays valid as long as any object uses the font.

      Regards,
      Sven
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Sven,

      I followed the procedure you mentioned but I don't see anything on the screen.Please see below and advise if I got something wrong.


      Source Code

      1. void setExternalXBFFont(const char * textname)
      2. {
      3. FS_FILE * pFile;
      4. GUI_FONT Font;
      5. GUI_XBF_DATA Data;
      6. BUTTON_Handle hButton;
      7. FS_Init();
      8. pFile = FS_FOpen(FILE_PATH, "rb");
      9. // Create the font from the XBF file
      10. // The font and xbf data will be loaded into the two variables created above.
      11. // This data has to be valid during the time we use the font.
      12. GUI_XBF_CreateFont((GUI_FONT*)&Font, &Data, GUI_XBF_TYPE_PROP_EXT, _GetData, pFile);
      13. // Set the newly created font as the current font
      14. GUI_SetFont(&Font);
      15. GUI_UC_SetEncodeUTF8();
      16. // Display some text in the current font
      17. WM_GetDialogItem(hButton, GUI_ID_BUTTON0);
      18. BUTTON_SetFont(hButton, &Font);
      19. BUTTON_SetText(hButton, textname);
      20. FS_FClose(pFile);
      21. GUI_XBF_DeleteFont(&Font);
      22. }
      Display All
      Appreciate all your help.

      Best regards,
      BMD
    • Could someone help me understand if I am getting the steps right to display XBF font from SDcard in a widget. Or is there somewhere I can look at, as to how to implement XBF fonts on widgets?
      Appreciate any help.

      Thanks and regards,
      BMD