Changeset 960 for libcaca/trunk/tools/makefont.c
- Timestamp:
- May 18, 2006, 9:56:54 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/tools/makefont.c
r948 r960 34 34 #include <pango/pangoft2.h> 35 35 36 /* Split our big strings into chunks of 480 characters, because it is 37 * the multiple of 32 directly below 509, which is the maximum allowed 38 * string size in C89. */ 39 #define STRING_CHUNKS 480 40 36 41 /* This list is built so that it includes all of ASCII, Latin-1, CP-437, 37 42 * and the UTF-8 glyphs necessary for canvas rotation and mirroring. */ 38 static int const blocklist[] =43 static unsigned int const blocklist[] = 39 44 { 40 45 0x0000, 0x0080, /* Basic latin: A, B, C, a, b, c */ … … 70 75 static int printf_u16(char const *, uint16_t); 71 76 77 /* Counter for written bytes */ 78 static int written = 0; 79 72 80 int main(int argc, char *argv[]) 73 81 { … … 79 87 80 88 FT_Bitmap img; 81 int width, height, b , i, blocks, glyphs;82 unsigned int n, index, glyph_size, control_size, data_size;89 int width, height, blocks, glyphs; 90 unsigned int n, b, i, index, glyph_size, control_size, data_size; 83 91 uint8_t *glyph_data; 84 92 struct glyph *gtab; … … 166 174 printf("static unsigned int const %s_size = %i;\n", 167 175 prefix, 8 + control_size + data_size); 168 printf("static unsigned char const %s_data[] =\n", prefix); 176 printf("static struct {\n"); 177 printf("char "); 178 for(i = 0; (i + 1) * STRING_CHUNKS < 8 + control_size + data_size; i++) 179 printf("d%x[%i],%c", i, STRING_CHUNKS, (i % 6) == 5 ? '\n' : ' '); 180 printf("d%x[%i];\n", i, 8 + control_size + data_size - i * STRING_CHUNKS); 181 printf("} %s_data = {\n", prefix); 182 printf("\n"); 169 183 170 184 printf("/* file: */\n"); 171 185 printf("\"CACA\" /* caca_header */\n"); 186 written += 4; 172 187 printf("\"FONT\" /* caca_file_type */\n"); 188 written += 4; 173 189 printf("\n"); 174 190 … … 291 307 } 292 308 293 printf(" ;\n");309 printf("};\n"); 294 310 295 311 free(img.buffer); … … 414 430 { 415 431 uint8_t ch = *data++; 432 433 if(written == STRING_CHUNKS) 434 { 435 parser += sprintf(parser, "\", \""); 436 written = 0; 437 rewind = 0; 438 } 439 416 440 if(ch == '\\' || ch == '"') 417 441 { … … 431 455 rewind = ch ? 0 : 2; 432 456 } 457 458 written++; 433 459 } 434 460
Note: See TracChangeset
for help on using the changeset viewer.