Project

General

Profile

Statistics
| Revision:

root / proj / src / font.c @ 182

History | View | Annotate | Download (563 Bytes)

1 182 up20180642
#include <lcom/lcf.h>
2
3
#include "font.h"
4
5
struct glyph{
6
    uint16_t w, h;
7
    uint8_t *map;
8
};
9
10
glyph_t* (glyph_ctor)(const char **xpm){
11
    glyph_t *ret = malloc(sizeof(glyph_t));
12
    if(ret == NULL) return NULL;
13
    enum xpm_image_type type = XPM_8_8_8_8;
14
    xpm_image_t img;
15
    ret->map = xpm_load((xpm_map_t)xpm, type, &img);
16
    if(ret->map == NULL){
17
        free(ret);
18
        return NULL;
19
    }
20
    ret->w = img.width;
21
    ret->h = img.height;
22
    return ret;
23
}
24
25
void (glyph_dtor)(glyph_t *p){
26
    if(p == NULL) return;
27
    free(p->map);
28
    free(p);
29
}