The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
bragi_cell.c File Reference

bragi: the monospace grid, with box drawing done in code. More...

#include "bragi_internal.h"

Macros

#define ARMS(up, right, down, left)
#define ARM_UP(a)
#define ARM_RIGHT(a)
#define ARM_DOWN(a)
#define ARM_LEFT(a)

Functions

void bragi_cell_size (bragi_face_t *face, int32_t *width, int32_t *height)
 the cell of a monospace face, in whole pixels: the advance of "M" and the line height.
void bragi_draw_cell (gfx_buffer_t *buf, bragi_face_t *face, int32_t x, int32_t y, uint32_t codepoint, gfx_color_t color)
 draw one character in a cell, its top left at (x, y).

Detailed Description

bragi: the monospace grid, with box drawing done in code.

a font's box drawing glyphs do not always fill the cell (the cell is rounded to whole pixels), so lines in a terminal get gaps. the single and heavy lines (U+2500 to U+254F, U+2574 to U+257F, and the round corners) and the block elements (U+2580 to U+259F) are drawn here as rectangles that fill the cell. the double lines and the diagonals come from the font.

Macro Definition Documentation

◆ ARMS

#define ARMS ( up,
right,
down,
left )
Value:
(uint8_t)((up) << 6 | (right) << 4 | (down) << 2 | (left))
unsigned char uint8_t
Definition fb.h:18

◆ ARM_UP

#define ARM_UP ( a)
Value:
(((a) >> 6) & 3)

◆ ARM_RIGHT

#define ARM_RIGHT ( a)
Value:
(((a) >> 4) & 3)

◆ ARM_DOWN

#define ARM_DOWN ( a)
Value:
(((a) >> 2) & 3)

◆ ARM_LEFT

#define ARM_LEFT ( a)
Value:
((a) & 3)

Function Documentation

◆ bragi_cell_size()

void bragi_cell_size ( bragi_face_t * face,
int32_t * width,
int32_t * height )

the cell of a monospace face, in whole pixels: the advance of "M" and the line height.

◆ bragi_draw_cell()

void bragi_draw_cell ( gfx_buffer_t * buf,
bragi_face_t * face,
int32_t x,
int32_t y,
uint32_t codepoint,
gfx_color_t color )

draw one character in a cell, its top left at (x, y).

the background is not drawn. the single and heavy box drawing lines and the block elements are drawn by code to fill the cell, so they join from cell to cell; the double lines and the diagonals come from the font.