| 349 | // store font data. |
| 350 | |
| 351 | void FontCreate(const char *fnt_file_source, const char *fnt_file_dest, int min_ascii) { |
| 352 | // import font |
| 353 | FONTFILE ffile; |
| 354 | tFontFileInfo ft; |
| 355 | int bm_handle; |
| 356 | char fontname[32]; |
| 357 | |
| 358 | strcpy(fontname, "d3font"); |
| 359 | |
| 360 | bm_handle = bm_AllocLoadFileBitmap(fnt_file_source, 0, BITMAP_FORMAT_4444); |
| 361 | if (bm_handle < 0) { |
| 362 | Error("Couldn't open %s for extraction.", fnt_file_source); |
| 363 | } |
| 364 | |
| 365 | // Get MinAscii and other needed info before extracting font. |
| 366 | if (!extract_font(bm_handle, &ft)) { |
| 367 | Error("Unable to generate font from %s.", fnt_file_source); |
| 368 | return; |
| 369 | } |
| 370 | |
| 371 | /////////////////////////////////////////////////////////////////////////////// |
| 372 | // Adjust font record for file write. |
| 373 | int num_char; |
| 374 | |
| 375 | ft.kern_data = NULL; |
| 376 | ft.min_ascii = min_ascii; |
| 377 | ft.max_ascii = ft.min_ascii + ft.max_ascii; |
| 378 | |
| 379 | // add newstyle variables here. |
| 380 | ft.flags |= FT_FFI2; |
| 381 | ft.ffi2.tracking = 0; |
| 382 | |
| 383 | // write to file |
| 384 | mprintf(0, "Saving font data..."); |
| 385 | ffile = OPEN_FONT((char *)fnt_file_dest); |
| 386 | if (!ffile) { |
| 387 | Error("Unable to save font %s.", fnt_file_dest); |
| 388 | } |
| 389 | |
| 390 | // Write file id. |
| 391 | WRITE_FONT_INT(ffile, 0xfeedbaba); |
| 392 | |
| 393 | // Write Header |
| 394 | ft.baseline = 0; |
| 395 | |
| 396 | WRITE_FONT_SHORT(ffile, ft.width); |
| 397 | WRITE_FONT_SHORT(ffile, ft.height); |
| 398 | WRITE_FONT_SHORT(ffile, ft.flags); |
| 399 | WRITE_FONT_SHORT(ffile, ft.baseline); |
| 400 | WRITE_FONT_BYTE(ffile, ft.min_ascii); |
| 401 | WRITE_FONT_BYTE(ffile, ft.max_ascii); |
| 402 | WRITE_FONT_DATA(ffile, fontname, 32, 1); |
| 403 | |
| 404 | WRITE_FONT_SHORT(ffile, (int16_t)ft.ffi2.tracking); |
| 405 | WRITE_FONT_DATA(ffile, ft.ffi2.reserved, sizeof(ft.ffi2.reserved), 1); |
| 406 | |
| 407 | num_char = (int)(ft.max_ascii - ft.min_ascii + 1); |
| 408 |
no test coverage detected