2021-11-30 21:29:18 -06:00
|
|
|
#ifndef FONT_H
|
|
|
|
#define FONT_H
|
|
|
|
|
2023-05-04 17:07:00 -05:00
|
|
|
#include "sokol/sokol_gfx.h"
|
2023-05-12 13:22:05 -05:00
|
|
|
#include "texture.h"
|
2023-05-16 01:31:13 -05:00
|
|
|
#include "2dphysics.h"
|
2023-05-24 20:45:50 -05:00
|
|
|
#include "HandmadeMath.h"
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
struct shader;
|
2022-11-03 16:58:03 -05:00
|
|
|
struct window;
|
2021-11-30 21:29:18 -06:00
|
|
|
|
|
|
|
/// Holds all state information relevant to a character as loaded using FreeType
|
|
|
|
struct Character {
|
2023-05-24 20:45:50 -05:00
|
|
|
float Size[2]; // Size of glyph
|
|
|
|
float Bearing[2]; // Offset from baseline to left/top of glyph
|
2023-05-30 15:41:02 -05:00
|
|
|
int Advance; // Horizontal offset to advance to next glyph
|
|
|
|
int leftbearing;
|
2023-05-12 13:22:05 -05:00
|
|
|
struct glrect rect;
|
2021-11-30 21:29:18 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sFont {
|
2023-05-12 13:22:05 -05:00
|
|
|
uint32_t fontTexture;
|
2023-05-30 15:41:02 -05:00
|
|
|
uint32_t height; /* in pixels */
|
|
|
|
int ascent;
|
|
|
|
int descent;
|
|
|
|
int linegap;
|
2023-06-05 10:32:45 -05:00
|
|
|
float emscale;
|
2023-05-12 13:22:05 -05:00
|
|
|
struct Character Characters[127];
|
|
|
|
sg_image texID;
|
2021-11-30 21:29:18 -06:00
|
|
|
};
|
|
|
|
|
2023-09-04 09:48:44 -05:00
|
|
|
void font_init();
|
2022-01-19 16:43:21 -06:00
|
|
|
struct sFont *MakeFont(const char *fontfile, int height);
|
2023-10-04 17:57:37 -05:00
|
|
|
void sdrawCharacter(struct Character c, HMM_Vec2 cursor, float scale, struct rgba color);
|
2022-01-31 17:04:59 -06:00
|
|
|
void text_settype(struct sFont *font);
|
2023-10-09 13:03:12 -05:00
|
|
|
struct boundingbox text_bb(const unsigned char *text, float scale, float lw, float tracking);
|
|
|
|
int renderText(const unsigned char *text, HMM_Vec2 pos, float scale, struct rgba color, float lw, int caret, float tracking);
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
// void text_frame();
|
2023-06-28 11:35:41 -05:00
|
|
|
void text_flush(HMM_Mat4 *proj);
|
2023-05-06 21:16:10 -05:00
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
#endif
|