How to display "Δ" Symbol using emwin

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

    • Hi,

      1. You need a font which contains the desired character (the default fonts do not contain this character so you have to create one with the Font Converter).

      2. Convert the string into a UTF8 string. For the "Δ" character it is "\xce\x94". To generate it on your own create a UTF8 decoded txt file and paste the desired string into it. Then convert the txt file with U2C.exe into a c file. It will contain the UTF8 encoded "c"-string.

      3. In your application enable UTF8 encoding by a call of GUI_UC_SetEncodeUTF8(), set the font with the character and display the UTF8 string.

      Here is a short example how this can be achieved:

      C Source Code

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * Defines
      5. *
      6. **********************************************************************
      7. */
      8. /*********************************************************************
      9. *
      10. * Static data
      11. *
      12. **********************************************************************
      13. */
      14. /* Start of unicode area <Basic Greek> */
      15. GUI_CONST_STORAGE unsigned char acGUI_FontDelta_0394[666] = { /* code 0394, GREEK CAPITAL LETTER DELTA */
      16. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      17. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xFF, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      18. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      19. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      20. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFC, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      21. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xF3, 0xFF, 0xFF, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      22. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9F, 0xFF, 0xD0, 0xBF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      23. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x80, 0x6F, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      24. 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0x20, 0x1F, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      25. 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFB, 0x00, 0x0A, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      26. 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xF4, 0x00, 0x04, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
      27. 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xE0, 0x00, 0x00, 0xDF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00,
      28. 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x90, 0x00, 0x00, 0x8F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00,
      29. 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x3F, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00,
      30. 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00,
      31. 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00,
      32. 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xF3, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00,
      33. 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00,
      34. 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xF5, 0x00, 0x00, 0x00, 0x00,
      35. 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00,
      36. 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xFF, 0x20, 0x00, 0x00, 0x00,
      37. 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0x70, 0x00, 0x00, 0x00,
      38. 0x00, 0x00, 0x00, 0xCF, 0xFF, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00,
      39. 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xFF, 0xF4, 0x00, 0x00, 0x00,
      40. 0x00, 0x00, 0x09, 0xFF, 0xFF, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xFF, 0xFA, 0x00, 0x00, 0x00,
      41. 0x00, 0x00, 0x1E, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFF, 0xFF, 0x10, 0x00, 0x00,
      42. 0x00, 0x00, 0x6F, 0xFF, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xFF, 0x60, 0x00, 0x00,
      43. 0x00, 0x00, 0xCF, 0xFF, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFF, 0xFF, 0xC0, 0x00, 0x00,
      44. 0x00, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0xF3, 0x00, 0x00,
      45. 0x00, 0x09, 0xFF, 0xFF, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F, 0xFF, 0xF9, 0x00, 0x00,
      46. 0x00, 0x0E, 0xFF, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x00, 0x00,
      47. 0x00, 0x5F, 0xFF, 0xFD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xFF, 0xFF, 0x50, 0x00,
      48. 0x00, 0xBF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xB0, 0x00,
      49. 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF2, 0x00,
      50. 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00,
      51. 0x0E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00,
      52. 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40
      53. };
      54. GUI_CONST_STORAGE GUI_CHARINFO_EXT GUI_FontDelta_CharInfo[1] = {
      55. { 35, 37, -1, 11, 35, acGUI_FontDelta_0394 } /* code 0394, GREEK CAPITAL LETTER DELTA */
      56. };
      57. GUI_CONST_STORAGE GUI_FONT_PROP_EXT GUI_FontDelta_Prop1 = {
      58. 0x0394 /* first character */
      59. ,0x0394 /* last character */
      60. ,&GUI_FontDelta_CharInfo[ 0] /* address of first character */
      61. ,(GUI_CONST_STORAGE GUI_FONT_PROP_EXT *)0 /* pointer to next GUI_FONT_PROP_EXT */
      62. };
      63. GUI_CONST_STORAGE GUI_FONT GUI_FontDelta = {
      64. GUI_FONTTYPE_PROP_AA4_EXT /* type of font */
      65. ,60 /* height of font */
      66. ,60 /* space of font y */
      67. ,1 /* magnification x */
      68. ,1 /* magnification y */
      69. ,{&GUI_FontDelta_Prop1}
      70. ,48 /* Baseline */
      71. ,28 /* Height of lowercase characters */
      72. ,37 /* Height of capital characters */
      73. };
      74. /*********************************************************************
      75. *
      76. * Static code
      77. *
      78. **********************************************************************
      79. */
      80. /*********************************************************************
      81. *
      82. * Public code
      83. *
      84. **********************************************************************
      85. */
      86. /*********************************************************************
      87. *
      88. * MainTask
      89. */
      90. void MainTask(void) {
      91. GUI_Init();
      92. GUI_UC_SetEncodeUTF8();
      93. GUI_SetFont(&GUI_FontDelta);
      94. GUI_DispString("\xce\x94");
      95. while (1) {
      96. GUI_Delay(100);
      97. }
      98. }
      99. /*************************** End of file ****************************/
      Display All


      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 ,

      Thanks for the valuable reply, i tried the above example and it works fine, I want to reduce the font size of the Delta, Please let me know how can i reduce the font size in the above example.


      Regards
      Annappa
    • Hi,

      For modifying a font the FontConverter is required. With the FontConverter you can create a font in (almost) any size.

      It is not possible to reduce the size of the font on runtime.

      You also might refer to the TrueType fonts:
      segger.com/downloads/emwin/emWin_FreeType

      You could create an emWin-font from a TTF font on runtime which allows you to choose a different size.

      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,

      I have created the code to Delta symbol for the font size 32 , i am running below code but i am not able to display the Delta symbol, Can you please help me , what is the problem with below code.


      #include "DIALOG.h"

      /*********************************************************************
      *
      * Defines
      *
      **********************************************************************
      */
      /*********************************************************************
      *
      * Static data
      *
      **********************************************************************
      */
      /* Start of unicode area <Basic Greek> */
      GUI_CONST_STORAGE unsigned char acGUI_FontDeltaa_0394[200] = { /* code 0394, GREEK CAPITAL LETTER DELTA */
      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
      0xF0, 0x00, 0x00, 0x06, 0xFF, 0xF7, 0x00, 0x00, 0x00, 0xF0,
      0xF0, 0x00, 0x00, 0x0C, 0xF9, 0xFD, 0x00, 0x00, 0x00, 0xF0,
      0xF0, 0x00, 0x00, 0x3F, 0xE1, 0xEF, 0x30, 0x00, 0x00, 0xF0,
      0xF0, 0x00, 0x00, 0x8F, 0x90, 0x8F, 0x90, 0x00, 0x00, 0xF0,
      0xF0, 0x00, 0x00, 0xEF, 0x30, 0x2F, 0xE0, 0x00, 0x00, 0xF0,
      0xF0, 0x00, 0x05, 0xFB, 0x00, 0x0B, 0xF5, 0x00, 0x00, 0xF0,
      0xF0, 0x00, 0x0B, 0xF5, 0x00, 0x05, 0xFB, 0x00, 0x00, 0xF0,
      0xF0, 0x00, 0x2F, 0xE0, 0x00, 0x00, 0xEF, 0x20, 0x00, 0xF0,
      0xF0, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x8F, 0x70, 0x00, 0xF0,
      0xF0, 0x00, 0xDF, 0x30, 0x00, 0x00, 0x3F, 0xD0, 0x00, 0xF0,
      0xF0, 0x04, 0xFC, 0x00, 0x00, 0x00, 0x0C, 0xF4, 0x00, 0xF0,
      0xF0, 0x09, 0xF6, 0x00, 0x00, 0x00, 0x06, 0xFA, 0x00, 0xF0,
      0xF0, 0x1F, 0xE1, 0x00, 0x00, 0x00, 0x01, 0xEF, 0x10, 0xF0,
      0xF0, 0x6F, 0x90, 0x00, 0x00, 0x00, 0x00, 0x9F, 0x60, 0xF0,
      0xF0, 0xCF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xC0, 0xF0,
      0xF2, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xF3, 0xF0,
      0xF8, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xF8, 0xF0,
      0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF0,
      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
      };

      GUI_CONST_STORAGE GUI_CHARINFO_EXT GUI_FontDeltaa_CharInfo[1] = {
      { 19, 20, -1, 6, 18, acGUI_FontDeltaa_0394 } /* code 0394, GREEK CAPITAL LETTER DELTA */
      };


      GUI_CONST_STORAGE GUI_FONT_PROP_EXT GUI_FontDeltaa_Prop135 = {
      0xFFFF /* first character */
      ,0xFFFF /* last character */
      ,&GUI_FontDeltaa_CharInfo[0] /* address of first character */
      ,(GUI_CONST_STORAGE GUI_FONT_PROP_EXT *)0 /* pointer to next GUI_FONT_PROP_EXT */
      };



      GUI_CONST_STORAGE GUI_FONT GUI_FontDeltaa = {
      GUI_FONTTYPE_PROP_AA4_EXT /* type of font */
      ,32 /* height of font */
      ,32 /* space of font y */
      ,1 /* magnification x */
      ,1 /* magnification y */
      ,{&GUI_FontDeltaa_Prop135}
      ,26 /* Baseline */
      ,15 /* Height of lowercase characters */
      ,20 /* Height of capital characters */
      };
      /*********************************************************************
      *
      * Static code
      *
      **********************************************************************
      */
      /*********************************************************************
      *
      * Public code
      *
      **********************************************************************
      */
      /*********************************************************************
      *
      * MainTask
      */
      void MainTask(void) {
      GUI_Init();
      GUI_SetColor(GUI_WHITE);
      GUI_UC_SetEncodeUTF8();
      GUI_SetFont(&GUI_FontDeltaa);
      GUI_DispString("\xce\x94");
      while (1) {
      GUI_Delay(100);
      }
      }

      /*************************** End of file ****************************/
    • Hi,

      Try to change the following in GUI_FontDeltaa_CharInfo:

      C Source Code

      1. 0x0394 /* first character */
      2. ,0x0394
      3. //0xFFFF /* first character */
      4. //,0xFFFF /* last character */
      If first and last character are 0xFFFF emWin will never find the character placed on 0x0394.

      Don't wonder why there is a frame around the Delta. This is becasue you are using the demo version of the FontConverter.

      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.