#include #include #include #include #include #include #include #include #include static const font_desc * const fonts[] = {&font_vga_8x8, &font_vga_8x16, &font_pearl_8x8, &font_vga_6x11, &font_7x14, &font_10x18, &font_sun_8x16, &font_sun_12x22, &font_acorn_8x8, &font_mini_4x6, &font_6x10, &font_ter_16x32, &font_6x8}; static const char * const mapping[256] = { "NUL", "☺", "☻", "♥", "♦", "♣", "♠", "•", "◘", "○", "◙", "♂", "♀", "♪", "♫", "☼", "►", "◄", "↕", "‼", "¶", "§", "▬", "↨", "↑", "↓", "→", "←", "∟", "↔", "▲", "▼", " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "slash", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "⌂", "Ç", "ü", "é", "â", "ä", "à", "å", "ç", "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å", "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", "ÿ", "Ö", "Ü", "¢", "£", "¥", "₧", "ƒ", "á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", "¿", "⌐", "¬", "½", "¼", "¡", "«", "»", "░", "▒", "▓", "│", "┤", "╡", "╢", "╖", "╕", "╣", "║", "╗", "╝", "╜", "╛", "┐", "└", "┴", "┬", "├", "─", "┼", "╞", "╟", "╚", "╔", "╩", "╦", "╠", "═", "╬", "╧", "╨", "╤", "╥", "╙", "╘", "╒", "╓", "╫", "╪", "┘", "┌", "█", "▄", "▌", "▐", "▀", "α", "ß", "Γ", "π", "Σ", "σ", "µ", "τ", "Φ", "Θ", "Ω", "δ", "∞", "φ", "ε", "∩", "≡", "±", "≥", "≤", "⌠", "⌡", "÷", "≈", "°", "·", "•", "√", "ⁿ", "²", "■", " "}; int main() { char fname[256]; for(auto fp : fonts) { auto && f = *fp; printf("%s: %d %d\n", f.name, f.width, f.height); sprintf(fname, "%s.x-metrics", f.name); FILE * file = fopen(fname, "w"); fprintf(file, "%d %d %d\n", f.height, f.width, /*TODO: baseline*/ 0); fclose(file); sprintf(fname, "%s.x", f.name); mkdir(fname, 0777); chdir(fname); auto cursor = reinterpret_cast(f.data); for(size_t c = 0; c < 256; ++c) { sprintf(fname, "%02zx-%s.blk", c, mapping[c]); file = fopen(fname, "w"); for(size_t r = 0; r < f.height; ++r) { unsigned rowdata = *cursor++; if(f.width > 8) { rowdata <<= 8; rowdata |= *cursor++; rowdata >>= 16 - f.width; } else rowdata >>= 8 - f.width; for(auto col = 1; col <= f.width; ++col) fputs(rowdata & (1 << (f.width - col)) ? "█" : " ", file); fputc('\n', file); } fclose(file); } chdir(".."); } return 1; /* mkdir(fname, 0777); if(chdir(fname)) return fprintf(stderr, "%d %s\n", errno, fname), 1; errno = 0; // int height = strtoul(height_s, NULL, 0); int width = strtoul(width_s, NULL, 0); char * line = NULL; size_t line_s = 0; for(int i = 0; getline(&line, &line_s, stdin) != -1; ++i) { *(line + strlen(line) - 1) = '\0'; char * charname = strchr(line, '#') + 2; if(!strcmp(charname, "/")) charname = "slash"; else if(!strcmp(charname, "M-/")) charname = "M-slash"; *strchr(line, '#') = '\0'; sprintf(fname, "%02x-%s.blk", i, charname); if(!freopen(fname, "w", stdout)) return fprintf(stderr, "%d %s\n", errno, fname), 1; for(char * tok = strtok(strstr(line, "0x"), ", "); tok; tok = strtok(NULL, ", ")) { unsigned row = strtoul(tok, NULL, 0); for(int i = 0; i < width; ++i) { fputs(row & (1 << (width - 1)) ? "█" : " ", stdout); row <<= 1; } putchar('\n'); } } if(errno) fprintf(stderr, "%d\n", errno);*/ }