summaryrefslogtreecommitdiff
path: root/src/text.h
blob: 2e768ee5c896e55b5ce2f6b597a6bfa2170c3e8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include "cglm/types.h"
#include "freetype/freetype.h"
#include "sokol_gfx.h"
#include "utils.h"

struct text_vertex_s {
  vec2 pos;
  vec2 uv;
};

enum font_context_error_e : u8 {
  FONT_CONTEXT_ERROR_NONE = 0,
  FONT_CONTEXT_ERROR_LOAD_LIBRARY,
};

struct font_context_s {
  FT_Library ft;
  struct sg_pipeline pipeline;
  struct sg_sampler sampler;
};

enum font_context_error_e font_context_init(struct font_context_s* context);
void font_context_deinit(struct font_context_s* context);

struct font_s {
  FT_Face face;
  u8* source;

  u8* staging;
  bool staging_dirty;
  struct sg_image atlas;
};