Microchip® Advanced Software Framework

gfx_text.c File Reference

Font and text drawing routines.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "stddef.h"
#include "assert.h"
#include "gfx.h"
#include "gfx_text.h"

Macros

#define CONFIG_FONT_PIXELS_PER_BYTE   8
 
#define EXTMEM_BUF_SIZE   20
 

Functions

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...
 
static void gfx_draw_char_hugemem (const char ch, const gfx_coord_t x, const gfx_coord_t y, const struct font *font, const gfx_color_t color)
 Helper function that draws a character from a font in hugemem to the display. More...
 
static void gfx_draw_char_progmem (const char ch, const gfx_coord_t x, const gfx_coord_t y, const struct font *font, const gfx_color_t color)
 Helper function that draws a character from a font in progmem to the display. More...
 
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_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. 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_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...
 
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. More...
 

#define CONFIG_FONT_PIXELS_PER_BYTE   8
#define EXTMEM_BUF_SIZE   20

Referenced by gfx_draw_char_hugemem().

static void gfx_draw_char_hugemem ( const char  ch,
const gfx_coord_t  x,
const gfx_coord_t  y,
const struct font font,
const gfx_color_t  color 
)
static

Helper function that draws a character from a font in hugemem to the display.

This function will first calculate the start offset in the font character data before iterating over the specific character data.

Only pixels in the character that should be enabled are done so, the caller is required to prepare the drawing area before printing a character to it. This is done by the gfx_draw_string() and gfx_draw_progmem_string() functions.

Parameters
chCharacter to be drawn
xX coordinate on screen.
yY coordinate on screen.
fontFont to draw character in
colorForeground color to draw the character in

References Assert, CONFIG_FONT_PIXELS_PER_BYTE, font::data, EXTMEM_BUF_SIZE, font::first_char, gfx_draw_pixel(), font::height, NULL, and font::width.

Referenced by gfx_draw_char().

static void gfx_draw_char_progmem ( const char  ch,
const gfx_coord_t  x,
const gfx_coord_t  y,
const struct font font,
const gfx_color_t  color 
)
static

Helper function that draws a character from a font in progmem to the display.

This function will first calculate the start offset in the font character data before iterating over the specific character data.

Only pixels in the character that should be enabled are done so, the caller is required to prepare the drawing area before printing a character to it. This is done by the gfx_draw_string() and gfx_draw_progmem_string() functions.

Parameters
chCharacter to be drawn
xX coordinate on screen.
yY coordinate on screen.
fontFont to draw character in
colorForeground color to draw the character in

References Assert, CONFIG_FONT_PIXELS_PER_BYTE, font::data, font::first_char, gfx_draw_pixel(), font::height, NULL, font::progmem, PROGMEM_PTR_T, PROGMEM_READ_BYTE, and font::width.

Referenced by gfx_draw_char().