31 lines
707 B
C
31 lines
707 B
C
#include <vhex/display.h>
|
|
#include <vhex/defs/types.h>
|
|
|
|
#include <string.h>
|
|
|
|
//TODO: dynamic
|
|
extern struct {
|
|
uint32_t width;
|
|
uint32_t height;
|
|
uint32_t pixel[];
|
|
} font8x9;
|
|
|
|
/* dsize(): Get the width and height of rendered text */
|
|
//TODO: line-discipline
|
|
void dsize(char const *str, int *w, int *h)
|
|
{
|
|
if (str == NULL) return;
|
|
if (w != NULL) *w = strlen(str) * (font8x9.width + 1);
|
|
if (h != NULL) *h = font8x9.height;
|
|
}
|
|
|
|
|
|
/* dnsize(): Get the width and height of rendered text for the n first char */
|
|
//TODO: line-discipline
|
|
void dnsize(char const *str, int n, int *w, int *h)
|
|
{
|
|
if (str == NULL) return;
|
|
if (w != NULL) *w = strnlen(str, n) * (font8x9.width + 1);
|
|
if (h != NULL) *h = font8x9.height;
|
|
}
|