---
name: "libg15render"
section: "3"
platform: "linux"
package: "libg15render-dev"
version: "1.3.0~svn316-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/libg15render"
---

# libg15render(3)

Render text and graphics to a buffer usable by libg15(3) or g15daemon(1).

## NAME

libg15render - Render text and graphics to a buffer usable by **libg15**(3) or [**g15daemon**(1)](/g15daemon/1.md).

## SYNOPSIS

`#include <libg15render.h>`\

### Data Structures

struct **g15canvas**\
 *This structure holds the data need to render objects to the LCD screen.*  struct **g15font**\
 *Structure holding a single font.*  struct **g15glyph**\
 *Structure holding glyph data for g15render font types.*

### Defines

\#define **BYTE\_SIZE**   8\
 \#define **G15\_BUFFER\_LEN**   1048\
 \#define **G15\_CHAR\_HEADER\_SIZE**   4\
 \#define **G15\_COLOR\_BLACK**   1\
 \#define **G15\_COLOR\_WHITE**   0\
 \#define **G15\_FONT\_HEADER\_SIZE**   15\
 \#define **G15\_LCD\_HEIGHT**   43\
 \#define **G15\_LCD\_OFFSET**   32\
 \#define **G15\_LCD\_WIDTH**   160\
 \#define **G15\_MAX\_FACE**   5\
 \#define **G15\_MAX\_GLYPH**   256\
 \#define **G15\_PIXEL\_FILL**   1\
 \#define **G15\_PIXEL\_NOFILL**   0\
 \#define **G15\_TEXT\_HUGE**   3\
 \#define **G15\_TEXT\_LARGE**   2\
 \#define **G15\_TEXT\_MED**   1\
 \#define **G15\_TEXT\_SMALL**   0\
 \#define **G15R\_FONT\_SUPPORT**   1\

### Functions

void **g15r\_clearScreen** (**g15canvas** \*canvas, int color)\
 *Fills the screen with pixels of color.*  void **g15r\_deleteG15Font** (**g15font** \*font)\
 *De-allocate memory associated with font.*  void **g15r\_drawBar** (**g15canvas** \*canvas, int x1, int y1, int x2, int y2, int color, int num, int max, int type)\
 *Draws a completion bar.*  void **g15r\_drawBigNum** (**g15canvas** \*canvas, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int color, int num)\
 *Draw a large number.*  void **g15r\_drawCircle** (**g15canvas** \*canvas, int x, int y, int r, int fill, int color)\
 *Draws a circle centered at (x, y) with a radius of r.*  void **g15r\_drawIcon** (**g15canvas** \*canvas, char \*buf, int my\_x, int my\_y, int width, int height)\
 *Draw an icon to the screen from a wbmp buffer.*  void **g15r\_drawLine** (**g15canvas** \*canvas, int px1, int py1, int px2, int py2, const int color)\
 *Draws a line from (px1, py1) to (px2, py2).*  void **g15r\_drawRoundBox** (**g15canvas** \*canvas, int x1, int y1, int x2, int y2, int fill, int color)\
 *Draws a box with rounded corners bounded by (x1, y1) and (x2, y2).*  void **g15r\_drawSprite** (**g15canvas** \*canvas, char \*buf, int my\_x, int my\_y, int width, int height, int start\_x, int start\_y, int total\_width)\
 *Draw a sprite to the screen from a wbmp buffer.*  void **g15r\_drawXBM** (**g15canvas** \*canvas, unsigned char \*data, int width, int height, int pos\_x, int pos\_y)\
 *Draw an XBM image.*  void **g15r\_G15FontRenderString** (**g15canvas** \*canvas, **g15font** \*font, char \*string, int row, unsigned int sx, unsigned int sy, int colour, int paint\_bg)\
 *Render a string in font 'font' to canvas.*  void **g15r\_G15FPrint** (**g15canvas** \*canvas, char \*string, int x, int y, int size, int center, int colour, int row)\
 *Print a string using the G15 default font at size 'size'.*  int **g15r\_getPixel** (**g15canvas** \*canvas, unsigned int x, unsigned int y)\
 *Gets the value of the pixel at (x, y).*  void **g15r\_initCanvas** (**g15canvas** \*canvas)\
 *Clears the canvas and resets the mode switches.*  **g15font** \* **g15r\_loadG15Font** (char \*filename)\
 *Load G15 font and return it in* **g15font** *struct.*  int **g15r\_loadWbmpSplash** (**g15canvas** \*canvas, char \*filename)\
 *Draw a splash screen from 160x43 wbmp file.*  char \* **g15r\_loadWbmpToBuf** (char \*filename, int \*img\_width, int \*img\_height)\
 *Load a wbmp file into a buffer.*  void **g15r\_pixelBox** (**g15canvas** \*canvas, int x1, int y1, int x2, int y2, int color, int thick, int fill)\
 *Draws a box bounded by (x1, y1) and (x2, y2).*  void **g15r\_pixelOverlay** (**g15canvas** \*canvas, int x1, int y1, int width, int height, short colormap\[\])\
 *Overlays a bitmap of size width x height starting at (x1, y1).*  void **g15r\_pixelReverseFill** (**g15canvas** \*canvas, int x1, int y1, int x2, int y2, int fill, int color)\
 *Fills an area bounded by (x1, y1) and (x2, y2).*  void **g15r\_renderCharacterLarge** (**g15canvas** \*canvas, int x, int y, unsigned char character, unsigned int sx, unsigned int sy)\
 *Renders a character in the large font at (x, y).*  void **g15r\_renderCharacterMedium** (**g15canvas** \*canvas, int x, int y, unsigned char character, unsigned int sx, unsigned int sy)\
 *Renders a character in the meduim font at (x, y).*  void **g15r\_renderCharacterSmall** (**g15canvas** \*canvas, int x, int y, unsigned char character, unsigned int sx, unsigned int sy)\
 *Renders a character in the small font at (x, y).*  int **g15r\_renderG15Glyph** (**g15canvas** \*canvas, **g15font** \*font, unsigned char character, int top\_left\_pixel\_x, int top\_left\_pixel\_y, int colour, int paint\_bg)\
 *render glyph 'character' from loaded font struct 'font'. Returns width (in pixels) of rendered glyph*  void **g15r\_renderString** (**g15canvas** \*canvas, unsigned char stringOut\[\], int row, int size, unsigned int sx, unsigned int sy)\
 *Renders a string with font size in row.*  int **g15r\_saveG15Font** (char \*oFilename, **g15font** \*font)\
 *Save font in font struct to given file, return 0 on success.*  void **g15r\_setPixel** (**g15canvas** \*canvas, unsigned int x, unsigned int y, int val)\
 *Sets the value of the pixel at (x, y).*  int **g15r\_testG15FontWidth** (**g15font** \*font, char \*string)\
 *Returns length (in pixels) of string if rendered in font 'font'.*  void **g15r\_ttfLoad** (**g15canvas** \*canvas, char \*fontname, int fontsize, int face\_num)\
 *Loads a font through the FreeType2 library.*  void **g15r\_ttfPrint** (**g15canvas** \*canvas, int x, int y, int fontsize, int face\_num, int color, int center, char \*print\_string)\
 *Prints a string in a given font.*

### Variables

unsigned char **fontdata\_6x4** \[\]\
 *Font data for the small (6x4) font.*  unsigned char **fontdata\_7x5** \[\]\
 *Font data for the medium (7x5) font.*  unsigned char **fontdata\_8x8** \[\]\
 *Font data for the large (8x8) font.*

## Define Documentation

### #define BYTE\_SIZE 8

Definition at line 23 of file libg15render.h.

Referenced by g15r\_drawIcon(), g15r\_drawSprite(), g15r\_getPixel(), g15r\_loadWbmpToBuf(), and g15r\_setPixel().

### #define G15\_BUFFER\_LEN 1048

Definition at line 24 of file libg15render.h.

Referenced by g15r\_clearScreen(), g15r\_initCanvas(), and g15r\_loadWbmpSplash().

### #define G15\_CHAR\_HEADER\_SIZE 4

Definition at line 38 of file libg15render.h.

Referenced by g15r\_loadG15Font(), and g15r\_saveG15Font().

### #define G15\_COLOR\_BLACK 1

Definition at line 29 of file libg15render.h.

Referenced by g15r\_drawRoundBox(), g15r\_drawXBM(), g15r\_pixelOverlay(), g15r\_renderCharacterLarge(), g15r\_renderCharacterMedium(), g15r\_renderCharacterSmall(), and g15r\_renderString().

### #define G15\_COLOR\_WHITE 0

Definition at line 28 of file libg15render.h.

Referenced by g15r\_drawRoundBox(), and g15r\_pixelOverlay().

### #define G15\_FONT\_HEADER\_SIZE 15

Definition at line 37 of file libg15render.h.

Referenced by g15r\_loadG15Font(), and g15r\_saveG15Font().

### #define G15\_LCD\_HEIGHT 43

Definition at line 26 of file libg15render.h.

Referenced by g15r\_getPixel(), and g15r\_setPixel().

### #define G15\_LCD\_OFFSET 32

Definition at line 25 of file libg15render.h.

### #define G15\_LCD\_WIDTH 160

Definition at line 27 of file libg15render.h.

Referenced by g15r\_getPixel(), and g15r\_setPixel().

### #define G15\_MAX\_FACE 5

Definition at line 36 of file libg15render.h.

Referenced by g15r\_ttfLoad().

### #define G15\_MAX\_GLYPH 256

Definition at line 39 of file libg15render.h.

Referenced by g15r\_saveG15Font().

### #define G15\_PIXEL\_FILL 1

Definition at line 35 of file libg15render.h.

### #define G15\_PIXEL\_NOFILL 0

Definition at line 34 of file libg15render.h.

### #define G15\_TEXT\_HUGE 3

Definition at line 33 of file libg15render.h.

### #define G15\_TEXT\_LARGE 2

Definition at line 32 of file libg15render.h.

Referenced by g15r\_renderCharacterLarge().

### #define G15\_TEXT\_MED 1

Definition at line 31 of file libg15render.h.

Referenced by g15r\_renderCharacterMedium().

### #define G15\_TEXT\_SMALL 0

Definition at line 30 of file libg15render.h.

Referenced by g15r\_renderCharacterSmall().

### #define G15R\_FONT\_SUPPORT 1

Definition at line 21 of file libg15render.h.

## Function Documentation

### void g15r\_clearScreen (g15canvas \* canvas, int color)

Fills the screen with pixels of color.

Clears the screen and fills it with pixels of color

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *color* Screen will be filled with this color.

Definition at line 80 of file screen.c.

References g15canvas::buffer, and G15\_BUFFER\_LEN.

### void g15r\_deleteG15Font (g15font \* font)

De-allocate memory associated with font.

De-allocate memory associated with **g15font** struct, including glyph buffers

**Parameters:**

*font* **g15font** structure containing glyphs.

Definition at line 424 of file text.c.

References g15font::glyph\_buffer.

### void g15r\_drawBar (g15canvas \* canvas, int x1, int y1, int x2, int y2, int color, int num, int max, int type)

Draws a completion bar.

Given a maximum value, and a value between 0 and that maximum value, calculate and draw a bar showing that percentage.

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *x1* Defines leftmost bound of the bar. \
 *y1* Defines uppermost bound of the bar. \
 *x2* Defines rightmost bound of the bar. \
 *y2* Defines bottommost bound of the bar. \
 *color* The bar will be drawn this color. \
 *num* Number of units relative to max filled. \
 *max* Number of units equal to 100% filled. \
 *type* Type of bar. 1=solid bar, 2=solid bar with border, 3 = solid bar with I-frame.

Definition at line 340 of file pixel.c.

References g15r\_drawLine(), and g15r\_pixelBox().

### void g15r\_drawBigNum (g15canvas \* canvas, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int color, int num)

Draw a large number.

Draw a large number to a canvas

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *x1* Defines leftmost bound of the number. \
 *y1* Defines uppermost bound of the number. \
 *x2* Defines rightmost bound of the number. \
 *y2* Defines bottommost bound of the number. \
 *color* The number will be drawn this color. \
 *num* The number to be drawn.

Definition at line 548 of file pixel.c.

References g15r\_pixelBox().

### void g15r\_drawCircle (g15canvas \* canvas, int x, int y, int r, int fill, int color)

Draws a circle centered at (x, y) with a radius of r.

Draws a circle centered at (x, y) with a radius of r.

The circle will be filled if fill != 0.

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *x* Defines horizontal center of the circle. \
 *y* Defines vertical center of circle. \
 *r* Defines radius of circle. \
 *fill* The circle will be filled with color if fill != 0. \
 *color* Lines defining the circle will be drawn this color.

Definition at line 206 of file pixel.c.

References g15r\_drawLine(), and g15r\_setPixel().

### void g15r\_drawIcon (g15canvas \* canvas, char \* buf, int my\_x, int my\_y, int width, int height)

Draw an icon to the screen from a wbmp buffer.

Draw an icon to a canvas

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated in is found. \
 *buf* A pointer to the buffer holding the icon to be displayed. \
 *my\_x* Leftmost boundary of image. \
 *my\_y* Topmost boundary of image. \
 *width* Width of the image in buf. \
 *height* Height of the image in buf.

Definition at line 413 of file pixel.c.

References BYTE\_SIZE, and g15r\_setPixel().

### void g15r\_drawLine (g15canvas \* canvas, int px1, int py1, int px2, int py2, const int color)

Draws a line from (px1, py1) to (px2, py2).

A line of color is drawn from (px1, py1) to (px2, py2).

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *px1* X component of point 1. \
 *py1* Y component of point 1. \
 *px2* X component of point 2. \
 *py2* Y component of point 2. \
 *color* Line will be drawn this color.

Definition at line 102 of file pixel.c.

References g15r\_setPixel(), and swap().

Referenced by g15r\_drawBar(), g15r\_drawCircle(), g15r\_drawRoundBox(), and g15r\_pixelBox().

### void g15r\_drawRoundBox (g15canvas \* canvas, int x1, int y1, int x2, int y2, int fill, int color)

Draws a box with rounded corners bounded by (x1, y1) and (x2, y2).

Draws a rounded box around the area bounded by (x1, y1) and (x2, y2).

The box will be filled if fill != 0.

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *x1* Defines leftmost bound of the box. \
 *y1* Defines uppermost bound of the box. \
 *x2* Defines rightmost bound of the box. \
 *y2* Defines bottommost bound of the box. \
 *fill* The box will be filled with color if fill != 0. \
 *color* Lines defining the box will be drawn this color.

Definition at line 255 of file pixel.c.

References G15\_COLOR\_BLACK, G15\_COLOR\_WHITE, g15r\_drawLine(), and g15r\_setPixel().

### void g15r\_drawSprite (g15canvas \* canvas, char \* buf, int my\_x, int my\_y, int width, int height, int start\_x, int start\_y, int total\_width)

Draw a sprite to the screen from a wbmp buffer.

Draw a sprite to a canvas

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated in is found. \
 *buf* A pointer to the buffer holding a set of sprites. \
 *my\_x* Leftmost boundary of image. \
 *my\_y* Topmost boundary of image. \
 *width* Width of the sprite. \
 *height* Height of the sprite. \
 *start\_x* X offset for reading sprite from buf. \
 *start\_y* Y offset for reading sprite from buf. \
 *total\_width* Width of the set of sprites held in buf.

Definition at line 445 of file pixel.c.

References BYTE\_SIZE, and g15r\_setPixel().

### void g15r\_drawXBM (g15canvas \* canvas, unsigned char \* data, int width, int height, int pos\_x, int pos\_y)

Draw an XBM image.

Draw an XBM Image to the canvas

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated in is found. \
 *data* A pointer to the buffer holding the icon to be displayed. \
 *width* Width of the image in data. \
 *height* Height of the image in data. \
 *pos\_x* Leftmost boundary of image. \
 *pos\_y* Topmost boundary of image.

Definition at line 625 of file pixel.c.

References G15\_COLOR\_BLACK, and g15r\_setPixel().

### void g15r\_G15FontRenderString (g15canvas \* canvas, g15font \* font, char \* string, int row, unsigned int sx, unsigned int sy, int colour, int paint\_bg)

Render a string in font 'font' to canvas.

Render a string in given font.

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *font* Loaded **g15font** structure as returned by **g15r\_loadG15Font()** \
 *string* Pointer to string to operate on. \
 *row* vertical font-dependent row to start printing on. can usually be left at 0 \
 *sx* horizontal top-left pixel location. \
 *sy* vertical top-left pixel location. \
 *colour* desired colour of character when rendered. \
 *paint\_bg* if !0, pixels in the glyph background will also be painted, obstructing any image behind the text.

Definition at line 512 of file text.c.

References g15font::ascender\_height, and g15r\_renderG15Glyph().

Referenced by g15r\_G15FPrint().

### void g15r\_G15FPrint (g15canvas \* canvas, char \* string, int x, int y, int size, int center, int colour, int row)

Print a string using the G15 default font at size 'size'.

Render a string in the default font.

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *string* Pointer to string to operate on. \
 *x* horizontal top-left pixel location. \
 *y* vertical top-left pixel location. \
 *size* if size\>= 4, denotes height in pixels. if size\<4, standard font sizes are used. \
 *center* Desired text justification. 0==left, 1==centered, 2==right justified. \
 *colour* desired colour of character when rendered. \
 *row* vertical font-dependent row to start printing on. can usually be left at 0

Definition at line 535 of file text.c.

References g15r\_G15FontRenderString(), g15r\_loadG15Font(), and g15r\_testG15FontWidth().

Referenced by g15r\_renderCharacterLarge(), g15r\_renderCharacterMedium(), g15r\_renderCharacterSmall(), g15r\_renderString(), and g15r\_ttfPrint().

### int g15r\_getPixel (g15canvas \* canvas, unsigned int x, unsigned int y)

Gets the value of the pixel at (x, y).

Retrieves the value of the pixel at (x, y)

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *x* X offset for pixel to be retrieved. \
 *y* Y offset for pixel to be retrieved.

Definition at line 29 of file screen.c.

References g15canvas::buffer, BYTE\_SIZE, G15\_LCD\_HEIGHT, and G15\_LCD\_WIDTH.

Referenced by g15r\_pixelReverseFill(), and g15r\_setPixel().

### void g15r\_initCanvas (g15canvas \* canvas)

Clears the canvas and resets the mode switches.

Clears the screen and resets the mode values for a canvas

**Parameters:**

*canvas* A pointer to a **g15canvas** struct

Definition at line 91 of file screen.c.

References g15canvas::buffer, g15canvas::ftLib, G15\_BUFFER\_LEN, g15canvas::mode\_cache, g15canvas::mode\_reverse, and g15canvas::mode\_xor.

### g15font\* g15r\_loadG15Font (char \* filename)

Load G15 font and return it in **g15font** struct.

Load a g15 font from file.

**Parameters:**

*filename* string containing full name and location of font to load.

**Returns:**

pointer to completed **g15font** structure.

Definition at line 286 of file text.c.

References g15font::ascender\_height, g15glyph::buffer, g15font::default\_gap, g15font::font\_height, G15\_CHAR\_HEADER\_SIZE, G15\_FONT\_HEADER\_SIZE, g15glyph::gap, g15font::glyph, g15font::lineheight, g15font::numchars, and g15glyph::width.

Referenced by g15r\_G15FPrint().

### int g15r\_loadWbmpSplash (g15canvas \* canvas, char \* filename)

Draw a splash screen from 160x43 wbmp file.

wbmp splash screen loader - assumes image is 160x43

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *filename* A string holding the path to the wbmp to be displayed.

Definition at line 389 of file pixel.c.

References g15canvas::buffer, G15\_BUFFER\_LEN, and g15r\_loadWbmpToBuf().

### char\* g15r\_loadWbmpToBuf (char \* filename, int \* img\_width, int \* img\_height)

Load a wbmp file into a buffer.

basic wbmp loader - loads a wbmp image into a buffer.

**Parameters:**

*filename* A string holding the path to the wbmp to be loaded. \
 *img\_width* A pointer to an int that will hold the image width on return. \
 *img\_height* A pointer to an int that will hold the image height on return.

Definition at line 471 of file pixel.c.

References BYTE\_SIZE.

Referenced by g15r\_loadWbmpSplash().

### void g15r\_pixelBox (g15canvas \* canvas, int x1, int y1, int x2, int y2, int color, int thick, int fill)

Draws a box bounded by (x1, y1) and (x2, y2).

Draws a box around the area bounded by (x1, y1) and (x2, y2).

The box will be filled if fill != 0 and the sides will be thick pixels wide.

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *x1* Defines leftmost bound of the box. \
 *y1* Defines uppermost bound of the box. \
 *x2* Defines rightmost bound of the box. \
 *y2* Defines bottommost bound of the box. \
 *color* Lines defining the box will be drawn this color. \
 *thick* Lines defining the box will be this many pixels thick. \
 *fill* The box will be filled with color if fill != 0.

Definition at line 166 of file pixel.c.

References g15r\_drawLine(), and g15r\_setPixel().

Referenced by g15r\_drawBar(), and g15r\_drawBigNum().

### void g15r\_pixelOverlay (g15canvas \* canvas, int x1, int y1, int width, int height, short colormap\[\])

Overlays a bitmap of size width x height starting at (x1, y1).

A 1-bit bitmap defined in colormap\[\] is drawn to the canvas with an upper left corner at (x1, y1) and a lower right corner at (x1+width, y1+height).

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *x1* Defines the leftmost bound of the area to be drawn. \
 *y1* Defines the uppermost bound of the area to be drawn. \
 *width* Defines the width of the bitmap to be drawn. \
 *height* Defines the height of the bitmap to be drawn. \
 *colormap* An array containing width\*height entries of value 0 for pixel off or != 0 for pixel on.

Definition at line 77 of file pixel.c.

References G15\_COLOR\_BLACK, G15\_COLOR\_WHITE, and g15r\_setPixel().

### void g15r\_pixelReverseFill (g15canvas \* canvas, int x1, int y1, int x2, int y2, int fill, int color)

Fills an area bounded by (x1, y1) and (x2, y2).

The area with an upper left corner at (x1, y1) and lower right corner at (x2, y2) will be filled with color if fill\>0 or the current contents of the area will be reversed if fill==0.

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *x1* Defines leftmost bound of area to be filled. \
 *y1* Defines uppermost bound of area to be filled. \
 *x2* Defines rightmost bound of area to be filled. \
 *y2* Defines bottommost bound of area to be filled. \
 *fill* Area will be filled with color if fill != 0, else contents of area will have color values reversed. \
 *color* If fill != 0, then area will be filled if color == 1 and emptied if color == 0.

Definition at line 48 of file pixel.c.

References g15r\_getPixel(), and g15r\_setPixel().

### void g15r\_renderCharacterLarge (g15canvas \* canvas, int col, int row, unsigned char character, unsigned int sx, unsigned int sy)

Renders a character in the large font at (x, y).

Render a character in std large font

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *col* size-dependent column to start rendering. \
 *row* size-dependent row to start rendering. \
 *character* ascii character to render. \
 *sx* horizontal top-left pixel location. \
 *sy* vertical top-left pixel location.

Definition at line 33 of file text.c.

References G15\_COLOR\_BLACK, G15\_TEXT\_LARGE, and g15r\_G15FPrint().

### void g15r\_renderCharacterMedium (g15canvas \* canvas, int col, int row, unsigned char character, unsigned int sx, unsigned int sy)

Renders a character in the meduim font at (x, y).

Render a character in std medium font.

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *col* size-dependent column to start rendering. \
 *row* size-dependent row to start rendering. \
 *character* ascii character to render. \
 *sx* horizontal top-left pixel location. \
 *sy* vertical top-left pixel location.

Definition at line 52 of file text.c.

References G15\_COLOR\_BLACK, G15\_TEXT\_MED, and g15r\_G15FPrint().

### void g15r\_renderCharacterSmall (g15canvas \* canvas, int col, int row, unsigned char character, unsigned int sx, unsigned int sy)

Renders a character in the small font at (x, y).

Render a character in std small font.

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *col* size-dependent column to start rendering. \
 *row* size-dependent row to start rendering. \
 *character* ascii character to render. \
 *sx* horizontal top-left pixel location. \
 *sy* vertical top-left pixel location.

Definition at line 72 of file text.c.

References G15\_COLOR\_BLACK, G15\_TEXT\_SMALL, and g15r\_G15FPrint().

### int g15r\_renderG15Glyph (g15canvas \* canvas, g15font \* font, unsigned char character, int top\_left\_pixel\_x, int top\_left\_pixel\_y, int colour, int paint\_bg)

render glyph 'character' from loaded font struct 'font'. Returns width (in pixels) of rendered glyph

Render a character in given font.

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *font* Loaded **g15font** structure as returned by **g15r\_loadG15Font()** \
 *character* ascii character to render. \
 *top\_left\_pixel\_x* horizontal top-left pixel location. \
 *top\_left\_pixel\_y* vertical top-left pixel location. \
 *colour* desired colour of character when rendered. \
 *paint\_bg* should the background of the character cell be painted?

Definition at line 461 of file text.c.

References g15font::ascender\_height, g15glyph::buffer, g15font::default\_gap, g15font::font\_height, g15r\_setPixel(), g15font::glyph, and g15glyph::width.

Referenced by g15r\_G15FontRenderString().

### void g15r\_renderString (g15canvas \* canvas, unsigned char stringOut\[\], int row, int size, unsigned int sx, unsigned int sy)

Renders a string with font size in row.

Render a string in the designated size

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *stringOut* An unsigned char pointer to the string which is to be printed. \
 *row* size-dependent row to start rendering. \
 *size* size of printed string. May be 0-3 for standard sizes, or 5-39 in pixel height. \
 *sx* horizontal top-left pixel location. \
 *sy* vertical top-left pixel location.

Definition at line 93 of file text.c.

References G15\_COLOR\_BLACK, and g15r\_G15FPrint().

### int g15r\_saveG15Font (char \* oFilename, g15font \* font)

Save font in font struct to given file, return 0 on success.

Save **g15font** struct to given file.

**Parameters:**

*oFilename* string containing full name and location of font to save. \
 *font* **g15font** structure containing glyphs. Glyphs to be saved should have the corresponding active\[glyph\] set.

**Returns:**

0 on success, -1 on failure.

Definition at line 361 of file text.c.

References g15font::active, g15font::ascender\_height, g15glyph::buffer, g15font::default\_gap, g15font::font\_height, G15\_CHAR\_HEADER\_SIZE, G15\_FONT\_HEADER\_SIZE, G15\_MAX\_GLYPH, g15font::glyph, g15font::lineheight, g15font::numchars, and g15glyph::width.

### void g15r\_setPixel (g15canvas \* canvas, unsigned int x, unsigned int y, int val)

Sets the value of the pixel at (x, y).

Sets the value of the pixel at (x, y)

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *x* X offset for pixel to be set. \
 *y* Y offset for pixel to be set. \
 *val* Value to which pixel should be set.

Definition at line 50 of file screen.c.

References g15canvas::buffer, BYTE\_SIZE, G15\_LCD\_HEIGHT, G15\_LCD\_WIDTH, g15r\_getPixel(), g15canvas::mode\_reverse, and g15canvas::mode\_xor.

Referenced by draw\_ttf\_char(), g15r\_drawCircle(), g15r\_drawIcon(), g15r\_drawLine(), g15r\_drawRoundBox(), g15r\_drawSprite(), g15r\_drawXBM(), g15r\_pixelBox(), g15r\_pixelOverlay(), g15r\_pixelReverseFill(), and g15r\_renderG15Glyph().

### int g15r\_testG15FontWidth (g15font \* font, char \* string)

Returns length (in pixels) of string if rendered in font 'font'.

Calculate width (in pixels) of given string if rendered in font 'font'.

**Parameters:**

*font* Loaded **g15font** structure as returned by **g15r\_loadG15Font()** \
 *string* Pointer to string for width calculations.

**Returns:**

total width in pixels of given string.

Definition at line 439 of file text.c.

References g15font::default\_gap, g15glyph::gap, g15font::glyph, and g15glyph::width.

Referenced by g15r\_G15FPrint().

### void g15r\_ttfLoad (g15canvas \* canvas, char \* fontname, int fontsize, int face\_num)

Loads a font through the FreeType2 library.

Load a font for use with FreeType2 font support

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *fontname* Absolute pathname to font file to be loaded. \
 *fontsize* Size in points for font to be loaded. \
 *face\_num* Slot into which font face will be loaded.

Definition at line 109 of file text.c.

References g15canvas::ftLib, G15\_MAX\_FACE, g15canvas::ttf\_face, and g15canvas::ttf\_fontsize.

### void g15r\_ttfPrint (g15canvas \* canvas, int x, int y, int fontsize, int face\_num, int color, int center, char \* print\_string)

Prints a string in a given font.

Render a string with a FreeType2 font

**Parameters:**

*canvas* A pointer to a **g15canvas** struct in which the buffer to be operated on is found. \
 *x* initial x position for string. \
 *y* initial y position for string. \
 *fontsize* Size of string in points. \
 *face\_num* Font to be used is loaded in this slot. \
 *color* Text will be drawn this color. \
 *center* Text will be centered if center == 1 and right justified if center == 2. \
 *print\_string* Pointer to the string to be printed.

Definition at line 247 of file text.c.

References calc\_ttf\_centering(), calc\_ttf\_right\_justify(), calc\_ttf\_true\_ypos(), draw\_ttf\_str(), g15r\_G15FPrint(), g15canvas::ttf\_face, and g15canvas::ttf\_fontsize.

## Variable Documentation

### unsigned char fontdata\_6x4\[\]

Font data for the small (6x4) font.

### unsigned char fontdata\_7x5\[\]

Font data for the medium (7x5) font.

### unsigned char fontdata\_8x8\[\]

Font data for the large (8x8) font.

## Author

Anthony J. Mirabella \<mirabeaj@gmail.com\>

Generated automatically by Doxygen for libg15render from the source code.
