Example #1
1
void Window::changeFont(int x, int y){
	CONSOLE_FONT_INFOEX fontInfo = { sizeof (CONSOLE_FONT_INFOEX) };
	bool value = GetCurrentConsoleFontEx(wHnd, 0, &fontInfo);
	fontInfo.dwFontSize.X = x;
	fontInfo.dwFontSize.Y = y;
	bool value2 = SetCurrentConsoleFontEx(wHnd, 0, &fontInfo);
}
Example #2
0
void WindowManager::setup() {
	//Set console font
	CONSOLE_FONT_INFOEX lpConsoleCurrentFontEx;
	lpConsoleCurrentFontEx.cbSize = sizeof(CONSOLE_FONT_INFOEX);
	lpConsoleCurrentFontEx.dwFontSize.X = 12;
	lpConsoleCurrentFontEx.dwFontSize.Y = 12;
	lpConsoleCurrentFontEx.FontWeight = 700;
	lpConsoleCurrentFontEx.nFont = 1;
	lpConsoleCurrentFontEx.FontFamily = FF_DONTCARE;
	lstrcpyW(lpConsoleCurrentFontEx.FaceName, L"Lucida Console");
	SetCurrentConsoleFontEx ( GetStdHandle(STD_OUTPUT_HANDLE), false, &lpConsoleCurrentFontEx );
	
	//get handles and create screen buffers
	mStdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
	mConsoleA = Console::createConsoleOutput();
	mConsoleB = Console::createConsoleOutput();
	mSwitch = true;

	CONSOLE_SCREEN_BUFFER_INFO info;
	if (GetConsoleScreenBufferInfo(mStdHandle, &info) != 0) {
		mCurrentSize.X = (info.srWindow.Right - info.srWindow.Left) + 1;
		mCurrentSize.Y = (info.srWindow.Bottom - info.srWindow.Top) + 1;
	} else {
		mCurrentSize.X = 80;
		mCurrentSize.Y = 25;
	}

	//get current codepage and set new one, unicode
	mOldCodePage = GetConsoleOutputCP();
	SetConsoleOutputCP(CP_UTF8);
}
Example #3
0
// usar esta de preferência a não ser que se esteja no XP ou anterior
void Consola::setTextSize(int x, int y) {
	CONSOLE_FONT_INFOEX cfont;

	cfont.cbSize=sizeof(CONSOLE_FONT_INFOEX);

	GetCurrentConsoleFontEx(hconsola, false, & cfont);
	cfont.dwFontSize.X = x;
	cfont.dwFontSize.Y = y;
	SetCurrentConsoleFontEx(hconsola, false, &cfont);
}
Example #4
0
void Console::setConsoleFont(SHORT width, SHORT height, LPCWSTR lpcwFontName)
{
    CONSOLE_FONT_INFOEX cfi;
    cfi.cbSize = sizeof cfi;
    cfi.nFont = 0;
    cfi.dwFontSize.X = width;
    cfi.dwFontSize.Y = height;
    cfi.FontFamily = FF_DONTCARE;
    cfi.FontWeight = FW_NORMAL;
    wcscpy_s(cfi.FaceName, lpcwFontName);
    SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
}
Example #5
0
JNIEXPORT void JNICALL Java_com_yifanlu_Josh_Josh_SETCURRENTCONSOLEFONTEX
  (JNIEnv *env, jclass jcls, jlong pointer, jboolean maximum, jint font, jint sizeX, jint sizeY)
{
    HANDLE hConsole = pointerToHandle(pointer);
	CONSOLE_FONT_INFOEX extendedInfo;
	GetCurrentConsoleFontEx(hConsole, (maximum ? TRUE : FALSE), &extendedInfo);
	
	extendedInfo.nFont = font;
	extendedInfo.dwFontSize.X = sizeX;
	extendedInfo.dwFontSize.Y = sizeY;

	SetCurrentConsoleFontEx(hConsole, (maximum ? TRUE : FALSE), &extendedInfo);
}
/**
* @brief (Only for Windows and for newer WINAPI) Sets the Console font size to the defined FontSize_X and FontSize_Y
* @param [in] FontSize defined font size informations
*/
void SetConsoleFont(SIZES FontSize) {
#if !defined(WINXP) && !defined(BASIGMINGW) /* Minimum supported client: Windows Vista */
    HANDLE outcon;
    CONSOLE_FONT_INFOEX font;

    outcon = GetStdHandle(STD_OUTPUT_HANDLE);      /* Getting windows console standard handler */
    font = {sizeof(CONSOLE_FONT_INFOEX)};          /* CONSOLE_FONT_INFOEX is defined in some windows header */
    GetCurrentConsoleFontEx(outcon, false, &font); /* Getting current font settings */
    font.FontFamily = 54;       /* Lucida console font */
    font.dwFontSize.X = FontSize.X;
    font.dwFontSize.Y = FontSize.Y;
    SetCurrentConsoleFontEx(outcon, false, &font); /* Setting font settings */
#endif /* WINXP, BASIGMINGW */
}
Example #7
0
void setFontSize(int x, int y)
{
    HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_FONT_INFOEX conFont = {0};
    conFont.cbSize = sizeof(CONSOLE_FONT_INFOEX);
    BOOL i = GetCurrentConsoleFontEx(hConsole,0,&conFont);
    if(!i)
        return GetLastError();
    conFont.dwFontSize.Y = y;
    conFont.dwFontSize.X = x;
    conFont.FontWeight = 100;
    conFont.FontFamily = FF_ROMAN;
    i = SetCurrentConsoleFontEx(hConsole, 0, &conFont);
    if(!i)
        return GetLastError();
}
Example #8
0
void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message)
{

	#ifdef _WINDOWS
		HANDLE  console_handle;
		console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
		CONSOLE_FONT_INFOEX info = { 0 };
		info.cbSize = sizeof(info);
		info.dwFontSize.Y = 12; // leave X as zero
		info.FontWeight = FW_NORMAL;
		wcscpy(info.FaceName, L"Lucida Console");
		SetCurrentConsoleFontEx(console_handle, NULL, &info);
		SetConsoleTextAttribute(console_handle, EQEmuLogSys::GetWindowsConsoleColorFromCategory(log_category));
		std::cout << message << "\n";
		SetConsoleTextAttribute(console_handle, Console::Color::White);
	#else
		std::cout << EQEmuLogSys::GetLinuxConsoleColorFromCategory(log_category) << message << LC_RESET << std::endl;
	#endif
}
Example #9
0
Window::Window(int pwidth, int pheight)
{
	height = pheight;
	width = pwidth;

	// Setup the handles
	outHnd = GetStdHandle(STD_OUTPUT_HANDLE);
	inHnd = GetStdHandle(STD_INPUT_HANDLE);

	// Set console window size
	COORD bufferSize = {pwidth, pheight};
	SMALL_RECT windowSize = {0, 0, pwidth-1, pheight-1};
	
	// set the size of the CONSOLE_FONT_INFOEX
	CONSOLE_FONT_INFOEX font;
	font.cbSize = sizeof(CONSOLE_FONT_INFOEX);
	GetCurrentConsoleFontEx(outHnd, false, &font); // Get current size
 
	// set size to be 3x5; 5x8; 6x12; 8x16; 8x18; 10x20;
	font.dwFontSize.X = 8;
	font.dwFontSize.Y = 16;
	 
	// Set the info for hiding the flashing cursor
	CONSOLE_CURSOR_INFO cursor;
	cursor.bVisible = 0;
	cursor.dwSize = sizeof(CONSOLE_CURSOR_INFO); // Get current size
	
	// Submit the settings
	SetConsoleTitle(TEXT("Adventure CMD!"));
	SetConsoleWindowInfo(outHnd, TRUE, &windowSize);
	SetConsoleScreenBufferSize(outHnd, bufferSize);
	SetCurrentConsoleFontEx(outHnd, false, &font);
	SetConsoleCursorInfo(outHnd, &cursor);
	srand(time(0));

}
Example #10
0
void ErrorLog::Log(eqLogType type, const char *message, ...)
{
	if(type >= _log_largest_type)
	{
		return;
	}

	va_list argptr;
	char *buffer = new char[4096];
	va_start(argptr, message);
	vsnprintf(buffer, 4096, message, argptr);
	va_end(argptr);

	time_t m_clock;
	struct tm *m_time;
	time(&m_clock);
	m_time = localtime(&m_clock);

	log_mutex->lock();

#ifdef _WINDOWS
	//system("color 0F");
	HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
	WORD color = WHITE;

	if (type == log_debug)			{ color = LIGHTGRAY; }
	if (type == log_error)			{ color = RED; }
	if (type == log_database)		{ color = LIGHTGREEN; }
	if (type == log_database_trace)	{ color = GREEN; }
	if (type == log_database_error)	{ color = LIGHTRED; }
	if (type == log_network)		{ color = YELLOW; }
	if (type == log_network_trace)	{ color = LIGHTBLUE; }
	if (type == log_network_error)	{ color = LIGHTRED; }
	if (type == log_world)			{ color = YELLOW; }
	if (type == log_world_trace)	{ color = LIGHTBLUE; }
	if (type == log_world_error)	{ color = LIGHTRED; }
	if (type == log_client)			{ color = YELLOW; }
	if (type == log_client_trace)	{ color = LIGHTBLUE; }
	if (type == log_client_error)	{ color = LIGHTRED; }

	std::string eqLogConsoleFormat = std::string(eqLogTypes[type]);
	std::string addspace = " ";

	while (eqLogConsoleFormat.length() < 14)
	{
		eqLogConsoleFormat += addspace;
	}

	CONSOLE_FONT_INFOEX info = { 0 };
	info.cbSize = sizeof(info);
	info.dwFontSize.Y = 12; // leave X as zero
	info.FontWeight = FW_NORMAL;
	wcscpy(info.FaceName, L"Lucida Console");
	SetCurrentConsoleFontEx(hStdOut, NULL, &info);
	SetConsoleTextAttribute(hStdOut, color);
	printf("[ %s ][ %02d.%02d.%02d - %02d:%02d:%02d ] %s\n",
		eqLogConsoleFormat.c_str(),
		m_time->tm_mon + 1,
		m_time->tm_mday,
		m_time->tm_year % 100,
		m_time->tm_hour,
		m_time->tm_min,
		m_time->tm_sec,
		buffer);
	SetConsoleTextAttribute(hStdOut, color);
#else

	printf("[ %s ][ %02d.%02d.%02d - %02d:%02d:%02d ] %s\n",
		eqLogTypes[type],
		m_time->tm_mon+1,
		m_time->tm_mday,
		m_time->tm_year%100,
		m_time->tm_hour,
		m_time->tm_min,
		m_time->tm_sec,
		buffer);
#endif

	if(error_log)
	{
		fprintf(error_log, "[ %s ] [ %02d.%02d.%02d - %02d:%02d:%02d ] %s\n",
			eqLogTypes[type],
			m_time->tm_mon+1,
			m_time->tm_mday,
			m_time->tm_year%100,
			m_time->tm_hour,
			m_time->tm_min,
			m_time->tm_sec,
			buffer);
		fflush(error_log);
	}

	log_mutex->unlock();
	delete[] buffer;
}
Example #11
0
// ----------------------------------------------------------------------------
int main () {
  
  LPGetNumberOfConsoleFonts   GetNumberOfConsoleFonts;
  HMODULE                     hmod;
  HANDLE                      OutConsole;
  static CONSOLE_FONT_INFOEX  font;
  static CONSOLE_FONT_INFOEX  newfont;
  unsigned int                OldCode=0;
  // Permet, en mode debug, dans la fenêtre Variables and Call Stack de CVI, de vérifier qu'en hexa les 'é' sont bine codés 'xE9' ce qui en codepage 850 correspond à 'Ú'
  char                        str[] = "Bel été et je dépense mes €";

  // évite un warning à la compile
  str[0]=str[0];
  
  // ----------------------------------------------------------------------------
  // http://blogs.msdn.com/b/michkap/archive/2011/09/22/10215125.aspx
  OutConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  
  // ATTENTION : penser à bien initialiser lea taille de la structure
  font.cbSize = sizeof(CONSOLE_FONT_INFOEX);
  GetCurrentConsoleFontEx(OutConsole, 0, &font);
  
  if ((font.FontFamily & TMPF_TRUETYPE) == TMPF_TRUETYPE) {
    puts("La console utilise une police TrueType.");
  }else{
    puts("La console n'utilise pas une police TrueType.");
  }
  
  // GetNumberOfConsoleFonts() is a Win SDK undocumented function
  hmod = GetModuleHandleA("KERNEL32.DLL");
  GetNumberOfConsoleFonts = (LPGetNumberOfConsoleFonts)GetProcAddress(hmod, "GetNumberOfConsoleFonts");   
  if (!hmod || !GetNumberOfConsoleFonts){
    FreeLibrary(hmod);
    puts("Y a un problème!"); 
    puts("Strike ENTER to exit :");
    getchar();
  }else{
    printf("Il y a %d polices pour la console\n", GetNumberOfConsoleFonts());
  }
  
  // http://fr.wikipedia.org/wiki/Page_de_code_850
  OldCode = GetConsoleOutputCP();
  printf("Le code page courant est : %d\n", OldCode);
  
  puts("Strike ENTER to continue :");
  getchar();
  
  // ----------------------------------------------------------------------------
  // http://support.microsoft.com/kb/99795/en-us
  // Si on met une font TT type Consolas ou Lucida Console ça passe
  puts("****   Affichage simple : Bel été  et je dépense mes €");  
  
  puts("Strike ENTER to continue :");
  getchar();
  
  // ----------------------------------------------------------------------------
  // é = 130 en dec et 0x82 en hexa
  // il n'y a pas de code pour le caractère '€' 
  // http://fr.wikipedia.org/wiki/Page_de_code_850
  puts("****   Affichage avec des code hexa : Bel \x82t\x82.");
  puts("ATTENTION : pas de code hexa pour le caract\x8Are \"euro\""); 
  
  puts("Strike ENTER to continue :");
  getchar();
  
  // ----------------------------------------------------------------------------
  // http://fr.wikipedia.org/wiki/Windows-1252    
  puts("On tente de passer en code page 1252");
  // http://support.microsoft.com/kb/99795/en-us
  // SetConsoleOutputCP does not effect the displaying of extended characters of the console font named "Raster Font."
  SetConsoleOutputCP(1252); 
  printf("Le code page courant est : %d\n", GetConsoleOutputCP());   
  
  puts("");    
  puts("****   Affichage en 1252 : Bel été et je dépense mes €");
  puts("ATTENTION : les caractères accentués n'apparaissent correctement qu'avec une police TrueType");  
  
  puts("Strike ENTER to continue :");
  getchar();
  
  // ----------------------------------------------------------------------------
  // http://msdn.microsoft.com/en-us/library/system.console.aspx
  puts("On force la police en mode TrueType");
  
  newfont.cbSize = sizeof(CONSOLE_FONT_INFOEX);     
  newfont.FontFamily = TMPF_TRUETYPE; 
  mbstowcs(newfont.FaceName, "Lucida Console", 100);
  // Faut bien initialiser X et Y
  newfont.dwFontSize.Y = font.dwFontSize.Y;
  newfont.dwFontSize.X = font.dwFontSize.X;
  newfont.FontWeight = font.FontWeight;  
  SetCurrentConsoleFontEx(OutConsole, 0, &newfont);
  
  GetNumberOfConsoleFonts = (LPGetNumberOfConsoleFonts)GetProcAddress(hmod, "GetNumberOfConsoleFonts");  
  printf("Il y a dorénavant %d polices pour la console\n", GetNumberOfConsoleFonts());         
  
  puts("Strike ENTER to continue :");
  getchar();
  
  // ----------------------------------------------------------------------------
  puts("");
  puts("****   Affichage 1252 avec la police modifiée : Bel été et je dépense mes €");         
  puts("ATTENTION : si au départ la police n'était pas TrueType, l'affichage en 1252 qui n'était pas correct l'est dorénavant");
  puts("Pensez à jeter un oeil sur les différents type d'affichage précédents et à observer comment ils ont évolués.");
  puts("");
  
  // ----------------------------------------------------------------------------
  SetConsoleOutputCP(850);  
  puts("****   Affichage en 850 avec la police modifiée : Bel été et je dépense mes €");  
  
  // ----------------------------------------------------------------------------
  puts("");
  // Rouge
  SetConsoleTextAttribute(OutConsole, FOREGROUND_RED|FOREGROUND_INTENSITY);
  puts("Strike ENTER to exit :");
  getchar();
  
  // ----------------------------------------------------------------------------
  // Hide the console and set the default parameters back 
  //ShowWindow( GetConsoleWindow(), SW_HIDE);   
  SetConsoleTextAttribute(OutConsole, FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
  SetConsoleOutputCP(OldCode);    
  SetCurrentConsoleFontEx(OutConsole, 0, &font);         
  FreeLibrary(hmod);
  
}