Search code examples
c++codeblockswxwidgets

wxWidgets/C++/Code::Blocks: Failed to import font from system library


I've been making a simple app in C++/wxWidgets that just has a catalog of Garfield comix from the Internet, without the annoying ads and offers. (Don't ask me how I got access to the PNG files of each comic in the first place, because my name already explains that)

Anyway, I'm trying to make a static text with a specific font (in my case, that would be Tahoma size 8. I'm going to make it bold but for sake of simplicity I haven't done it yet). I use the following line of code to import it from the Windows internal font catalog:

wxFont *CC_FONT_Tahoma_Bold(8, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Tahoma"), wxFONTENCODING_DEFAULT);

but whenever I try that it just fails and gives the following error message (I'm using mingw-w64 8.1.0 if that helps):

error: cannot convert 'wxFontEncoding' to 'wxFont*' in initialization

I have no idea what this means and I have tried to change the font encoding to every possible value, but still no progress. Also, I am creating the font in the App's OnInit function. I have also tried to put it in a different function. Please help.


Solution

  • Turns out, I just made a silly mistake. 🤣🤪

    The real code I should have used is:

    wxFont *CC_FONT_Tahoma_Bold = new wxFont(8, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Tahoma"), wxFONTENCODING_DEFAULT);