b. Using Built-In Fonts

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 02 - Drawing Strings >

b. Using Built-In Fonts

This section shows how to draw text using built-in fonts. The StringExt() command is used to draw the strings. Pass the Font handle as the first argument to this command.

 

 

Command Prototype

 

uint16_t StringExt(int16_t Handle,int X,int Y uint32_t Color, just_t Justification, int16_t Angle, double Radius, const char* String)

 

Parameters

Description

Handle

Font Size

X

x-coordinate for string

Y

y-coordinate for string

Color

String color

Justification

Justification values (i.e MM,TL,BL, etc.)

Angle

Angle at which string will be drawn

Radius

Distance from center at which string will be drawn

String

String text

 

The sample values for built-in fonts are given below -

FONT_VGA_8

FONT_VGA_16

FONT_BIT_0

FONT_BIT_1

FONT_BIT_2

FONT_BIT_3

FONT_BIT_4

FONT_BIT_5

FONT_SANS_0

FONT_SANS_1

FONT_SANS_2

FONT_SANS_3

FONT_SANS_4

FONT_SANS_5

FONT_SANS_6

FONT_SANS_7

FONT_SANS_8

FONT_TINY

FONT_MEDIUM

FONT_HUGE

 

 

Code

 

 

void setup()

{

   int screenWidth =  800, screenheight = 480;

 

  /* Initialize CleO */

   CleO.begin();

 

   /* Start building a screen frame */

   CleO.Start();

 

   /* Draw string (digits) using built-in font */

   CleO.StringExt(FONT_TINY, screenWidth / 2, 60, 0xff4040UL, MM, 0, 0, "Tiny");

   CleO.StringExt(FONT_SANS_2, screenWidth / 2, 150, 0xff4040UL, MM, 0, 0, "Small");

   CleO.StringExt(FONT_MEDIUM, screenWidth / 2, screenheight / 2, 0xff4040UL, MM, 0, 0, "Medium");

   CleO.StringExt(FONT_SANS_6, screenWidth / 2, 320, 0xff4040UL, MM, 0, 0, "Large");

   CleO.StringExt(FONT_HUGE, screenWidth / 2, 425, 0xff4040UL, MM, 0, 0, "Huge");

 

 /* Display completed screen frame */

   CleO.Show();

}

 

 

Description

 

The above code snippet uses FONT_TINY, FONT_SANS_2, FONT_MEDIUM, FONT_SANS_6 and FONT_HUGE built-in fonts to draw text of various size on the screen.

 

 

Output

 

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

 

Tutorials02-builtInFonts.50