Page 1 of 1

Why is wxFontInfo incomplete ?

Posted: Thu Dec 01, 2016 5:42 pm
by richrobin
Why are the "m_pointSize" and "m_pixelSize" fields of wxFontInfo made inaccessible by being declared private and then not giving a public access function to set them? I am porting a windows program to Linux and wish to use wxFontInfo in place of the Windows LOGFONT structure. Both these classes are just storing information for creating fonts so why not allow alteration of point size after creation of the wxFontInfo class? The program I am porting stores LOGFONT structures in a database and updates the size of the font just before the structure is used to create the font to be used for drawing on the Device Context. Is there a reason for not allowing access to "m_pointSize" and "m_pixelSize" or is this just an oversight? Also "AllFlags" will set the flags register "m_flags" but there is no simple way of "Getting" the flags register. I am using version 3.02 of wxWidgets.

Re: Why is wxFontInfo incomplete ?

Posted: Thu Dec 01, 2016 6:39 pm
by doublemax
wxFontInfo doesn't have reading access to any parameter, so how do you get the data out in order to put it into a database.

You could also try wxFont::GetNativeFontInfoDesc(). It's platform-specific but should serve your purpose. You just have to try out once where the font size is stored.

Re: Why is wxFontInfo incomplete ?

Posted: Thu Dec 01, 2016 6:42 pm
by DenDev
wxFontInfo is just a helper class which can be used to more convenient (or read friendly) font creation, like this:

Code: Select all

wxFont f = new wxFont(wxFontInfo(18).Bold().Underlined().FaceName("Helvetica"));
You cannot access the private fields because they are only temporary storage for parameters. The functionality you need is available in wxFont: http://docs.wxwidgets.org/3.1/classwx_font.html

My suggestion is that you create your own wxFont* wxFontFromLOGFONT(LOGFONT *lf) method :)