font.h 670 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef GS_PIXEL_EDITOR_FONT_H
  2. #define GS_PIXEL_EDITOR_FONT_H
  3. #include "gs.h"
  4. // For this font, Each glyph is monospaced, 5 x 7 pixels.
  5. // Total font size is 128 x 64.
  6. typedef struct font_glyph_t
  7. {
  8. u32 x;
  9. u32 y;
  10. u32 width;
  11. u32 height;
  12. } font_glyph_t;
  13. // 6 rows of font data to use * 18 columns
  14. // Total num glyphs = 6 * 18 - (18 - 5)
  15. #define total_num_font_glyphs (6 * 18)
  16. typedef struct font_t
  17. {
  18. void* data;
  19. u32 width;
  20. u32 height;
  21. u32 num_comps;
  22. u32 glyph_advance;
  23. gs_texture_format texture_format;
  24. font_glyph_t glyphs[ total_num_font_glyphs ];
  25. } font_t;
  26. // Font methods
  27. font_t construct_font_data();
  28. font_glyph_t get_glyph( font_t* f, char c );
  29. #endif