86 lines
1.7 KiB
C
86 lines
1.7 KiB
C
#ifndef __VHEX_DISPLAY_FONT__
|
|
# define __VHEX_DISPLAY_FONT__
|
|
|
|
#include <vhex/defs/types.h>
|
|
#include <vhex/defs/attributes.h>
|
|
#include <vhex/display/shader.h>
|
|
|
|
/* font_t: Font data encoded for dfont*() functions */
|
|
typedef struct font {
|
|
/* Font name (NUL-terminated), NULL if no title */
|
|
char const *name;
|
|
|
|
/* Font shape flags */
|
|
byte_union(shape,
|
|
uint8_t bold :1;
|
|
uint8_t italic :1;
|
|
uint8_t serif :1;
|
|
uint8_t mono :1;
|
|
uint8_t :3;
|
|
uint8_t prop :1;
|
|
);
|
|
|
|
/* Line height */
|
|
uint8_t line_height;
|
|
/* Storage height */
|
|
uint8_t data_height;
|
|
|
|
/* Number of Unicode blocks */
|
|
uint8_t block_count;
|
|
/* Number of total glyphs */
|
|
uint32_t glyph_count;
|
|
|
|
/* Character spacing (usually 1) */
|
|
uint8_t char_spacing;
|
|
|
|
struct {
|
|
/* Unicode point of first character in block */
|
|
uint32_t start :20;
|
|
/* Length of block */
|
|
uint32_t length :12;
|
|
} *blocks;
|
|
|
|
/* Raw glyph data */
|
|
uint32_t *data;
|
|
|
|
union {
|
|
/* For monospaced fonts */
|
|
struct {
|
|
/* Width of glyphs */
|
|
uint16_t width;
|
|
/* Storage size, in longwords, of each glyph */
|
|
uint16_t storage_size;
|
|
};
|
|
/* For proportional fonts */
|
|
struct {
|
|
/* Storage index to find glyphs quickly */
|
|
uint16_t *glyph_index;
|
|
/* Width of each individual glyph */
|
|
uint8_t *glyph_width;
|
|
};
|
|
};
|
|
|
|
} VPACKED(4) font_t;
|
|
|
|
/* dfont_get() : get the current font */
|
|
extern font_t *dfont_get(void);
|
|
|
|
/* dfont_text_geometry() : get the char geometry */
|
|
extern int dfont_text_geometry(
|
|
font_t *font,
|
|
char const * const str_char,
|
|
int *size,
|
|
size_t *w,
|
|
size_t *h
|
|
);
|
|
|
|
|
|
//---
|
|
// Kernel-level API
|
|
//---
|
|
|
|
/* dfont_render() : draw caracter in surface */
|
|
extern void dfont_text_render(struct dshader_surface *surface, uint32_t *arg);
|
|
|
|
#endif /* __VHEX_DISPLAY_FONT__ */
|