Files
cudoku/text.h
T

38 lines
1.0 KiB
C
Raw Normal View History

2023-11-29 01:42:44 +02:00
#pragma once
2023-12-11 22:42:19 +02:00
#include "core.h"
2023-11-29 01:42:44 +02:00
#include "ui.h"
2023-12-11 22:42:19 +02:00
#include "zephr_math.h"
2023-11-29 01:42:44 +02:00
typedef struct Character {
Size size;
Size bearing;
unsigned int advance;
Vec2f tex_coords[4]; // the 4 corners of the character quad
} Character;
2023-12-11 22:42:19 +02:00
typedef struct ZephrFont {
2023-11-29 01:42:44 +02:00
Character characters[128];
unsigned int atlas_texture_id;
2023-12-11 22:42:19 +02:00
} ZephrFont;
2023-11-29 01:42:44 +02:00
typedef struct TextInstance {
Vec4f position;
int tex_coords_index;
Color color;
float model[4][4];
2023-11-30 18:25:44 +02:00
} GlyphInstance;
2023-11-29 01:42:44 +02:00
typedef struct GlyphInstanceList {
2023-11-30 18:25:44 +02:00
GlyphInstance *data;
2023-11-29 01:42:44 +02:00
int size;
int capacity;
} GlyphInstanceList;
2023-12-11 22:42:19 +02:00
void new_glyph_instance_list(GlyphInstanceList *list, u32 capacity);
2023-11-29 01:42:44 +02:00
int init_fonts(const char *font_path);
Sizef calculate_text_size(const char *text, int font_size);
void draw_text(const char* text, int font_size, UIConstraints constraints, const Color *color, Alignment alignment);
2023-11-30 18:25:44 +02:00
void add_text_instance(GlyphInstanceList *batch, const char* text, int font_size, UIConstraints constraints, const Color *color, Alignment alignment);
void draw_text_batch(GlyphInstanceList *batch);