Emwin TEXT_SetFont(hItem, acHRBCezanne_140_Normal_EXT_AA4) not working

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

    • Emwin TEXT_SetFont(hItem, acHRBCezanne_140_Normal_EXT_AA4) not working

      Hi guys,

      I created some custom font in App wizard like acHRBCezanne_140_Normal_EXT_AA4 and acHRBCezanne_190_Normal_EXT_AA4. Initially I set 190 fonts by default in App wizard text properties. But run time I try to change to 140 fonts using following comment in emwin code.

      TEXT_SetFont(hItem, acHRBCezanne_140_Normal_EXT_AA4)

      But i am getting error.

      If i miss something somebody pls help to fix this issue.

      Thanks advance.

    • Hi Ravi,

      There currently is no "SETFONT" job implemented that would set the font of an object. But you can set the font of the object in user code.

      The byte arrays generated by AppWizard are essentially just the content of XBF font files. The reason why what you were trying to do does not work is that TEXT_SetFont() expects a pointer to a GUI_FONT struct.

      The easiest way to change the font would be if you'd retrieve the GUI_FONT* from a TEXT widget that has the 190 font set with TEXT_GetFont(). Then you could set it to the other TEXT widget that should retrieve the font with TEXT_SetFont().

      If this is not an option, the XBF font needs to be parsed into a GUI_FONT struct during runtime and then it can be set to the widget.
      There is an example in our wiki. However, you can strip away everything file related from the example. The _GetData() function just needs to copy the XBF data to the buffer:

      C Source Code

      1. /*** Begin of user code area ***/
      2. #include <string.h>
      3. /*********************************************************************
      4. *
      5. * _GetData
      6. */
      7. static int _GetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer) {
      8. memcpy(pBuffer, (U8 *)pVoid + Off, NumBytes);
      9. return 0;
      10. }
      11. /*** End of user code area ***/
      12. /*********************************************************************
      13. *
      15. */
      16. void ID_SCREEN_00__ID_BUTTON_00__WM_NOTIFICATION_RELEASED(APPW_ACTION_ITEM * pAction, WM_HWIN hScreen, WM_MESSAGE * pMsg, int * pResult) {
      17. WM_HWIN hText;
      18. static GUI_FONT Font;
      19. static GUI_XBF_DATA Data;
      20. //
      21. // Create font.
      22. //
      23. GUI_XBF_CreateFont((GUI_FONT*)&Font, &Data, GUI_XBF_TYPE_PROP_AA4_EXT, _GetData, (void *)acNettoOT_40_Normal_EXT_AA4);
      24. //
      25. // Set font to desired text widget.
      26. //
      27. hText = WM_GetDialogItem(hScreen, ID_TEXT_00);
      28. TEXT_SetFont(hText, &Font);
      29. }
      Display All

      Best regards,
      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.