34 lines
672 B
C
Raw Normal View History

2023-02-12 09:34:44 +01:00
#include <stdlib.h>
#include <stdio.h>
#include <grapheme.h>
#include "cache.h"
#include "font.h"
2023-02-15 02:15:44 +01:00
#include "util.h"
2023-02-12 09:34:44 +01:00
int main(void)
{
2023-02-15 02:15:44 +01:00
int err;
struct font_atlas *at = font_init();
err = font_load(at, "./monospace.ttf");
ERROR(err, -1, printf("failed to load font\n"));
2023-02-12 09:34:44 +01:00
2023-02-15 02:15:44 +01:00
const char *s = "ciao mamma";
const struct font_glyph *g;
2023-02-12 09:34:44 +01:00
size_t ret, off;
uint_least32_t cp;
for (off = 0; (ret = grapheme_decode_utf8(s+off, SIZE_MAX, &cp)) > 0 && cp != 0; off += ret) {
printf("%.*s (%d) -> %d\n", (int)ret, s+off, (int)ret, cp);
2023-02-15 02:15:44 +01:00
g = font_get_glyph_texture(at, cp);
if (!g)
printf("g is NULL\n");
2023-02-12 09:34:44 +01:00
}
2023-02-15 02:15:44 +01:00
font_dump(at, "./atlas.png");
font_free(at);
2023-02-12 09:34:44 +01:00
return 0;
}