Microchip® Advanced Software Framework

gfx_mono_text.c File Reference

Font and text drawing routines.

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

#include "stddef.h"
#include "assert.h"
#include "gfx_mono.h"
#include "gfx_mono_text.h"
#include <asf.h>

Macros

#define CONFIG_FONT_PIXELS_PER_BYTE   8
 
#define EXTMEM_BUF_SIZE   20
 

Functions

void gfx_mono_draw_char (const char c, const gfx_coord_t x, const gfx_coord_t y, const struct font *font)
 Draws a character to the display. More...
 
static void gfx_mono_draw_char_hugemem (const char ch, const gfx_coord_t x, const gfx_coord_t y, const struct font *font)
 Helper function that draws a character from a font in hugemem to the display. More...
 
static void gfx_mono_draw_char_progmem (const char ch, const gfx_coord_t x, const gfx_coord_t y, const struct font *font)
 Helper function that draws a character from a font in progmem to the display. More...
 
void gfx_mono_draw_progmem_string (char PROGMEM_PTR_T str, gfx_coord_t x, gfx_coord_t y, const struct font *font)
 Draws a string located in program memory to the display. More...
 
void gfx_mono_draw_string (const char *str, gfx_coord_t x, gfx_coord_t y, const struct font *font)
 Draws a string to the display. More...
 
void gfx_mono_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_mono_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

static void gfx_mono_draw_char_hugemem ( const char  ch,
const gfx_coord_t  x,
const gfx_coord_t  y,
const struct font font 
)
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_mono_draw_string() and gfx_mono_draw_progmem_string() functions.

Parameters
[in]chCharacter to be drawn
[in]xX coordinate on screen.
[in]yY coordinate on screen.
[in]fontFont to draw character in

References Assert, CONFIG_FONT_PIXELS_PER_BYTE, font::data, EXTMEM_BUF_SIZE, font::first_char, gfx_mono_draw_pixel, GFX_PIXEL_SET, font::height, and font::width.

Referenced by gfx_mono_draw_char().

static void gfx_mono_draw_char_progmem ( const char  ch,
const gfx_coord_t  x,
const gfx_coord_t  y,
const struct font font 
)
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_mono_draw_string() and gfx_mono_draw_progmem_string() functions.

Parameters
[in]chCharacter to be drawn
[in]xX coordinate on screen.
[in]yY coordinate on screen.
[in]fontFont to draw character in

References Assert, CONFIG_FONT_PIXELS_PER_BYTE, font::data, font::first_char, gfx_mono_draw_pixel, GFX_PIXEL_SET, font::height, font::progmem, PROGMEM_PTR_T, PROGMEM_READ_BYTE, and font::width.

Referenced by gfx_mono_draw_char().