12#define GP_FONT_NAME_MAX 64
27typedef struct gp_glyph {
67typedef enum gp_font_bitmap_format {
70} gp_font_bitmap_format;
75typedef enum gp_font_style {
76 GP_FONT_REGULAR = 0x00,
79 GP_FONT_ITALIC = 0x04,
80 GP_FONT_STYLE_MASK = 0x0f,
85 GP_FONT_FALLBACK = 0x10,
88#define GP_FONT_STYLE(x) ((x) & GP_FONT_STYLE_MASK)
90typedef uint32_t gp_glyph_offset;
91#define GP_NOGLYPH UINT32_MAX
93typedef struct gp_glyphs {
103 gp_glyph_offset *offsets;
104 gp_glyph_offset offset;
115typedef struct gp_font_face gp_font_face;
121 gp_glyph *(*glyph_load)(
const gp_font_face *self, uint32_t ch);
122 void (*font_free)(gp_font_face *self);
127 char family_name[GP_FONT_NAME_MAX];
133 uint8_t glyph_tables;
146 uint16_t max_glyph_width;
151 uint16_t max_glyph_advance;
156 uint16_t avg_glyph_advance;
161 gp_font_bitmap_format glyph_bitmap_format;
181typedef enum gp_font_ucode_block {
183 GP_UCODE_LATIN_BASIC = 0x0001,
185 GP_UCODE_LATIN_SUP = 0x0002,
187 GP_UCODE_LATIN_EXT_A = 0x0004,
189 GP_UCODE_GREEK = 0x0008,
191 GP_UCODE_CYRILIC = 0x0010,
193 GP_UCODE_HIRAGANA= 0x0020,
195 GP_UCODE_KATAKANA = 0x0030,
196} gp_font_ucode_block;
204typedef struct gp_font_family {
205 const char *family_name;
207 uint32_t ucode_blocks;
208 const gp_font_face *
const fonts[];
214static inline unsigned int gp_font_height(
const gp_font_face *font)
216 return font->ascend + font->descend;
219static inline unsigned int gp_font_ascend(
const gp_font_face *font)
224static inline unsigned int gp_font_descend(
const gp_font_face *font)
226 return font->descend;
229static inline unsigned int gp_font_max_width(
const gp_font_face *font)
231 return font->max_glyph_width;
234static inline unsigned int gp_font_max_advance_x(
const gp_font_face *font)
236 return font->max_glyph_advance;
239static inline unsigned int gp_font_avg_advance_x(
const gp_font_face *font)
241 if (font->avg_glyph_advance)
242 return font->avg_glyph_advance;
245 return font->max_glyph_advance;
248static inline const char *gp_font_family_name(
const gp_font_face *font)
250 return font->family_name;
253const char *gp_font_style_name(uint8_t style);
258gp_glyph *gp_get_glyph(
const gp_font_face *font, uint32_t ch);
261gp_font_face *gp_font_face_load(
const char *path, uint32_t width, uint32_t height);
264gp_font_face *gp_font_face_fc_load(
const char *name, uint32_t width, uint32_t height);
267void gp_font_face_free(gp_font_face *self);