GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
A text drawing functions. More...
#include <stdarg.h>
#include <core/gp_types.h>
#include <core/gp_compiler.h>
#include <text/gp_text_style.h>
#include <text/gp_text_metric.h>
#include <text/gp_fonts.h>
Go to the source code of this file.
Typedefs | |
typedef enum gp_text_flags | gp_text_flags |
Text flags, mostly alignment. | |
Enumerations | |
enum | gp_text_flags { GP_ALIGN_LEFT = 0x01 , GP_ALIGN_CENTER = 0x02 , GP_ALIGN_RIGHT = 0x03 , GP_ALIGN_HORIZ = 0x03 , GP_TEXT_BEARING = 0x04 , GP_VALIGN_ABOVE = 0x10 , GP_VALIGN_TOP = GP_VALIGN_ABOVE , GP_VALIGN_CENTER = 0x20 , GP_VALIGN_BASELINE = 0x30 , GP_VALIGN_BELOW = 0x40 , GP_VALIGN_BOTTOM = GP_VALIGN_BELOW , GP_VALIGN_VERT = 0x70 , GP_TEXT_NOBG = 0x80 } |
Text flags, mostly alignment. More... | |
Functions | |
gp_size | gp_text_raw (gp_pixmap *pixmap, const gp_text_style *style, gp_coord x, gp_coord y, gp_text_flags flags, gp_pixel fg_color, gp_pixel bg_color, const char *str, size_t max_chars) |
Draws a string. | |
gp_size | gp_text (gp_pixmap *pixmap, const gp_text_style *style, gp_coord x, gp_coord y, gp_text_flags flags, gp_pixel fg_color, gp_pixel bg_color, const char *str) |
Draws a string. | |
gp_size | gp_glyph_draw (gp_pixmap *pixmap, const gp_text_style *style, gp_coord x, gp_coord y, int flags, gp_pixel fg_color, gp_pixel bg_color, uint32_t glyph) |
Renders a single glyph. | |
static gp_size | gp_text_xxy (gp_pixmap *pixmap, const gp_text_style *style, gp_coord x1, gp_coord x2, gp_coord y, gp_text_flags flags, gp_pixel fg_color, gp_pixel bg_color, const char *str) |
Draws a string. | |
gp_size | gp_print (gp_pixmap *pixmap, const gp_text_style *style, gp_coord x, gp_coord y, gp_text_flags flags, gp_pixel fg_color, gp_pixel bg_color, const char *fmt,...) |
Draws a string. | |
gp_size | gp_vprint (gp_pixmap *pixmap, const gp_text_style *style, gp_coord x, gp_coord y, gp_text_flags flags, gp_pixel fg_color, gp_pixel bg_color, const char *fmt, va_list va) |
Draws a string. | |
static gp_size | gp_print_xxy (gp_pixmap *pixmap, const gp_text_style *style, gp_coord x1, gp_coord x2, gp_coord y, gp_text_flags flags, gp_pixel fg_color, gp_pixel bg_color, const char *fmt,...) |
Draws a string. | |
void | gp_text_clear (gp_pixmap *pixmap, const gp_text_style *style, gp_coord x, gp_coord y, gp_text_flags flags, gp_pixel bg_color, gp_size size) |
Clears a rectangle that would be used to draw text of size pixels. | |
A text drawing functions.
Definition in file gp_text.h.
typedef enum gp_text_flags gp_text_flags |
Text flags, mostly alignment.
The alignment is relative to a specified point.
enum gp_text_flags |
Text flags, mostly alignment.
The alignment is relative to a specified point.
gp_size gp_glyph_draw | ( | gp_pixmap * | pixmap, |
const gp_text_style * | style, | ||
gp_coord | x, | ||
gp_coord | y, | ||
int | flags, | ||
gp_pixel | fg_color, | ||
gp_pixel | bg_color, | ||
uint32_t | glyph | ||
) |
Renders a single glyph.
The x, y coordinates are the upper left corner of the glyph box. If you want to render on baseline, you have to add the ascend. The if GP_TEXT_BEARING is passed in the flags, bearing is applied before the glyph is rendered. Usually first letter in a line is rendered without bearing and the rest of them is rendered with bearing.
pixmap | A pixmap to draw the glyph into. |
style | A text font and style. |
x | An x coordinate inside the pixmap. |
y | An y coordinate inside the pixmap. |
flags | Either 0 or any combination of GP_TEXT_BEARING and GP_TEXT_NOBG and GP_VALIGN_* |
fg_color | Text color. |
bg_color | Background color. The background color is ignored for 1bpp font formats. |
glyph | And unicode glypth to draw. |
gp_size gp_print | ( | gp_pixmap * | pixmap, |
const gp_text_style * | style, | ||
gp_coord | x, | ||
gp_coord | y, | ||
gp_text_flags | flags, | ||
gp_pixel | fg_color, | ||
gp_pixel | bg_color, | ||
const char * | fmt, | ||
... | |||
) |
Draws a string.
This is the same as gp_text() only with a printf() like format and parameters.
pixmap | A pixmap to draw the glyph into. |
style | A text font and style. |
x | An x coordinate inside the pixmap. |
y | An y coordinate inside the pixmap. |
flags | Either 0 or any combination of GP_TEXT_BEARING and GP_TEXT_NOBG and GP_VALIGN_* |
fg_color | Text color. |
bg_color | Background color. The background color is ignored for 1bpp font formats. |
fmt | A printf like format. |
... | A printf like parameters. |
|
inlinestatic |
Draws a string.
This is the same as gp_text_xxy() only with a printf() like format and parameters.
pixmap | A pixmap to draw the glyph into. |
style | A text font and style. |
x1 | An x1 coordinate inside the pixmap. |
x2 | An x2 coordinate inside the pixmap. |
y | An y coordinate inside the pixmap. |
flags | Either 0 or any combination of GP_TEXT_BEARING and GP_TEXT_NOBG and GP_VALIGN_*. |
fg_color | Text color. |
bg_color | Background color. The background color is ignored for 1bpp font formats. |
fmt | A printf like format. |
... | A printf like parameters. |
Definition at line 277 of file gp_text.h.
References GP_ALIGN_CENTER, GP_ALIGN_HORIZ, GP_ALIGN_LEFT, GP_ALIGN_RIGHT, and gp_vprint().
gp_size gp_text | ( | gp_pixmap * | pixmap, |
const gp_text_style * | style, | ||
gp_coord | x, | ||
gp_coord | y, | ||
gp_text_flags | flags, | ||
gp_pixel | fg_color, | ||
gp_pixel | bg_color, | ||
const char * | str | ||
) |
Draws a string.
The string is rendered to pixmap (horizontally) with defined text style. The x and y coordinates determines point defined by aligment flags.
pixmap | A pixmap to draw the glyph into. |
style | A text font and style. |
x | An x coordinate inside the pixmap. |
y | An y coordinate inside the pixmap. |
flags | Either 0 or any combination of GP_TEXT_BEARING and GP_TEXT_NOBG and GP_VALIGN_* |
fg_color | Text color. |
bg_color | Background color. The background color is ignored for 1bpp font formats. |
str | An UTF-8 string. |
Referenced by gp_text_xxy().
void gp_text_clear | ( | gp_pixmap * | pixmap, |
const gp_text_style * | style, | ||
gp_coord | x, | ||
gp_coord | y, | ||
gp_text_flags | flags, | ||
gp_pixel | bg_color, | ||
gp_size | size | ||
) |
Clears a rectangle that would be used to draw text of size pixels.
pixmap | A pixmap to draw the glyph into. |
style | A text font and style. |
x | An x coordinate inside the pixmap. |
y | An y coordinate inside the pixmap. |
gp_size gp_text_raw | ( | gp_pixmap * | pixmap, |
const gp_text_style * | style, | ||
gp_coord | x, | ||
gp_coord | y, | ||
gp_text_flags | flags, | ||
gp_pixel | fg_color, | ||
gp_pixel | bg_color, | ||
const char * | str, | ||
size_t | max_chars | ||
) |
Draws a string.
pixmap | A pixmap to draw the glyph into. |
style | A text font and style. |
x | An x coordinate inside the pixmap. |
y | An y coordinate inside the pixmap. |
flags | Either 0 or any combination of GP_TEXT_BEARING and GP_TEXT_NOBG and GP_VALIGN_*. |
fg_color | Text color. |
bg_color | Background color. The background color is ignored for 1bpp font formats. |
str | An UTF-8 string. |
max_chars | A maximum number of characters to draw, can be used to limit the number of characters to draw from str. |
|
inlinestatic |
Draws a string.
Aligns a string between x1 and x2 based ond horizontal aligment flags. The caller must make sure that the string will fit horizontally between x1 and x2.
pixmap | A pixmap to draw the glyph into. |
style | A text font and style. |
x1 | An x1 coordinate inside the pixmap. |
x2 | An x2 coordinate inside the pixmap. |
y | An y coordinate inside the pixmap. |
flags | Either 0 or any combination of GP_TEXT_BEARING and GP_TEXT_NOBG and GP_VALIGN_*. |
fg_color | Text color. |
bg_color | Background color. The background color is ignored for 1bpp font formats. |
str | An UTF-8 string. |
Definition at line 162 of file gp_text.h.
References GP_ALIGN_CENTER, GP_ALIGN_HORIZ, GP_ALIGN_LEFT, GP_ALIGN_RIGHT, and gp_text().
gp_size gp_vprint | ( | gp_pixmap * | pixmap, |
const gp_text_style * | style, | ||
gp_coord | x, | ||
gp_coord | y, | ||
gp_text_flags | flags, | ||
gp_pixel | fg_color, | ||
gp_pixel | bg_color, | ||
const char * | fmt, | ||
va_list | va | ||
) |
Draws a string.
This is va_arg variant of gp_print().
pixmap | A pixmap to draw the glyph into. |
style | A text font and style. |
x | An x coordinate inside the pixmap. |
y | An y coordinate inside the pixmap. |
flags | Either 0 or any combination of GP_TEXT_BEARING and GP_TEXT_NOBG and GP_VALIGN_* |
fg_color | Text color. |
bg_color | Background color. The background color is ignored for 1bpp font formats. |
fmt | A printf like format. |
va | A printf like parameters. |
Referenced by gp_print_xxy().