+ fprintf(out, "\n};\n\n");
+
+ fprintf(out, "#define GLYPH_WIDTH_MAX %d\n", max_width);
+ fprintf(out, "#define GLYPH_HEIGHT_MAX %d\n", max_height);
+ if (fixed_size) {
+ fprintf(out, "#define GLYPH_WIDTH %d\n", width);
+ fprintf(out, "#define GLYPH_HEIGHT %d\n", height);
+ fprintf(out, "#define GLYPH_ASCENT %d\n", font.ascent);
+ } else {
+ fprintf(out, "static const struct ao_glyph_metrics %s_metrics[%d] = {\n", font_name, dim(pos));
+ for (int i = 0; i < dim(pos); i++) {
+ int g = 0;
+ for (int j = 0; j < dim(font.glyphs); j++) {
+ if (font.glyphs[j].encoding == i) {
+ g = j;
+ break;
+ }
+ }
+ string c;
+ if (' ' <= i && i <= '~')
+ c = sprintf("%c", i);
+ else
+ c = sprintf("%02x", i);
+ fprintf(out, " { .width = %d, .height = %d, .x_off = %d, .y_off = %d, .advance = %d }, /* %s */\n",
+ font.glyphs[g].width, font.glyphs[g].height,
+ font.glyphs[g].x_off, font.glyphs[g].y_off, font.glyphs[g].advance, c);
+ }
+ fprintf(out, "};\n");
+ }
+ fprintf(out, "const struct ao_font %s_font = {\n", font_name);
+ fprintf(out, "\t.bytes = %s_bytes,\n", font_name);
+ fprintf(out, "\t.pos = %s_pos,\n", font_name);
+ if (!fixed_size)
+ fprintf(out, "\t.metrics = %s_metrics,\n", font_name);
+ fprintf(out, "\t.max_width = %d,\n", max_width);
+ fprintf(out, "\t.max_height = %d,\n", max_height);
+ fprintf(out, "\t.ascent = %d,\n", font.ascent);
+ fprintf(out, "};\n");
+}