locked
Console font changes RRS feed

  • Question

  • //top of main console window opens

    //I am trying to use the following to change the font size but it doesn't work

    PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx =

    new CONSOLE_FONT_INFOEX;

      lpConsoleCurrentFontEx->cbSize =

    sizeof(CONSOLE_FONT_INFOEX);

      GetCurrentConsoleFontEx(hStdOut, NULL, lpConsoleCurrentFontEx);

    //retrive all console font informations

    //The font size is X=8, Y=12

    printf("Test line\n   "); //test print

    "Test Line", 10, nL, 0);  //same exact output with this fn

    //I want to change lpConsoleCurrentFontEx->dwFontSize,12, 18
      SetCurrentConsoleFontEx(hStdOut, FALSE, lpConsoleCurrentFontEx);   //.hopefully change the size I tried both TRUE and FALSE

    "\n\nTest line\n");   //test print finds no change at all

       WriteConsoleA(hStdOut,

    "Test Line", 10, nL, 0);  //same with this console fn

      lpConsoleCurrentFontEx->dwFontSize.X=12; 

      lpConsoleCurrentFontEx->dwFontSize.Y=18;

       printf(

      WriteConsoleA(hStdOut,

    Sunday, June 10, 2012 11:33 PM

Answers

  • RossSC wrote:

    see the callGetCurrentConsoleFontEx(hStdOut, NULL,  lpConsoleCurrentFontEx);

    //retrive all console font information

    //inspecting values inlpConsoleCurrentFontEx I see the initial font  size values 8 & 12 pixels//The font size is X=8, Y=12

    printf("Test line\n "); //test print

    //Then I changed them to 12 & 18 and print the test line again, but no  change in the font size

    Just changing the values in the structure doesn't by itself do anything.  Calling SetCurrentConsoleFontEx with the changed values does.


    Igor Tandetnik

    • Proposed as answer by Elegentin Xie Tuesday, June 12, 2012 6:42 AM
    • Marked as answer by Elegentin Xie Friday, June 15, 2012 6:39 AM
    Monday, June 11, 2012 2:11 PM

All replies

  • RossSC wrote:

    /I want to change lpConsoleCurrentFontEx->dwFontSize,12, 18
    SetCurrentConsoleFontEx(hStdOut, FALSE, lpConsoleCurrentFontEx);  /
    .hopefully change the size I tried both TRUE and FALSE

    I don't see you actually change any fields of lpConsoleCurrentFontEx.  You are setting the same font you've just retrieved.


    Igor Tandetnik

    Sunday, June 10, 2012 11:49 PM
  • The initial font size was X=8, Y=12.  I increased them by 50 % but no effect on the text output

    Ross

    Monday, June 11, 2012 12:08 AM
  • RossSC wrote:

    The initial font size was X=8, Y=12. I increased them by 50 %

    I don't see this in the code. How exactly did you do that? I see you  call SetCurrentConsoleFontEx with exactly the same values you got from  GetCurrentConsoleFontEx.


    Igor Tandetnik

    Monday, June 11, 2012 12:23 AM
  • see the call

    GetCurrentConsoleFontEx(hStdOut, NULL, lpConsoleCurrentFontEx);

    //retrive all console font information

    //inspecting values in lpConsoleCurrentFontEx I see the initial font size values 8 & 12 pixels

    //The font size is X=8, Y=12  

     printf("Test line\n   "); //test print

    //Then I changed them to 12 & 18 and print the test line again, but no change in the font size

    I did inspect  lpConsoleCurrentFontEx after the change to be sure the values had been changed to 12 and 18 before the next print test of the font.

    I do appreciate any help you can give me on this issue.  I see in previous threads that others have had the same problem but the threads end with no solution.


    Ross


    • Edited by RossSC Monday, June 11, 2012 2:04 PM
    Monday, June 11, 2012 1:57 PM
  • RossSC wrote:

    see the callGetCurrentConsoleFontEx(hStdOut, NULL,  lpConsoleCurrentFontEx);

    //retrive all console font information

    //inspecting values inlpConsoleCurrentFontEx I see the initial font  size values 8 & 12 pixels//The font size is X=8, Y=12

    printf("Test line\n "); //test print

    //Then I changed them to 12 & 18 and print the test line again, but no  change in the font size

    Just changing the values in the structure doesn't by itself do anything.  Calling SetCurrentConsoleFontEx with the changed values does.


    Igor Tandetnik

    • Proposed as answer by Elegentin Xie Tuesday, June 12, 2012 6:42 AM
    • Marked as answer by Elegentin Xie Friday, June 15, 2012 6:39 AM
    Monday, June 11, 2012 2:11 PM
  • Yes I am sorry I neglected to show this call after changing the dwFontSize values in the snippet of code above

    BOOL success=SetCurrentConsoleFontEx(hStdOut, TRUE, lpConsoleCurrentFontEx);

    executing this line returns TRUE. 

    Also I have these calls at the beginning of main to get correct handles

      hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

      hStdIn = GetStdHandle(STD_INPUT_HANDLE);

    Quite a mystery. I wish someone would write a referrence book on the wincon.h and related fns.  A lot of my projects

    are console apps because the the logic flow is much easier to code for expert systems which I write.


    Ross

    Monday, June 11, 2012 6:43 PM