MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / FontCreate

Function FontCreate

legacy/FontEditor/FontCreate.cpp:351–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349// store font data.
350
351void 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

Callers 1

WinMainFunction · 0.85

Calls 15

bm_AllocLoadFileBitmapFunction · 0.85
ErrorFunction · 0.85
extract_fontFunction · 0.85
bm_FreeBitmapFunction · 0.85
grfont_LoadFunction · 0.85
message_boxFunction · 0.85
FontDoIOFunction · 0.85
ddio_KeyInKeyFunction · 0.85
grtext_SetParametersFunction · 0.85
grtext_SetFontFunction · 0.85
grtext_SetColorFunction · 0.85
grtext_PrintfFunction · 0.85

Tested by

no test coverage detected