wxFont

From WxWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Official Classes SmallBlocks.png Archive Containers Controls Data Structures Database Date & Time Debug Device Contexts Dialogs Document & Views Drag & Drop Events Filesystem Frames Graphics Grid Cell Help HTML Logging Miscellaneous Networking Printing Sizers Streams Threading Windows

A font is an object which determines the appearance of text.

Fonts are used for drawing text to a device context, and setting the appearance of a window's text, see wxDC::SetFont() and wxWindow::SetFont().

The easiest way to create a custom font is to use wxFontInfo object to specify the font attributes and then use wxFont::wxFont(const wxFontInfo&) constructor. Alternatively, you could start with one of the pre-defined fonts or use wxWindow::GetFont() and modify the font, e.g. by increasing its size using MakeLarger() or changing its weight using MakeBold().

This class uses reference counting and copy-on-write internally so that assignments between two instances of this class are very cheap. You can therefore use actual objects instead of pointers without efficiency problems. If an instance of this class is changed it will create its own data internally so that other instances, which previously shared the data using the reference counting, are not affected.

You can retrieve the current system font settings with wxSystemSettings.

Creating a wxFont based on a X Font Name

      wxNativeFontInfo nativename;
      nativename.FromXFontName("-*-fixed-*-*-*-*-*-*-*-*-*-*-*-*");
      font.SetNativeFontInfo(nativename);

Tested on wxGTK 2.4.0.8 (Debian GNU/Linux) and it does compile (when there is wx/fontutil.h include) but does not work at all.

See Also