Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here some code I scraped together from several sources. Allows me to use codepages, avoids unicode. However, wprintf() etc should work, too.</p> <p>Only consolas and lucida console work sofar. Includes an attempt to get a similar size.</p> <p>Checks include the validitycheck of the nFont index. That may be unneeded, in which case you can leave out the undocumented call to kernel32 routine GetNumberOfConsoleFonts().</p> <p>Hans says it won't work on XP, <a href="http://msdn.microsoft.com/en-us/library/ms686200%28v=vs.85%29.aspx" rel="nofollow">docs</a> say minimum _WIN32_WINNT is 0x500 which would include XP. Haven't tried yet. Jan</p> <pre><code>static void strcpytoW(WCHAR *dst, const char *src) { WCHAR c; while ((c=*src++)!=0) *dst++=c; *dst=0; } /*************************************/ typedef DWORD (WINAPI *FN_NUMCONSOLEFONT)(); FN_NUMCONSOLEFONT GetNumberOfConsoleFonts; static bool setfont(const HANDLE h, char *facename, CONSOLE_FONT_INFOEX &amp;in,CONSOLE_FONT_INFOEX &amp;out) { in.cbSize=out.cbSize=sizeof(in); strcpytoW(in.FaceName,facename); if (!SetCurrentConsoleFontEx(h,FALSE,&amp;in)) return false; HMODULE hm = ::GetModuleHandleA("KERNEL32.DLL"); if (!hm) return false; GetNumberOfConsoleFonts = (FN_NUMCONSOLEFONT) GetProcAddress(hm, "GetNumberOfConsoleFonts"); if (!GetNumberOfConsoleFonts) return false; DWORD numConsoleFonts=GetNumberOfConsoleFonts(); if (!GetCurrentConsoleFontEx(h,FALSE,&amp;out)) return false; return out.nFont&gt;=0 &amp;&amp; out.nFont&lt;numConsoleFonts &amp;&amp; _wcsicmp(in.FaceName,out.FaceName)==0; } /*************************************/ static char *set_console(char *facename,int page) { HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_FONT_INFOEX fi={sizeof(fi),-1,{0,0},54,700},newfi; CONSOLE_FONT_INFO curfi; if (!GetCurrentConsoleFont(hStdout,FALSE,&amp;curfi)) return NULL; for (fi.dwFontSize=curfi.dwFontSize;;fi.dwFontSize.Y++) { if (!setfont(hStdout,facename,fi,newfi)) { facename="Lucida Console"; if (!setfont(hStdout,facename,fi,newfi)) return NULL; } if (newfi.dwFontSize.X&gt;=curfi.dwFontSize.X) break; } if (!SetConsoleOutputCP(page)) return NULL; return facename; } /*************************************/ int main(int argc, char *argv[]) { char *faceused; if ((faceused=set_console("Consolas",1252))!=NULL) printf("Console succesful, using %s\n",faceused); else puts("Console failed"); puts("\x86 \x87 \xa7 \xa9 \xae \xb1 \xbc"); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload