+ printf("#define GLYPH_WIDTH_MAX %d\n", max_width);
+ printf("#define GLYPH_HEIGHT_MAX %d\n", max_height);
+ if (fixed_size) {
+ printf("#define GLYPH_WIDTH %d\n", width);
+ printf("#define GLYPH_HEIGHT %d\n", height);
+ printf("#define GLYPH_ASCENT %d\n", font.ascent);
+ } else {
+ printf("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);
+ printf(" { .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);
+ }
+ printf("};\n");
+ }
+ printf("const struct ao_font %s_font = {\n", font_name);
+ printf("\t.bytes = %s_bytes,\n", font_name);
+ printf("\t.pos = %s_pos,\n", font_name);
+ if (!fixed_size)
+ printf("\t.metrics = %s_metrics,\n", font_name);
+ printf("\t.max_width = %d,\n", max_width);
+ printf("\t.max_height = %d,\n", max_height);
+ printf("\t.ascent = %d,\n", font.ascent);
+ printf("};\n");
+}
+
+string
+to_c(string a)
+{
+ string r = "";
+ for (int i = String::rindex(a, "/") + 1; i < String::length(a); i++) {
+ int c = a[i];
+ if (c == '.')
+ break;
+ if (!(Ctype::isalnum(c) || c == '_'))
+ c = '_';
+ r += String::new(c);
+ }
+ if (!Ctype::isalpha(r[0]))
+ r = "_" + r;
+ return r;