Author Topic: Console Font Info  (Read 5344 times)

Offline alizadeh.mehrzad

  • Single posting newcomer
  • *
  • Posts: 3
Console Font Info
« on: November 30, 2016, 08:47:22 pm »
Hi everyone

When I try to use "CONSOLE_FONT_INFOEX" command to change console font, I face a compile error: "CONSOLE_FONT_INFOEX was not declared in this scope." I included "windows.h" header.

Code
#include <windows.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<fstream>
#include <wincon.h>

using namespace std ;


int main()
{
    system("chcp 65001");

    CONSOLE_FONT_INFOEX cfi ;
    cfi.cbSize = sizeof cfi;
    cfi.nFont = 0;
    cfi.dwFontSize.X = 0;
    cfi.dwFontSize.Y = 20;
    cfi.FontFamily = FF_DONTCARE;
    cfi.FontWeight = FW_NORMAL;
    wcscpy(cfi.FaceName, L"Lucida Console");
    SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);

    printf("Hello,  \u0444!\n");
    return 0;
}

I am using Code::Blocks 16 and Windows 10. Could anybody please advise?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Console Font Info
« Reply #1 on: November 30, 2016, 11:41:00 pm »
1) http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

2) you probably use mingw compiler and i think the standard mingw compiler does not have this defined properly: http://lists-archives.com/git/830441-mingw-compat-winansi-c-do-not-redefine-console_font_infoex.html
to solve this you can use mingw64 compiler or search a header where the structure is defined and copy it to your project (and look at the license) (for ex. https://msdn.microsoft.com/de-de/library/windows/desktop/ms682069(v=vs.85).aspx)