BeRTOS
Functions
text_format.c File Reference

printf-family routines for text output More...

#include "text.h"
#include <mware/formatwr.h>
#include <gfx/font.h>
#include <gfx/gfx.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>

Go to the source code of this file.

Functions

int text_puts (const char *PGM_ATTR str, struct Bitmap *bm)
 Render string str in Bitmap bm at current cursor position.
int text_vprintf (struct Bitmap *bm, const char *PGM_ATTR fmt, va_list ap)
 vprintf()-like formatter to render text in a Bitmap.
int text_printf (struct Bitmap *bm, const char *PGM_ATTR fmt,...)
 printf()-like formatter to render text in a Bitmap.
int text_xyvprintf (struct Bitmap *bm, coord_t x, coord_t y, uint16_t style, const char *PGM_ATTR fmt, va_list ap)
 Render text with vprintf()-like formatting at a specified pixel position.
int text_xyprintf (struct Bitmap *bm, coord_t x, coord_t y, uint16_t style, const char *PGM_ATTR fmt,...)
 Render text with printf()-like formatting at a specified pixel position.
int text_xprintf (struct Bitmap *bm, uint8_t row, uint8_t col, uint16_t style, const char *PGM_ATTR fmt,...)
 Render text with printf()-like formatting at a specified row/column position.
static int text_charWidth (int c, struct TextWidthData *twd)
 Compute width in pixels of a character.
int text_vwidthf (UNUSED_ARG(struct Bitmap *, bm), const char *PGM_ATTR fmt, va_list ap)
 Return the width in pixels of a vprintf()-formatted string.
int text_widthf (struct Bitmap *bm, const char *PGM_ATTR fmt,...)
 Return the width in pixels of a printf()-formatted string.

Detailed Description

printf-family routines for text output

Author:
Bernie Innocenti <bernie@codewiz.org>
Stefano Fedrigo <aleph@develer.com>

Definition in file text_format.c.


Function Documentation

static int text_charWidth ( int  c,
struct TextWidthData *  twd 
) [static]

Compute width in pixels of a character.

Compute the on screen width of a character, taking the current style and font into account.

The width is accumulated in the WidthData structure passed as second argument.

This is a formatted_write() callback used by text_vwidthf() to compute the length of a formatted string.

Definition at line 222 of file text_format.c.

int text_printf ( struct Bitmap bm,
const char *PGM_ATTR  fmt,
  ... 
)

printf()-like formatter to render text in a Bitmap.

Perform printf()-like formatting on the fmt format string. Render the resulting string in Bitmap bm starting at the current cursor position.

See also:
text_puts() text_putchar() text_vprintf()

Definition at line 99 of file text_format.c.

int text_puts ( const char *PGM_ATTR  str,
struct Bitmap bm 
)

Render string str in Bitmap bm at current cursor position.

Note:
Text formatting functions are also available with an _P suffix accepting the source string from program memory. This feature is only available (and useful) on Harvard microprocessors such as the AVR.
See also:
text_putchar()

Definition at line 64 of file text_format.c.

int text_vprintf ( struct Bitmap bm,
const char *PGM_ATTR  fmt,
va_list  ap 
)

vprintf()-like formatter to render text in a Bitmap.

Perform vprintf()-like formatting on the fmt format string using the variable-argument list ap. Render the resulting string in Bitmap bm starting at the current cursor position.

See also:
text_puts() text_putchar() text_printf()

Definition at line 85 of file text_format.c.

int text_xprintf ( struct Bitmap bm,
uint8_t  row,
uint8_t  col,
uint16_t  style,
const char *PGM_ATTR  fmt,
  ... 
)

Render text with printf()-like formatting at a specified row/column position.

See also:
text_xyprintf()

Definition at line 188 of file text_format.c.

int text_xyprintf ( struct Bitmap bm,
coord_t  x,
coord_t  y,
uint16_t  style,
const char *PGM_ATTR  fmt,
  ... 
)

Render text with printf()-like formatting at a specified pixel position.

Parameters:
bmBitmap where to render the text
x[pixels] Initial X coordinate of text.
y[pixels] Coordinate of top border of text.
styleFormatting style to use. In addition to any STYLEF_ flag, it can be TEXT_NORMAL, TEXT_FILL, TEXT_INVERT or TEXT_RIGHT, or a combination of these flags ORed together.
fmtString possibly containing printf() formatting commands.
See also:
text_puts() text_putchar() text_printf() text_vprintf()
text_moveTo() text_style()

Definition at line 169 of file text_format.c.

int text_xyvprintf ( struct Bitmap bm,
coord_t  x,
coord_t  y,
uint16_t  style,
const char *PGM_ATTR  fmt,
va_list  ap 
)

Render text with vprintf()-like formatting at a specified pixel position.

See also:
text_xyprintf()

Definition at line 116 of file text_format.c.