Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

This modules provides functionality for outputting a font to a display.

Modules

 System font
 The system font objects are globally available for a graphical application.
 

Data Structures

struct  font
 Font structure. More...
 

Enumerations

enum  font_data_type { FONT_LOC_PROGMEM }
 Valid storage locations for font data. More...
 
enum  gfx_text_alignment {
  TEXT_ALIGN_LEFT,
  TEXT_ALIGN_RIGHT,
  TEXT_ALIGN_CENTER
}
 Text alignment options for text lines within a paragraph. More...
 
enum  gfx_text_position {
  TEXT_POS_TOP = (1 << 0),
  TEXT_POS_CENTER_Y = (1 << 1),
  TEXT_POS_BOTTOM = (1 << 2),
  TEXT_POS_LEFT = (1 << 3),
  TEXT_POS_CENTER_X = (1 << 4),
  TEXT_POS_RIGHT = (1 << 5),
  TEXT_POS_TOP_LEFT = TEXT_POS_TOP | TEXT_POS_LEFT,
  TEXT_POS_TOP_CENTER = TEXT_POS_TOP | TEXT_POS_CENTER_X,
  TEXT_POS_TOP_RIGHT = TEXT_POS_TOP | TEXT_POS_RIGHT,
  TEXT_POS_CENTER_LEFT = TEXT_POS_CENTER_Y | TEXT_POS_LEFT,
  TEXT_POS_CENTER = TEXT_POS_CENTER_Y | TEXT_POS_CENTER_X,
  TEXT_POS_CENTER_RIGHT = TEXT_POS_CENTER_Y | TEXT_POS_RIGHT,
  TEXT_POS_BOTTOM_LEFT = TEXT_POS_BOTTOM | TEXT_POS_LEFT,
  TEXT_POS_BOTTOM_CENTER = TEXT_POS_BOTTOM | TEXT_POS_CENTER_X,
  TEXT_POS_BOTTOM_RIGHT = TEXT_POS_BOTTOM | TEXT_POS_RIGHT
}
 Text paraphraph positioning options. More...
 

Strings and characters located in RAM

void gfx_draw_char (const char c, const gfx_coord_t x, const gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color)
 Draws a character to the display. More...
 
void gfx_draw_string (const char *str, const gfx_coord_t x, const gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color)
 Draws a string to the display. More...
 
void gfx_draw_string_aligned (const char *str, gfx_coord_t x, gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color, enum gfx_text_position text_pos, enum gfx_text_alignment text_align)
 Draws an aligned string to the display. More...
 
void gfx_get_string_bounding_box (char const *str, const struct font *font, gfx_coord_t *width, gfx_coord_t *height)
 Computes the bounding box of a string. More...
 

Strings located in flash

void gfx_draw_progmem_string (char PROGMEM_PTR_T str, gfx_coord_t x, gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color)
 Draws a string located in program memory to the display. More...
 
void gfx_draw_progmem_string_aligned (char PROGMEM_PTR_T str, gfx_coord_t x, gfx_coord_t y, const struct font *font, const gfx_color_t bg_color, const gfx_color_t text_color, enum gfx_text_position text_pos, enum gfx_text_alignment text_align)
 Draws an aligned string located in program memory to the display. More...
 
void gfx_get_progmem_string_bounding_box (char PROGMEM_PTR_T str, const struct font *font, gfx_coord_t *width, gfx_coord_t *height)
 Computes the bounding box of a string located in program memory. More...
 

Valid storage locations for font data.

Todo:
Add support for fonts in regular ram
Enumerator
FONT_LOC_PROGMEM 

Font data stored in program/flash memory.

Text alignment options for text lines within a paragraph.

Enumerator
TEXT_ALIGN_LEFT 

Align each line to the left side of the paragraph bounding box.

Align each line to the right side of the paragraph bounding box

TEXT_ALIGN_RIGHT 

Align each line to the center of the paragraph bounding box.

TEXT_ALIGN_CENTER 

Text paraphraph positioning options.

Enumerator
TEXT_POS_TOP 

Position text paragraph vertically below given coordinate.

Position text paragraph vertically centered on given coordinate

TEXT_POS_CENTER_Y 

Position text paragraph vertically above given coordinate.

TEXT_POS_BOTTOM 

Position text paragraph horizontally right to the given coordinate.

TEXT_POS_LEFT 

Position text paragraph horizontally centered on given coordinate.

TEXT_POS_CENTER_X 

Position text paragraph horizontally left to the given coordinate.

TEXT_POS_RIGHT 
TEXT_POS_TOP_LEFT 
TEXT_POS_TOP_CENTER 
TEXT_POS_TOP_RIGHT 
TEXT_POS_CENTER_LEFT 
TEXT_POS_CENTER 
TEXT_POS_CENTER_RIGHT 
TEXT_POS_BOTTOM_LEFT 
TEXT_POS_BOTTOM_CENTER 
TEXT_POS_BOTTOM_RIGHT 

void gfx_draw_char ( const char  c,
const gfx_coord_t  x,
const gfx_coord_t  y,
const struct font font,
const gfx_color_t  bg_color,
const gfx_color_t  text_color 
)

Draws a character to the display.

Parameters
cCharacter to be drawn
xX coordinate on screen.
yY coordinate on screen.
fontFont to draw character in
bg_colorBackground color to draw behind the text string
text_colorForeground color to draw the text string in

References Assert, FONT_LOC_PROGMEM, GFX_COLOR_TRANSPARENT, gfx_draw_char_hugemem(), gfx_draw_char_progmem(), gfx_draw_filled_rect, font::height, font::type, and font::width.

Referenced by gfx_draw_progmem_string_aligned(), and gfx_draw_string_aligned().

void gfx_draw_progmem_string ( char PROGMEM_PTR_T  str,
gfx_coord_t  x,
gfx_coord_t  y,
const struct font font,
const gfx_color_t  bg_color,
const gfx_color_t  text_color 
)

Draws a string located in program memory to the display.

This function will draw a string located in program memory to the display, this differs from gfx_draw_string() by using constant string data from the program memory instead of string data in RAM.

Using program memory for constant strings will reduce the applications need for RAM, and thus lower the overall size footprint.

Parameters
strPointer to string located in program memory
xX coordinate on screen.
yY coordinate on screen.
fontFont to draw string in
bg_colorBackground color to draw behind the text string
text_colorForeground color to draw the text string in

References gfx_draw_progmem_string_aligned(), TEXT_ALIGN_LEFT, and TEXT_POS_LEFT.

void gfx_draw_progmem_string_aligned ( char PROGMEM_PTR_T  str,
gfx_coord_t  x,
gfx_coord_t  y,
const struct font font,
const gfx_color_t  bg_color,
const gfx_color_t  text_color,
enum gfx_text_position  text_pos,
enum gfx_text_alignment  text_align 
)

Draws an aligned string located in program memory to the display.

This function will draw a string located in program memory to the display with the specified alignment. This differs from gfx_draw_aligned_string() by using constant string data from the program memory instead of string data in RAM.

Parameters
strPointer to string located in program memory
xX coordinate on screen.
yY coordinate on screen.
fontFont to draw string in
bg_colorBackground color to draw behind the text string
text_colorForeground color to draw the text string in
text_posPosition of the coordinate relative to the text paragraph
text_alignAlignment of text lines within the paragraph bounding box

References Assert, gfx_draw_char(), gfx_get_progmem_string_bounding_box(), font::height, NULL, PROGMEM_PTR_T, PROGMEM_READ_BYTE, TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT, TEXT_POS_BOTTOM, TEXT_POS_CENTER_X, TEXT_POS_CENTER_Y, TEXT_POS_RIGHT, and font::width.

Referenced by gfx_draw_progmem_string().

void gfx_draw_string ( const char *  str,
gfx_coord_t  x,
gfx_coord_t  y,
const struct font font,
const gfx_color_t  bg_color,
const gfx_color_t  text_color 
)

Draws a string to the display.

This function will draw a string located in memory to the display.

Parameters
strPointer to string
xX coordinate on screen.
yY coordinate on screen.
fontFont to draw string in
bg_colorBackground color to draw behind the text string
text_colorForeground color to draw the text string in

References gfx_draw_string_aligned(), TEXT_ALIGN_LEFT, and TEXT_POS_LEFT.

Referenced by app_widget_launch_audio(), draw_finger_square(), task_win(), wtk_check_box_handler(), wtk_frame_handler(), wtk_label_handler(), and wtk_radio_button_handler().

void gfx_draw_string_aligned ( const char *  str,
gfx_coord_t  x,
gfx_coord_t  y,
const struct font font,
const gfx_color_t  bg_color,
const gfx_color_t  text_color,
enum gfx_text_position  text_pos,
enum gfx_text_alignment  text_align 
)

Draws an aligned string to the display.

This function will draw a string located in memory to the display with the specified alignment.

Parameters
strPointer to string
xX coordinate on screen.
yY coordinate on screen.
fontFont to draw string in
bg_colorBackground color to draw behind the text string
text_colorForeground color to draw the text string in
text_posPosition of the coordinate relative to the text paragraph
text_alignAlignment of text lines within the paragraph bounding box

References Assert, gfx_draw_char(), gfx_get_string_bounding_box(), font::height, NULL, TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT, TEXT_POS_BOTTOM, TEXT_POS_CENTER_X, TEXT_POS_CENTER_Y, TEXT_POS_RIGHT, and font::width.

Referenced by app_widget_fft_on(), draw_pallet_labels(), gfx_draw_string(), main(), rtouch_calibrate(), show_out_of_memory_error(), and wtk_button_handler().

void gfx_get_progmem_string_bounding_box ( char PROGMEM_PTR_T  str,
const struct font font,
gfx_coord_t width,
gfx_coord_t height 
)

Computes the bounding box of a string located in program memory.

Note
If string is empty the returned width will be 1 pixel and the height equal to the font height.
Parameters
strString in program memory to calculate bounding box for
fontFont used
widthPointer to width result
heightPointer to height result

References Assert, font::height, NULL, PROGMEM_PTR_T, PROGMEM_READ_BYTE, and font::width.

Referenced by gfx_draw_progmem_string_aligned().

void gfx_get_string_bounding_box ( const char *  str,
const struct font font,
gfx_coord_t width,
gfx_coord_t height 
)

Computes the bounding box of a string.

Note
If string is empty the returned width will be 1 pixel and the height equal to the font height.
Parameters
strString to calculate bounding box for
fontFont used
widthPointer to width result
heightPointer to height result

References Assert, font::height, NULL, and font::width.

Referenced by draw_finger_square(), gfx_draw_string_aligned(), wtk_button_size_hint(), wtk_check_box_size_hint(), wtk_label_handler(), wtk_label_size_hint(), and wtk_radio_button_size_hint().