// this file is designed to be platform-agnostic #pragma once #include #ifdef __cplusplus extern "C" { #endif // metrics are 26.6 fixed point struct glyph_metrics { int32_t width; int32_t height; int32_t horiBearingX; int32_t horiBearingY; int32_t horiAdvance; } __attribute__ ((packed)); static_assert((sizeof (struct glyph_metrics)) == ((sizeof (int32_t)) * 5)); struct glyph_texture { uint16_t x; uint16_t y; uint16_t width; uint16_t height; } __attribute__ ((packed)); static_assert((sizeof (struct glyph_texture)) == ((sizeof (uint16_t)) * 4)); struct glyph_bitmap { int32_t left; int32_t top; } __attribute__ ((packed)); static_assert((sizeof (struct glyph_bitmap)) == ((sizeof (uint32_t)) * 2)); struct glyph { struct glyph_texture texture; struct glyph_metrics metrics; struct glyph_bitmap bitmap; } __attribute__ ((packed)); static_assert((sizeof (struct glyph)) == ((sizeof (struct glyph_texture)) + (sizeof (struct glyph_metrics)) + (sizeof (struct glyph_bitmap)))); struct font { uint32_t first_char_code; uint32_t last_char_code; struct face_metrics { int32_t height; // 26.6 fixed point int32_t max_advance; // 26.6 fixed point } face_metrics; uint32_t glyph_count; uint16_t texture_width; uint16_t texture_height; } __attribute__ ((packed)); static_assert((sizeof (struct font)) == ((sizeof (uint32_t)) * 6)); #ifdef __cplusplus } #endif