Exemple #1
0
static void loadFont(int detectSize)
{
	char font[60];
	
	if (detectSize) {
		int fontWidths[13] = {112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 272, 288, 304}; // widths of the font graphics (divide by 16 to get individual character width)
		int fontHeights[13] = {176, 208, 240, 272, 304, 336, 368, 400, 432, 464, 496, 528, 528}; // heights of the font graphics (divide by 16 to get individual character height)

		const SDL_VideoInfo* vInfo = SDL_GetVideoInfo();
		int screenWidth = desktop_width = vInfo->current_w;
		int screenHeight = desktop_height = vInfo->current_h;

		// adjust for title bars and whatever -- very approximate, but better than the alternative
		screenWidth -= 6;
		screenHeight -= 48;

		if (brogueFontSize < 1 || brogueFontSize > 13) {
			for (
				brogueFontSize = 13;
				brogueFontSize > 1 && (fontWidths[brogueFontSize - 1] * COLS / 16 >= screenWidth || fontHeights[brogueFontSize - 1] * ROWS / 16 >= screenHeight);
				brogueFontSize--
			);
		}

	}

	sprintf(font, "fonts/font-%i.png", brogueFontSize);
	
	TCOD_console_set_custom_font(font, (TCOD_FONT_TYPE_GREYSCALE | TCOD_FONT_LAYOUT_ASCII_INROW), 0, 0);
	TCOD_console_init_root(COLS, ROWS, "Brogue", false, renderer);

	TCOD_console_map_ascii_codes_to_font(0, 255, 0, 0);
	TCOD_console_set_keyboard_repeat(175, 30);

	SDL_WM_SetIcon(SDL_LoadBMP("icon.bmp"), NULL);
}
Exemple #2
0
void TCODConsole::mapAsciiCodesToFont(int firstAsciiCode, int nbCodes, int fontCharX, int fontCharY) {
	TCOD_console_map_ascii_codes_to_font(firstAsciiCode,nbCodes,fontCharX,fontCharY);
}