#ifndef ECEX_FONT_H #define ECEX_FONT_H #include #include "stb_truetype.h" #define ECEX_FONT_BITMAP_W 512 #define ECEX_FONT_BITMAP_H 512 #define ECEX_FONT_FIRST_CHAR 32 #define ECEX_FONT_CHAR_COUNT 96 typedef struct font { GLuint texture; stbtt_bakedchar chars[ECEX_FONT_CHAR_COUNT]; float size_px; /* * draw_text() takes y as a baseline. These metrics let render.c place * baselines, highlights, bars, and cursors from the same font-scaled * coordinate system instead of fixed pixel constants. */ float ascent_px; float descent_px; float line_gap_px; float line_height; } font_t; const char *font_choose_path(const char *explicit_font_path); int font_load(font_t *font, const char *path, float size_px); void font_free(font_t *font); void draw_text(font_t *font, float x, float y, const char *text); float text_width(font_t *font, const char *text); #endif