f. Loading External Fonts

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 02 - Drawing Strings >

f. Loading External Fonts

This section shows how to use the Loadfont() and StringExt() commands to load an external font and use it for drawing the string.



Command Prototype


uint16_t LoadFont(const char* FileName);





Path of the external font file





The following code snippet illustrates how to load and use the external fonts -


void setup()


   int screenWidth = _WIDTH, screenheight = _HEIGHT;


  /* Initialize CleO */



 /* Load font file and get the handle for it */

   font = CleO.LoadFont("@Fonts/DSEG7ClassicMini-BoldItalic.ftfont");


  /* Start building a screen frame */



  /* Draw string (digits) using external font */

   CleO.StringExt(font, screenWidth/2, 15, 0xff4040UL, TM, 0, 0, "1 2 3");

   CleO.StringExt(font, screenWidth/2, screenheight/2, 0xff4040UL, MM, 0, 0, "4 5 6");

   CleO.StringExt(font, screenWidth/2, 400, 0xff4040UL, MM, 0, 0, "7 8 9");


  /* Display completed screen frame */







In the above code snippet, the font file is loaded first and provides a font handle.


Later, the StringExt() command uses this handle to draw strings of numerical digits.


0xff4040UL is the color (bright red) value.


Use the @ symbol only when performing the file operation from the eFlash and not from the SD Card.





Here is the output displayed upon executing the above code snippet -