示例#1
0
/*
 * Initialize our window port.  Of course, there are no arguments but we
 * also initialize the graphics subsystem, here, so we'll be prepared for
 * later.
 */
void nds_init_nhwindows(int *argc, char **argv)
{
  int i;

  system_font = read_bdf("font.bdf");

  if (system_font == NULL) {
    iprintf("Error loading font!\n");

    return;
  }

  if (nds_init_map()) {
    iprintf("Error loading tiles!\n");

    return;
  }

  keysSetRepeat(30, 2);

  for (i = 0; i < MAX_WINDOWS; i++) {
    windows[i] = NULL;
  }

  /* Set up our palettes. */
  BG_PALETTE_SUB[255] = RGB15(31,31,31);

  nds_load_palette("minimap.pal", BG_PALETTE_SUB + 16);

  BG_PALETTE_SUB[C_CURSOR] = RGB15(31,0, 0);

  iflags.window_inited = true;

  /* Get these set up for our windowing routines */

  up_arrow = alloc_ppm(16, 16);
  down_arrow = alloc_ppm(16, 16);
  okay_button = alloc_ppm(16, 16);
  cancel_button = alloc_ppm(16, 16);

  _nds_copy_header_pixels(up_arrow_data, (unsigned char *)up_arrow->bitmap, 
                          MAP_COLOUR(CLR_BLACK), MAP_COLOUR(CLR_WHITE));
  _nds_copy_header_pixels(down_arrow_data, (unsigned char *)down_arrow->bitmap, 
                          MAP_COLOUR(CLR_BLACK), MAP_COLOUR(CLR_WHITE));
  _nds_copy_header_pixels(okay_data, (unsigned char *)okay_button->bitmap, 
                          MAP_COLOUR(CLR_BLACK), MAP_COLOUR(CLR_WHITE));
  _nds_copy_header_pixels(cancel_data, (unsigned char *)cancel_button->bitmap, 
                          MAP_COLOUR(CLR_BLACK), MAP_COLOUR(CLR_WHITE));

  if (nds_init_cmd() < 0) {
    nds_error();
  }

  nds_init_msg();
  font_bdf_init();

  text_dims(system_font, "*", &tag_width, NULL);

  tag_width *= 4;
}
示例#2
0
文件: font.c 项目: 0x6e3078/matelight
glyphtable_t *read_bdf_file(char *filename){
	FILE *fontfile = fopen("unifont.bdf", "r");
	if(!fontfile){
		fprintf(stderr, "Error opening font file: %s\n", strerror(errno));
		goto error;
	}

	glyphtable_t *glyph_table = read_bdf(fontfile);
	if(!glyph_table){
		fprintf(stderr, "Error reading font file.\n");
		goto error;
	}

	fclose(fontfile);
	return glyph_table;
error:
	fclose(fontfile);
	return NULL;
}