gpforge
An advanced bitmap font editor
Loading...
Searching...
No Matches
format_c.c
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright (C) 2026 Cyril Hrubis <metan@ucw.cz>
4 */
5
6#include <stdlib.h>
7#include <string.h>
8
9#include <utils/gp_utf.h>
10#include <utils/gp_vec.h>
11#include <text/gp_font.h>
12
13#include "resolve.h"
14#include "format_c.h"
15
16/*
17 * The ranges a gfxprim font is made of. They are not unicode blocks: gfxprim
18 * indexes a table by the codepoint, so a table is a contiguous range and the
19 * ones that are worth having are these. Everything outside them is dropped by
20 * the export — it is the reason a font has more glyphs than the C font it
21 * compiles into.
22 *
23 * The ASCII table is first because gfxprim looks it up by position.
24 */
25struct range {
26 uint32_t min, max;
27 /* the C symbol suffix, NULL for the ASCII table */
28 const char *suffix;
29 const char *ucode;
30};
31
32static const struct range ranges[] = {
33 {0x0020, 0x007f, NULL, "GP_UCODE_LATIN_BASIC"},
34 {0x00a1, 0x017e, "latin_ext", "GP_UCODE_LATIN_SUP | GP_UCODE_LATIN_EXT_A"},
35 {0x0384, 0x03ce, "greek", "GP_UCODE_GREEK"},
36 {0x0400, 0x045f, "cyrilic", "GP_UCODE_CYRILIC"},
37 {0x2018, 0x2037, "punctuation", "GP_UCODE_PUNCTUATION"},
38 {0x2070, 0x208e, "subsuper", "GP_UCODE_SUB_SUPER"},
39 {0x2190, 0x21ff, "arrows", "GP_UCODE_ARROWS"},
40 {0x2500, 0x257f, "box", "GP_UCODE_BOX"},
41 {0x3041, 0x3096, "hiragana", "GP_UCODE_HIRAGANA"},
42 {0x30a0, 0x30ff, "katakana", "GP_UCODE_KATAKANA"},
43 {}
44};
45
46/* the C symbol a variant's tables and face are named with */
47static const char *var_id(enum gpf_variant_id id)
48{
49 switch (id) {
50 case GPF_MONO:
51 return "font";
52 case GPF_REGULAR:
53 return "font_regular";
54 case GPF_BOLD_MONO:
55 return "font_bold_mono";
56 default:
57 return "font_bold";
58 }
59}
60
61static void sym(char *buf, size_t len, enum gpf_variant_id id,
62 const struct range *range, const char *what)
63{
64 if (range->suffix)
65 snprintf(buf, len, "%s_%s_%s", var_id(id), range->suffix, what);
66 else
67 snprintf(buf, len, "%s_%s", var_id(id), what);
68}
69
70/*
71 * A glyph is five bytes of metrics and then the bitmap, rows byte aligned and
72 * the whole thing padded to four bytes — struct gp_glyph, as the compiled in
73 * fonts store it.
74 */
75static size_t glyph_size(const struct gpf_glyph *glyph)
76{
77 size_t rows = ((size_t)glyph->width + 7) / 8;
78
79 return (5 + rows * glyph->height + 3) & ~(size_t)3;
80}
81
82/*
83 * The glyph record as the bytes that end up in the array, so that two glyphs
84 * are the same record exactly when these compare equal.
85 */
86static uint8_t *glyph_record(const struct gpf_glyph *glyph)
87{
88 unsigned int row_bytes = (glyph->width + 7) / 8;
89 uint8_t *rec = calloc(1, glyph_size(glyph));
90 unsigned int x, y, i;
91 size_t pos = 5;
92
93 if (!rec)
94 return NULL;
95
96 rec[0] = glyph->width;
97 rec[1] = glyph->height;
98 rec[2] = glyph->bearing_x;
99 rec[3] = glyph->bearing_y;
100 rec[4] = glyph->advance;
101
102 for (y = 0; y < glyph->height; y++) {
103 for (x = 0; x < row_bytes; x++) {
104 for (i = 0; i < 8; i++) {
105 if (8 * x + i >= glyph->width)
106 break;
107
108 if (gpf_glyph_pixel(glyph, 8 * x + i, y))
109 rec[pos] |= 0x80 >> i;
110 }
111
112 pos++;
113 }
114 }
115
116 /* the padding is left zeroed, it keeps the next record aligned */
117 return rec;
118}
119
120/* a codepoint that points to a record and the variants it does so in */
121struct glyph_ref {
122 uint32_t code;
123 /* a bit per variant */
124 unsigned int variants;
125};
126
127static void emit_ref(FILE *f, const struct glyph_ref *ref)
128{
129 char utf[5] = "";
130 const char *sep = "";
131 unsigned int id;
132
133 utf[gp_to_utf8(ref->code, utf)] = 0;
134
135 if (ref->code < 0x7f)
136 fprintf(f, "\t/* '%s'", utf);
137 else
138 fprintf(f, "\t/* 0x%0x '%s'", ref->code, utf);
139
140 for (id = 0; id < GPF_VARIANTS; id++) {
141 if (!(ref->variants & (1u << id)))
142 continue;
143
144 fprintf(f, "%s %s", sep, gpf_variant_name(id));
145 sep = " |";
146 }
147
148 fprintf(f, " */\n");
149}
150
151/*
152 * A record with a comment above it for each codepoint that points to it,
153 * naming the variants it does so in.
154 */
155static void emit_record(FILE *f, const struct glyph_ref *refs,
156 const uint8_t *rec, size_t size)
157{
158 size_t pos, i;
159
160 for (i = 0; i < gp_vec_len(refs); i++)
161 emit_ref(f, &refs[i]);
162
163 /* the bearings are signed */
164 fprintf(f, "\t%2i, %2i, %2i, %2i, %2i,\n", rec[0], rec[1],
165 (int8_t)rec[2], (int8_t)rec[3], rec[4]);
166
167 if (size > 5)
168 fprintf(f, "\t");
169
170 for (pos = 5; pos < size; pos++)
171 fprintf(f, "0x%02x,%s", rec[pos], pos + 1 < size ? " " : "\n");
172}
173
174static int range_has_glyphs(struct gpf_font *font, enum gpf_variant_id id,
175 const struct range *range)
176{
177 uint32_t code;
178
179 for (code = range->min; code <= range->max; code++) {
180 struct gpf_resolved res;
181
182 if (gpf_resolve(font, id, code, &res))
183 continue;
184
185 gpf_resolved_clear(&res);
186 return 1;
187 }
188
189 return 0;
190}
191
192/*
193 * The glyph array of the family. Every face indexes the same one, so that a
194 * glyph a variant inherits unchanged — all of `regular` that is not redrawn,
195 * the bold that embolds to what `bold-mono` does — is stored once.
196 */
197struct glyph_store {
198 uint8_t *data;
199 /* where each record starts in data */
200 size_t *starts;
201 /* the codepoints that point to each record, a vector per record */
202 struct glyph_ref **refs;
203};
204
205/*
206 * The index of a record the array already holds, or -1. A linear
207 * search, which is a few milliseconds for the largest corpus font with all
208 * four variants and runs once per export.
209 */
210static ssize_t find_record(const struct glyph_store *store,
211 const uint8_t *rec, size_t size)
212{
213 size_t i, cnt = gp_vec_len(store->starts);
214
215 for (i = 0; i < cnt; i++) {
216 size_t start = store->starts[i];
217 size_t end = i + 1 < cnt ? store->starts[i + 1] : gp_vec_len(store->data);
218
219 if (end - start == size && !memcmp(store->data + start, rec, size))
220 return i;
221 }
222
223 return -1;
224}
225
226/*
227 * The offset of a glyph record in the array, appending it when it is not there
228 * yet — H and the Cyrillic Н, a letter and the Greek one, a mono glyph and the
229 * regular that inherits it, are the same bytes. GP_NOGLYPH on allocation
230 * failure.
231 */
232static gp_glyph_offset store_record(struct glyph_store *store,
233 enum gpf_variant_id id, uint32_t code,
234 const uint8_t *rec, size_t size)
235{
236 struct glyph_ref ref = {.code = code, .variants = 1u << id};
237 ssize_t i = find_record(store, rec, size);
238 size_t len = gp_vec_len(store->data), j;
239 struct glyph_ref *refs;
240 uint8_t *tmp;
241
242 if (i >= 0) {
243 refs = store->refs[i];
244
245 for (j = 0; j < gp_vec_len(refs); j++) {
246 if (refs[j].code == code) {
247 refs[j].variants |= ref.variants;
248 return store->starts[i];
249 }
250 }
251
252 if (!GP_VEC_APPEND(store->refs[i], ref))
253 return GP_NOGLYPH;
254
255 return store->starts[i];
256 }
257
258 refs = gp_vec_new(0, sizeof(struct glyph_ref));
259 if (!refs)
260 return GP_NOGLYPH;
261
262 if (!GP_VEC_APPEND(refs, ref) || !GP_VEC_APPEND(store->refs, refs)) {
263 gp_vec_free(refs);
264 return GP_NOGLYPH;
265 }
266
267 if (!GP_VEC_APPEND(store->starts, len))
268 return GP_NOGLYPH;
269
270 tmp = gp_vec_expand(store->data, size);
271 if (!tmp)
272 return GP_NOGLYPH;
273
274 store->data = tmp;
275
276 memcpy(store->data + len, rec, size);
277
278 return len;
279}
280
281static void emit_glyphs(FILE *f, const struct glyph_store *store)
282{
283 size_t i, cnt = gp_vec_len(store->starts);
284
285 fprintf(f, "static uint8_t %s_glyphs[] = {\n", var_id(GPF_MONO));
286
287 for (i = 0; i < cnt; i++) {
288 size_t start = store->starts[i];
289 size_t end = i + 1 < cnt ? store->starts[i + 1] : gp_vec_len(store->data);
290
291 emit_record(f, store->refs[i], store->data + start, end - start);
292 }
293
294 fprintf(f, "};\n\n");
295}
296
297/*
298 * The offsets of a variant, one table per range it has glyphs in, with the
299 * records they point to added to the store. Sets tables[] to which ranges the
300 * variant has glyphs in; returns non-zero on allocation failure.
301 */
302static int variant_offsets(struct gpf_font *font,
303 enum gpf_variant_id id, struct glyph_store *store,
304 int *tables, gp_glyph_offset **offsets)
305{
306 uint32_t code;
307 unsigned int i;
308
309 for (i = 0; ranges[i].max; i++) {
310 size_t cnt = ranges[i].max - ranges[i].min + 1;
311
312 tables[i] = range_has_glyphs(font, id, &ranges[i]);
313 if (!tables[i])
314 continue;
315
316 offsets[i] = malloc(cnt * sizeof(gp_glyph_offset));
317 if (!offsets[i])
318 return 1;
319
320 for (code = ranges[i].min; code <= ranges[i].max; code++) {
321 gp_glyph_offset *off = &offsets[i][code - ranges[i].min];
322 struct gpf_resolved res;
323 uint8_t *rec;
324 size_t size;
325
326 *off = GP_NOGLYPH;
327
328 if (gpf_resolve(font, id, code, &res))
329 continue;
330
331 size = glyph_size(&res.glyph);
332 rec = glyph_record(&res.glyph);
333 gpf_resolved_clear(&res);
334
335 if (!rec)
336 return 1;
337
338 *off = store_record(store, id, code, rec, size);
339 free(rec);
340
341 if (*off == GP_NOGLYPH)
342 return 1;
343 }
344 }
345
346 return 0;
347}
348
349/*
350 * The variant whose offsets table a face points to for a range: an earlier one
351 * with the very same table, which is the case for a range nobody redrew, or the
352 * variant itself.
353 */
354static enum gpf_variant_id offsets_owner(int tables[][16],
355 gp_glyph_offset *offsets[][16],
356 enum gpf_variant_id id, unsigned int i)
357{
358 size_t size = (ranges[i].max - ranges[i].min + 1) * sizeof(gp_glyph_offset);
359 unsigned int prev;
360
361 for (prev = 0; prev < id; prev++) {
362 if (tables[prev][i] && !memcmp(offsets[prev][i], offsets[id][i], size))
363 return prev;
364 }
365
366 return id;
367}
368
369static void emit_offsets(FILE *f, enum gpf_variant_id id,
370 const struct range *range,
371 const gp_glyph_offset *offsets)
372{
373 size_t cnt = range->max - range->min + 1, i;
374 char name[128];
375
376 sym(name, sizeof(name), id, range, "offsets");
377
378 fprintf(f, "static gp_glyph_offset %s[] = {", name);
379
380 for (i = 0; i < cnt; i++) {
381 if (!(i % 8))
382 fprintf(f, "\n\t");
383
384 if (offsets[i] == GP_NOGLYPH)
385 fprintf(f, "GP_NOGLYPH,");
386 else
387 fprintf(f, " 0x%04x,", offsets[i]);
388
389 if (i % 8 != 7)
390 fprintf(f, " ");
391 }
392
393 fprintf(f, "\n};\n\n");
394}
395
396static void emit_face(FILE *f, struct gpf_font *font, enum gpf_variant_id id,
397 const char *font_id, const int *tables,
398 const enum gpf_variant_id *owners)
399{
400 struct gpf_family_meta *m = &font->meta;
401 struct gpf_variant *variant = font->variants[id];
402 int mono = (id == GPF_MONO || id == GPF_BOLD_MONO);
403 int bold = (id == GPF_BOLD || id == GPF_BOLD_MONO);
404 unsigned int max_width = 0, max_advance = 0, cnt = 0, i;
405 uint32_t code;
406 char name[128];
407
408 (void)variant;
409
410 for (i = 0; ranges[i].max; i++) {
411 if (!tables[i])
412 continue;
413
414 cnt++;
415
416 for (code = ranges[i].min; code <= ranges[i].max; code++) {
417 struct gpf_resolved res;
418 unsigned int width;
419
420 if (gpf_resolve(font, id, code, &res))
421 continue;
422
423 width = res.glyph.bearing_x + res.glyph.width;
424
425 if (width > max_width)
426 max_width = width;
427
428 if ((unsigned int)res.glyph.advance > max_advance)
429 max_advance = res.glyph.advance;
430
431 gpf_resolved_clear(&res);
432 }
433 }
434
435 fprintf(f, "static struct gp_font_face %s = {\n", var_id(id));
436
437 if (id == GPF_MONO)
438 fprintf(f, "\t.family_name = \"%s\",\n", font_id);
439 else
440 fprintf(f, "\t.family_name = \"%s_%s\",\n", font_id, var_id(id) + 5);
441
442 fprintf(f, "\t.style = %s%s,\n", mono ? "GP_FONT_MONO" : "GP_FONT_REGULAR",
443 bold ? " | GP_FONT_BOLD" : "");
444
445 fprintf(f, "\t.ascent = %i,\n", m->ascent);
446 fprintf(f, "\t.descent = %i,\n", m->descent);
447 fprintf(f, "\t.max_glyph_width = %u,\n", max_width);
448 fprintf(f, "\t.max_glyph_advance = %u,\n", max_advance);
449
450 if (m->em)
451 fprintf(f, "\t.em = %i,\n", m->em);
452 if (m->x_height)
453 fprintf(f, "\t.x_height = %i,\n", m->x_height);
454 if (m->cap_height)
455 fprintf(f, "\t.cap_height = %i,\n", m->cap_height);
456 if (m->ch_width)
457 fprintf(f, "\t.ch_width = %i,\n", m->ch_width);
458 if (m->line_gap)
459 fprintf(f, "\t.line_gap = %i,\n", m->line_gap);
460 if (m->underline_pos)
461 fprintf(f, "\t.underline_pos = %i,\n", m->underline_pos);
462 if (m->underline_thickness)
463 fprintf(f, "\t.underline_thickness = %i,\n", m->underline_thickness);
464 if (m->strike_pos)
465 fprintf(f, "\t.strike_pos = %i,\n", m->strike_pos);
466 if (m->strike_thickness)
467 fprintf(f, "\t.strike_thickness = %i,\n", m->strike_thickness);
468 if (m->overline_pos)
469 fprintf(f, "\t.overline_pos = %i,\n", m->overline_pos);
470 if (m->overline_thickness)
471 fprintf(f, "\t.overline_thickness = %i,\n", m->overline_thickness);
472
473 fprintf(f, "\t.glyph_bitmap_format = GP_FONT_BITMAP_1BPP,\n");
474 fprintf(f, "\t.glyph_tables = %u,\n", cnt);
475 fprintf(f, "\t.glyphs = {\n");
476
477 for (i = 0; ranges[i].max; i++) {
478 if (!tables[i])
479 continue;
480
481 fprintf(f, "\t\t{\n");
482
483 fprintf(f, "\t\t\t.glyphs = %s_glyphs,\n", var_id(GPF_MONO));
484
485 sym(name, sizeof(name), owners[i], &ranges[i], "offsets");
486 fprintf(f, "\t\t\t.offsets = %s,\n", name);
487
488 fprintf(f, "\t\t\t.min_glyph = 0x%04x,\n", ranges[i].min);
489 fprintf(f, "\t\t\t.max_glyph = 0x%04x,\n", ranges[i].max);
490 fprintf(f, "\t\t},\n");
491 }
492
493 fprintf(f, "\t}\n};\n\n");
494}
495
496/*
497 * Which faces are worth emitting. The monospace pair always is — a bold that
498 * nobody drew is the emboldened one, which is what the compiled in fonts have
499 * had all along. The proportional pair only when the font really has a
500 * proportional variant, or `regular` would be a second copy of `mono`.
501 */
502static int face_wanted(struct gpf_font *font, enum gpf_variant_id id)
503{
504 if (id == GPF_MONO || id == GPF_BOLD_MONO)
505 return 1;
506
507 return !!font->variants[GPF_REGULAR] || !!font->variants[id];
508}
509
510/* what the export leaves behind, which is worth knowing */
511static void count_dropped(struct gpf_font *font, unsigned int *kept,
512 unsigned int *dropped)
513{
514 uint32_t *codes = gpf_font_codes(font);
515 size_t i;
516 unsigned int j;
517
518 if (!codes)
519 return;
520
521 for (i = 0; i < gp_vec_len(codes); i++) {
522 int in = 0;
523
524 for (j = 0; ranges[j].max; j++) {
525 if (codes[i] >= ranges[j].min && codes[i] <= ranges[j].max)
526 in = 1;
527 }
528
529 if (in)
530 (*kept)++;
531 else
532 (*dropped)++;
533 }
534
535 gp_vec_free(codes);
536}
537
538int gpf_export_c(struct gpf_font *font, const char *font_id, const char *name,
539 FILE *f, char *err, size_t err_len)
540{
541 int tables[GPF_VARIANTS][16] = {};
542 gp_glyph_offset *offsets[GPF_VARIANTS][16] = {};
543 enum gpf_variant_id owners[GPF_VARIANTS][16] = {};
544 struct glyph_store store = {
545 .data = gp_vec_new(0, 1),
546 .starts = gp_vec_new(0, sizeof(size_t)),
547 .refs = gp_vec_new(0, sizeof(struct glyph_ref *)),
548 };
549 char blocks[512] = "";
550 unsigned int kept = 0, dropped = 0;
551 unsigned int id, i;
552 int faces = 0, ret = 1;
553
554 if (!font->variants[GPF_MONO]) {
555 snprintf(err, err_len, "the font has no mono variant to export");
556 goto out;
557 }
558
559 if (!store.data || !store.starts || !store.refs)
560 goto oom;
561
562 if (font->meta.license[0])
563 fprintf(f, "// SPDX-License-Identifier: %s\n", font->meta.license);
564
565 if (font->authors) {
566 fprintf(f, "/*\n");
567 for (i = 0; i < gp_vec_len(font->authors); i++) {
568 fprintf(f, " * Copyright (C) %s %s <%s>\n",
569 font->authors[i].years,
570 font->authors[i].name,
571 font->authors[i].email);
572 }
573 fprintf(f, " */\n");
574 }
575
576 fprintf(f, "/* Generated file, do not touch */\n\n");
577 fprintf(f, "#include <text/gp_font.h>\n\n");
578
579 for (id = 0; id < GPF_VARIANTS; id++) {
580 if (!face_wanted(font, id))
581 continue;
582
583 if (variant_offsets(font, id, &store, tables[id], offsets[id]))
584 goto oom;
585 }
586
587 emit_glyphs(f, &store);
588
589 for (id = 0; id < GPF_VARIANTS; id++) {
590 for (i = 0; ranges[i].max; i++) {
591 if (!tables[id][i])
592 continue;
593
594 owners[id][i] = offsets_owner(tables, offsets, id, i);
595
596 if (owners[id][i] == id)
597 emit_offsets(f, id, &ranges[i], offsets[id][i]);
598 }
599 }
600
601 for (id = 0; id < GPF_VARIANTS; id++) {
602 if (!face_wanted(font, id))
603 continue;
604
605 emit_face(f, font, id, font_id, tables[id], owners[id]);
606
607 faces++;
608 }
609
610 /* the blocks the family has, named the way gfxprim names them */
611 for (i = 0; ranges[i].max; i++) {
612 if (!tables[GPF_MONO][i])
613 continue;
614
615 if (blocks[0])
616 strncat(blocks, " | ", sizeof(blocks) - strlen(blocks) - 1);
617
618 strncat(blocks, ranges[i].ucode, sizeof(blocks) - strlen(blocks) - 1);
619 }
620
621 fprintf(f, "const gp_font_family __attribute__((visibility (\"hidden\")))"
622 " font_family_%s = {\n", font_id);
623 fprintf(f, "\t.family_name = \"%s\",\n", name);
624 fprintf(f, "\t.ucode_blocks = %s,\n", blocks);
625 fprintf(f, "\t.fonts = {\n");
626
627 for (id = 0; id < GPF_VARIANTS; id++) {
628 if (!face_wanted(font, id))
629 continue;
630
631 fprintf(f, "\t\t&%s,\n", var_id(id));
632 }
633
634 fprintf(f, "\t\tNULL\n\t}\n};\n");
635
636 count_dropped(font, &kept, &dropped);
637
638 fprintf(stderr, "%s: %u glyphs, %u faces", name, kept, faces);
639
640 if (dropped) {
641 fprintf(stderr, ", %u outside the exported ranges dropped",
642 dropped);
643 }
644
645 fprintf(stderr, "\n");
646
647 ret = faces ? 0 : 1;
648 goto out;
649oom:
650 snprintf(err, err_len, "out of memory");
651out:
652 for (id = 0; id < GPF_VARIANTS; id++) {
653 for (i = 0; ranges[i].max; i++)
654 free(offsets[id][i]);
655 }
656
657 for (i = 0; store.refs && i < gp_vec_len(store.refs); i++)
658 gp_vec_free(store.refs[i]);
659
660 gp_vec_free(store.refs);
661 gp_vec_free(store.starts);
662 gp_vec_free(store.data);
663 return ret;
664}
static int gpf_glyph_pixel(const struct gpf_glyph *self, unsigned int x, unsigned int y)
Returns a glyph ink pixel.
Definition font.h:623
gpf_variant_id
Font face variant.
Definition font.h:34
@ GPF_BOLD_MONO
Bold monospace glyphs.
Definition font.h:40
@ GPF_VARIANTS
Number of font variants.
Definition font.h:44
@ GPF_MONO
Monospace glyphs, the base variant.
Definition font.h:36
@ GPF_BOLD
Bold glyphs.
Definition font.h:42
@ GPF_REGULAR
Proportional glyphs, "regular" on disk.
Definition font.h:38
The gfxprim C font export.
The glyph variant lattice.
void gpf_resolved_clear(struct gpf_resolved *self)
Clears the resolved glyph.
Definition resolve.c:30
int gpf_resolve(struct gpf_font *font, enum gpf_variant_id id, uint32_t code, struct gpf_resolved *res)
Resolves a glyph variant metric and ink.
Definition resolve.c:521
char years[32]
Copyright years, e.g. "2024", "2019-2024" or "2019,2023".
Definition font.h:220
char email[64]
The author's email, without the angle brackets.
Definition font.h:224
char name[64]
The author's name.
Definition font.h:222
Font family meta data.
Definition font.h:230
int descent
Font descent.
Definition font.h:241
int line_gap
Gap between two lines of text.
Definition font.h:243
int overline_thickness
Overline thickness.
Definition font.h:265
int ch_width
The advance of the digit zero.
Definition font.h:252
int overline_pos
Overline position.
Definition font.h:263
char license[64]
SPDX license name.
Definition font.h:234
int cap_height
Capital letter height.
Definition font.h:250
int x_height
The x-height.
Definition font.h:248
int strike_thickness
Strikethrough thickness.
Definition font.h:261
int em
Em size.
Definition font.h:246
int ascent
Font ascent.
Definition font.h:239
int strike_pos
Strikethrough position.
Definition font.h:259
int underline_thickness
Underline thickness.
Definition font.h:257
int underline_pos
Underline position.
Definition font.h:255
A font family.
Definition font.h:274
struct gpf_author * authors
Font authors.
Definition font.h:298
struct gpf_variant * variants[GPF_VARIANTS]
Variants indexed by gpf_variant_id, NULL when missing.
Definition font.h:301
struct gpf_family_meta meta
Font meta data.
Definition font.h:276
A glyph.
Definition font.h:80
int bearing_y
Glyph bearing y.
Definition font.h:128
unsigned int height
Glyph ink height.
Definition font.h:137
unsigned int width
Glyph ink width.
Definition font.h:133
int advance
Glyph advance.
Definition font.h:116
int bearing_x
Glyph bearing x.
Definition font.h:122
A resolved glyph and where it was drawn from.
Definition resolve.h:36
struct gpf_glyph glyph
Freshly allocated glyph with copied/generated ink.
Definition resolve.h:42
A font variant.
Definition font.h:170
enum gpf_variant_id id
Font variant e.g. GPF_REGULAR, GPF_MONO, etc.
Definition font.h:172