How do I change the font in my c++ windows console app? It doesn't seem to use the font cmd.exe uses by default(Lucida Console). When i run my app through an existing cmd.exe (typing name.exe) it looks like this: http://dathui.mine.nu/konsol3.png which is entierly correct. But when i run my app seperatly(double-click the .exe) it looks like this: http://dathui.mine.nu/konsol2.png. Same code, two different looks.
So now I wonder how i can change the font so it always looks correctly regardless of how it's run.
EDIT: Ok, some more information. When i just use this little snippet:
SetConsoleOutputCP(CP_UTF8);
wchar_t s[] = L"èéøÞǽлљΣæča";
int bufferSize = WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, NULL, NULL);
char* m = new char[bufferSize];
WideCharToMultiByte(CP_UTF8, 0, s, -1, m, bufferSize, NULL, NULL);
wprintf(L"%S", m);
it works with the correct font. But in my real application I use WriteConsoleOutput to print strings instead;
CHAR_INFO* info = new CHAR_INFO[mWidth * mHeight];
for(unsigned int a = 0; a < mWidth*mHeight; ++a) {
info[a].Char.UnicodeChar = mWorld.getSymbol(mWorldX + (a % mWidth), mWorldY + (a / mWidth));
info[a].Attributes = mWorld.getColour(mWorldX + (a % mWidth), mWorldY + (a / mWidth));
}
COORD zero;
zero.X = zero.Y = 0;
COORD buffSize;
buffSize.X = mWidth;
buffSize.Y = mHeight;
if(!WriteConsoleOutputW(window, info, buffSize, zero, &rect)) {
exit(-1);
}
and then it uses the wrong font. I use two different windows, created like this
mHandleA = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
Might i be setting the codepage for just the standard output or something?