2021-11-30 21:29:18 -06:00
|
|
|
#ifndef FONT_H
|
|
|
|
#define FONT_H
|
|
|
|
|
|
|
|
#include "mathc.h"
|
2022-12-30 13:31:06 -06:00
|
|
|
#include "texture.h"
|
2023-05-04 17:07:00 -05:00
|
|
|
#include "sokol/sokol_gfx.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 {
|
|
|
|
mfloat_t Size[2]; // Size of glyph
|
|
|
|
mfloat_t Bearing[2]; // Offset from baseline to left/top of glyph
|
|
|
|
unsigned int Advance; // Horizontal offset to advance to next glyph
|
2022-12-28 16:50:54 -06:00
|
|
|
struct glrect rect;
|
2023-03-10 13:13:48 -06:00
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sFont {
|
|
|
|
uint32_t fontTexture;
|
|
|
|
uint32_t height;
|
2022-12-16 09:07:21 -06:00
|
|
|
struct Character Characters[127];
|
2023-05-04 17:07:00 -05:00
|
|
|
sg_image texID;
|
2021-11-30 21:29:18 -06:00
|
|
|
};
|
|
|
|
|
2022-11-19 17:13:57 -06:00
|
|
|
void font_init(struct shader *s);
|
2022-11-03 16:58:03 -05:00
|
|
|
void font_frame(struct window *w);
|
2022-01-19 16:43:21 -06:00
|
|
|
struct sFont *MakeFont(const char *fontfile, int height);
|
2022-11-19 17:13:57 -06:00
|
|
|
void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, struct shader *shader, float color[3]);
|
2022-01-31 17:04:59 -06:00
|
|
|
void text_settype(struct sFont *font);
|
2023-04-07 12:52:35 -05:00
|
|
|
int renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw,int caret);
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2023-05-06 21:16:10 -05:00
|
|
|
//void text_frame();
|
|
|
|
void text_flush();
|
|
|
|
|
2023-01-15 09:53:50 -06:00
|
|
|
unsigned char *slurp_file(const char *filename);
|
2023-02-02 17:52:15 -06:00
|
|
|
char *slurp_text(const char *filename);
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2023-01-25 21:32:58 -06:00
|
|
|
int slurp_write(const char *txt, const char *filename);
|
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
#endif
|