2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: font.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxFont
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Standard font families: these may be used only for the font creation, it
|
|
|
|
doesn't make sense to query an existing font for its font family as,
|
|
|
|
especially if the font had been created from a native font description, it
|
|
|
|
may be unknown.
|
|
|
|
*/
|
|
|
|
enum wxFontFamily
|
|
|
|
{
|
|
|
|
wxFONTFAMILY_DEFAULT = wxDEFAULT, //!< Chooses a default font.
|
|
|
|
wxFONTFAMILY_DECORATIVE = wxDECORATIVE, //!< A decorative font.
|
|
|
|
wxFONTFAMILY_ROMAN = wxROMAN, //!< A formal, serif font.
|
|
|
|
wxFONTFAMILY_SCRIPT = wxSCRIPT, //!< A handwriting font.
|
|
|
|
wxFONTFAMILY_SWISS = wxSWISS, //!< A sans-serif font.
|
|
|
|
wxFONTFAMILY_MODERN = wxMODERN, //!< A fixed pitch font.
|
|
|
|
wxFONTFAMILY_TELETYPE = wxTELETYPE, //!< A teletype font.
|
|
|
|
wxFONTFAMILY_MAX,
|
|
|
|
wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Font styles.
|
|
|
|
*/
|
|
|
|
enum wxFontStyle
|
|
|
|
{
|
|
|
|
wxFONTSTYLE_NORMAL = wxNORMAL,
|
|
|
|
wxFONTSTYLE_ITALIC = wxITALIC,
|
|
|
|
wxFONTSTYLE_SLANT = wxSLANT,
|
|
|
|
wxFONTSTYLE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Font weights.
|
|
|
|
*/
|
|
|
|
enum wxFontWeight
|
|
|
|
{
|
|
|
|
wxFONTWEIGHT_NORMAL = wxNORMAL, //!< Normal font.
|
|
|
|
wxFONTWEIGHT_LIGHT = wxLIGHT, //!< Light font.
|
|
|
|
wxFONTWEIGHT_BOLD = wxBOLD, //!< Bold font.
|
|
|
|
wxFONTWEIGHT_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
The font flag bits for the new font ctor accepting one combined flags word.
|
|
|
|
*/
|
|
|
|
enum wxFontFlag
|
|
|
|
{
|
|
|
|
/// no special flags: font with default weight/slant/anti-aliasing
|
|
|
|
wxFONTFLAG_DEFAULT = 0,
|
|
|
|
|
|
|
|
/// slant flags (default: no slant)
|
|
|
|
wxFONTFLAG_ITALIC = 1 << 0,
|
|
|
|
wxFONTFLAG_SLANT = 1 << 1,
|
|
|
|
|
|
|
|
/// weight flags (default: medium)
|
|
|
|
wxFONTFLAG_LIGHT = 1 << 2,
|
|
|
|
wxFONTFLAG_BOLD = 1 << 3,
|
|
|
|
|
|
|
|
/// anti-aliasing flag: force on or off (default: the current system default)
|
|
|
|
wxFONTFLAG_ANTIALIASED = 1 << 4,
|
|
|
|
wxFONTFLAG_NOT_ANTIALIASED = 1 << 5,
|
|
|
|
|
|
|
|
/// underlined/strikethrough flags (default: no lines)
|
|
|
|
wxFONTFLAG_UNDERLINED = 1 << 6,
|
|
|
|
wxFONTFLAG_STRIKETHROUGH = 1 << 7,
|
|
|
|
|
|
|
|
/// the mask of all currently used flags
|
|
|
|
wxFONTFLAG_MASK = wxFONTFLAG_ITALIC |
|
|
|
|
wxFONTFLAG_SLANT |
|
|
|
|
wxFONTFLAG_LIGHT |
|
|
|
|
wxFONTFLAG_BOLD |
|
|
|
|
wxFONTFLAG_ANTIALIASED |
|
|
|
|
wxFONTFLAG_NOT_ANTIALIASED |
|
|
|
|
wxFONTFLAG_UNDERLINED |
|
|
|
|
wxFONTFLAG_STRIKETHROUGH
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Font encodings.
|
|
|
|
*/
|
|
|
|
enum wxFontEncoding
|
|
|
|
{
|
|
|
|
/// Default system encoding.
|
|
|
|
wxFONTENCODING_SYSTEM = -1, // system default
|
|
|
|
|
|
|
|
/// Default application encoding.
|
|
|
|
wxFONTENCODING_DEFAULT, // current default encoding
|
|
|
|
|
|
|
|
// ISO8859 standard defines a number of single-byte charsets
|
|
|
|
wxFONTENCODING_ISO8859_1, // West European (Latin1)
|
|
|
|
wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
|
|
|
|
wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
|
|
|
|
wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
|
|
|
|
wxFONTENCODING_ISO8859_5, // Cyrillic
|
|
|
|
wxFONTENCODING_ISO8859_6, // Arabic
|
|
|
|
wxFONTENCODING_ISO8859_7, // Greek
|
|
|
|
wxFONTENCODING_ISO8859_8, // Hebrew
|
|
|
|
wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
|
|
|
|
wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
|
|
|
|
wxFONTENCODING_ISO8859_11, // Thai
|
|
|
|
wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
|
|
|
|
// here anyhow to make all ISO8859
|
|
|
|
// consecutive numbers
|
|
|
|
wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
|
|
|
|
wxFONTENCODING_ISO8859_14, // Latin8
|
|
|
|
wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
|
|
|
|
wxFONTENCODING_ISO8859_MAX,
|
|
|
|
|
|
|
|
// Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
|
|
|
|
wxFONTENCODING_KOI8, // KOI8 Russian
|
|
|
|
wxFONTENCODING_KOI8_U, // KOI8 Ukrainian
|
|
|
|
wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
|
|
|
|
wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
|
|
|
|
|
|
|
|
// what would we do without Microsoft? They have their own encodings
|
|
|
|
// for DOS
|
|
|
|
wxFONTENCODING_CP437, // original MS-DOS codepage
|
|
|
|
wxFONTENCODING_CP850, // CP437 merged with Latin1
|
|
|
|
wxFONTENCODING_CP852, // CP437 merged with Latin2
|
|
|
|
wxFONTENCODING_CP855, // another cyrillic encoding
|
|
|
|
wxFONTENCODING_CP866, // and another one
|
|
|
|
// and for Windows
|
|
|
|
wxFONTENCODING_CP874, // WinThai
|
|
|
|
wxFONTENCODING_CP932, // Japanese (shift-JIS)
|
|
|
|
wxFONTENCODING_CP936, // Chinese simplified (GB)
|
|
|
|
wxFONTENCODING_CP949, // Korean (Hangul charset)
|
|
|
|
wxFONTENCODING_CP950, // Chinese (traditional - Big5)
|
|
|
|
wxFONTENCODING_CP1250, // WinLatin2
|
|
|
|
wxFONTENCODING_CP1251, // WinCyrillic
|
|
|
|
wxFONTENCODING_CP1252, // WinLatin1
|
|
|
|
wxFONTENCODING_CP1253, // WinGreek (8859-7)
|
|
|
|
wxFONTENCODING_CP1254, // WinTurkish
|
|
|
|
wxFONTENCODING_CP1255, // WinHebrew
|
|
|
|
wxFONTENCODING_CP1256, // WinArabic
|
|
|
|
wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
|
|
|
|
wxFONTENCODING_CP12_MAX,
|
|
|
|
|
|
|
|
wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
|
|
|
|
wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
|
|
|
|
wxFONTENCODING_EUC_JP, // Extended Unix Codepage for Japanese
|
|
|
|
wxFONTENCODING_UTF16BE, // UTF-16 Big Endian Unicode encoding
|
|
|
|
wxFONTENCODING_UTF16LE, // UTF-16 Little Endian Unicode encoding
|
|
|
|
wxFONTENCODING_UTF32BE, // UTF-32 Big Endian Unicode encoding
|
|
|
|
wxFONTENCODING_UTF32LE, // UTF-32 Little Endian Unicode encoding
|
|
|
|
|
|
|
|
wxFONTENCODING_MACROMAN, // the standard mac encodings
|
|
|
|
wxFONTENCODING_MACJAPANESE,
|
|
|
|
wxFONTENCODING_MACCHINESETRAD,
|
|
|
|
wxFONTENCODING_MACKOREAN,
|
|
|
|
wxFONTENCODING_MACARABIC,
|
|
|
|
wxFONTENCODING_MACHEBREW,
|
|
|
|
wxFONTENCODING_MACGREEK,
|
|
|
|
wxFONTENCODING_MACCYRILLIC,
|
|
|
|
wxFONTENCODING_MACDEVANAGARI,
|
|
|
|
wxFONTENCODING_MACGURMUKHI,
|
|
|
|
wxFONTENCODING_MACGUJARATI,
|
|
|
|
wxFONTENCODING_MACORIYA,
|
|
|
|
wxFONTENCODING_MACBENGALI,
|
|
|
|
wxFONTENCODING_MACTAMIL,
|
|
|
|
wxFONTENCODING_MACTELUGU,
|
|
|
|
wxFONTENCODING_MACKANNADA,
|
|
|
|
wxFONTENCODING_MACMALAJALAM,
|
|
|
|
wxFONTENCODING_MACSINHALESE,
|
|
|
|
wxFONTENCODING_MACBURMESE,
|
|
|
|
wxFONTENCODING_MACKHMER,
|
|
|
|
wxFONTENCODING_MACTHAI,
|
|
|
|
wxFONTENCODING_MACLAOTIAN,
|
|
|
|
wxFONTENCODING_MACGEORGIAN,
|
|
|
|
wxFONTENCODING_MACARMENIAN,
|
|
|
|
wxFONTENCODING_MACCHINESESIMP,
|
|
|
|
wxFONTENCODING_MACTIBETAN,
|
|
|
|
wxFONTENCODING_MACMONGOLIAN,
|
|
|
|
wxFONTENCODING_MACETHIOPIC,
|
|
|
|
wxFONTENCODING_MACCENTRALEUR,
|
|
|
|
wxFONTENCODING_MACVIATNAMESE,
|
|
|
|
wxFONTENCODING_MACARABICEXT,
|
|
|
|
wxFONTENCODING_MACSYMBOL,
|
|
|
|
wxFONTENCODING_MACDINGBATS,
|
|
|
|
wxFONTENCODING_MACTURKISH,
|
|
|
|
wxFONTENCODING_MACCROATIAN,
|
|
|
|
wxFONTENCODING_MACICELANDIC,
|
|
|
|
wxFONTENCODING_MACROMANIAN,
|
|
|
|
wxFONTENCODING_MACCELTIC,
|
|
|
|
wxFONTENCODING_MACGAELIC,
|
|
|
|
wxFONTENCODING_MACKEYBOARD,
|
|
|
|
|
|
|
|
// more CJK encodings (for historical reasons some are already declared
|
|
|
|
// above)
|
|
|
|
wxFONTENCODING_ISO2022_JP, // ISO-2022-JP JIS encoding
|
|
|
|
|
|
|
|
wxFONTENCODING_MAX, // highest enumerated encoding value
|
|
|
|
|
|
|
|
wxFONTENCODING_MACMIN = wxFONTENCODING_MACROMAN ,
|
|
|
|
wxFONTENCODING_MACMAX = wxFONTENCODING_MACKEYBOARD ,
|
|
|
|
|
|
|
|
// aliases for endian-dependent UTF encodings
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
wxFONTENCODING_UTF16 = wxFONTENCODING_UTF16BE, // native UTF-16
|
|
|
|
wxFONTENCODING_UTF32 = wxFONTENCODING_UTF32BE, // native UTF-32
|
|
|
|
#else // WORDS_BIGENDIAN
|
|
|
|
wxFONTENCODING_UTF16 = wxFONTENCODING_UTF16LE, // native UTF-16
|
|
|
|
wxFONTENCODING_UTF32 = wxFONTENCODING_UTF32LE, // native UTF-32
|
|
|
|
#endif // WORDS_BIGENDIAN
|
|
|
|
|
|
|
|
// alias for the native Unicode encoding on this platform
|
|
|
|
// (this is used by wxEncodingConverter and wxUTFFile only for now)
|
|
|
|
#if SIZEOF_WCHAR_T == 2
|
|
|
|
wxFONTENCODING_UNICODE = wxFONTENCODING_UTF16,
|
|
|
|
#else // SIZEOF_WCHAR_T == 4
|
|
|
|
wxFONTENCODING_UNICODE = wxFONTENCODING_UTF32,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// alternative names for Far Eastern encodings
|
|
|
|
// Chinese
|
|
|
|
wxFONTENCODING_GB2312 = wxFONTENCODING_CP936, // Simplified Chinese
|
|
|
|
wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, // Traditional Chinese
|
|
|
|
|
|
|
|
// Japanese (see http://zsigri.tripod.com/fontboard/cjk/jis.html)
|
|
|
|
wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932 // Shift JIS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFont
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
This class uses @ref overview_refcount "reference counting and copy-on-write"
|
2008-03-08 08:52:38 -05:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
You can retrieve the current system font settings with wxSystemSettings.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{gdi}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@stdobjects
|
2008-04-06 11:28:55 -04:00
|
|
|
::wxNullFont, ::wxNORMAL_FONT, ::wxSMALL_FONT, ::wxITALIC_FONT, ::wxSWISS_FONT
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
@see @ref overview_font, wxDC::SetFont, wxDC::DrawText,
|
|
|
|
wxDC::GetTextExtent, wxFontDialog, wxSystemSettings
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFont : public wxGDIObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
2008-08-30 19:58:45 -04:00
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Default ctor.
|
2008-08-30 19:58:45 -04:00
|
|
|
*/
|
|
|
|
wxFont();
|
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Copy constructor, uses @ref overview_refcount "reference counting".
|
2008-08-30 19:58:45 -04:00
|
|
|
*/
|
|
|
|
wxFont(const wxFont& font);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Creates a font object with the specified attributes.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pointSize
|
2008-03-09 08:33:59 -04:00
|
|
|
Size in points.
|
2008-08-30 19:58:45 -04:00
|
|
|
@param family
|
|
|
|
Font family, a generic way of referring to fonts without specifying actual
|
2008-09-25 15:15:28 -04:00
|
|
|
facename. One of the ::wxFontFamily enumeration values.
|
2008-08-30 19:58:45 -04:00
|
|
|
@param style
|
|
|
|
One of wxFONTSTYLE_NORMAL, wxFONTSTYLE_SLANT and wxFONTSTYLE_ITALIC.
|
|
|
|
@param weight
|
2008-09-25 15:15:28 -04:00
|
|
|
Font weight, sometimes also referred to as font boldness. One of
|
|
|
|
the ::wxFontWeight enumeration values.
|
2008-08-30 19:58:45 -04:00
|
|
|
@param underline
|
2008-09-25 15:15:28 -04:00
|
|
|
The value can be @true or @false.
|
|
|
|
At present this has an effect on Windows and Motif 2.x only.
|
2008-08-30 19:58:45 -04:00
|
|
|
@param faceName
|
2008-09-25 15:15:28 -04:00
|
|
|
An optional string specifying the actual typeface to be used.
|
|
|
|
If it is an empty string, a default typeface will be chosen based on the family.
|
2008-08-30 19:58:45 -04:00
|
|
|
@param encoding
|
2008-09-25 15:15:28 -04:00
|
|
|
An encoding which may be one of the enumeration values of ::wxFontEncoding.
|
|
|
|
Briefly these can be summed up as:
|
|
|
|
<TABLE>
|
|
|
|
<TR><TD>wxFONTENCODING_SYSTEM</TD><TD>Default system encoding.</TD></TR>
|
|
|
|
<TR><TD>wxFONTENCODING_DEFAULT</TD><TD>
|
|
|
|
Default application encoding: this
|
|
|
|
is the encoding set by calls to
|
|
|
|
SetDefaultEncoding and which may be set to,
|
|
|
|
say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the
|
|
|
|
default application encoding is the same as default system encoding.</TD></TR>
|
|
|
|
<TR><TD>wxFONTENCODING_ISO8859_1...15</TD><TD>ISO8859 encodings.</TD></TR>
|
|
|
|
<TR><TD>wxFONTENCODING_KOI8</TD><TD>The standard Russian encoding for Internet.</TD></TR>
|
|
|
|
<TR><TD>wxFONTENCODING_CP1250...1252</TD><TD>Windows encodings similar to ISO8859 (but not identical).</TD></TR>
|
|
|
|
</TABLE>
|
2008-08-30 19:58:45 -04:00
|
|
|
If the specified encoding isn't available, no font is created
|
|
|
|
(see also font encoding overview).
|
|
|
|
|
|
|
|
@remarks If the desired font does not exist, the closest match will be
|
2008-09-25 15:15:28 -04:00
|
|
|
chosen. Under Windows, only scalable TrueType fonts are used.
|
2008-08-30 19:58:45 -04:00
|
|
|
*/
|
|
|
|
wxFont(int pointSize, wxFontFamily family, int style,
|
|
|
|
wxFontWeight weight,
|
|
|
|
const bool underline = false,
|
|
|
|
const wxString& faceName = "",
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
2008-09-25 15:15:28 -04:00
|
|
|
|
2008-08-30 19:58:45 -04:00
|
|
|
/**
|
|
|
|
Creates a font object with the specified attributes.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pixelSize
|
2008-09-25 15:15:28 -04:00
|
|
|
Size in pixels: this is directly supported only under MSW currently
|
|
|
|
where this constructor can be used directly, under other platforms a
|
|
|
|
font with the closest size to the given one is found using binary search
|
|
|
|
and the static New method must be used.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param family
|
2008-03-09 08:33:59 -04:00
|
|
|
Font family, a generic way of referring to fonts without specifying actual
|
2008-09-25 15:15:28 -04:00
|
|
|
facename. One of ::wxFontFamily enumeration values.
|
2008-03-09 08:33:59 -04:00
|
|
|
@param style
|
|
|
|
One of wxFONTSTYLE_NORMAL, wxFONTSTYLE_SLANT and wxFONTSTYLE_ITALIC.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param weight
|
2008-09-25 15:15:28 -04:00
|
|
|
Font weight, sometimes also referred to as font boldness.
|
|
|
|
One of the ::wxFontWeight enumeration values.
|
2008-03-09 08:33:59 -04:00
|
|
|
@param underline
|
2008-09-25 15:15:28 -04:00
|
|
|
The value can be @true or @false.
|
|
|
|
At present this has an effect on Windows and Motif 2.x only.
|
2008-03-09 08:33:59 -04:00
|
|
|
@param faceName
|
2008-09-25 15:15:28 -04:00
|
|
|
An optional string specifying the actual typeface to be used.
|
|
|
|
If it is an empty string, a default typeface will be chosen based on the family.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param encoding
|
2008-09-25 15:15:28 -04:00
|
|
|
An encoding which may be one of the enumeration values of ::wxFontEncoding.
|
|
|
|
Briefly these can be summed up as:
|
|
|
|
<TABLE>
|
|
|
|
<TR><TD>wxFONTENCODING_SYSTEM</TD><TD>Default system encoding.</TD></TR>
|
|
|
|
<TR><TD>wxFONTENCODING_DEFAULT</TD><TD>
|
|
|
|
Default application encoding: this
|
|
|
|
is the encoding set by calls to
|
|
|
|
SetDefaultEncoding and which may be set to,
|
|
|
|
say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the
|
|
|
|
default application encoding is the same as default system encoding.</TD></TR>
|
|
|
|
<TR><TD>wxFONTENCODING_ISO8859_1...15</TD><TD>ISO8859 encodings.</TD></TR>
|
|
|
|
<TR><TD>wxFONTENCODING_KOI8</TD><TD>The standard Russian encoding for Internet.</TD></TR>
|
|
|
|
<TR><TD>wxFONTENCODING_CP1250...1252</TD><TD>Windows encodings similar to ISO8859 (but not identical).</TD></TR>
|
|
|
|
</TABLE>
|
2008-03-09 08:33:59 -04:00
|
|
|
If the specified encoding isn't available, no font is created
|
|
|
|
(see also font encoding overview).
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks If the desired font does not exist, the closest match will be
|
2008-09-25 15:15:28 -04:00
|
|
|
chosen. Under Windows, only scalable TrueType fonts are used.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxFont(const wxSize& pixelSize, wxFontFamily family,
|
|
|
|
int style, wxFontWeight weight,
|
2008-03-09 08:33:59 -04:00
|
|
|
const bool underline = false,
|
2008-03-08 09:43:31 -05:00
|
|
|
const wxString& faceName = "",
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
2008-09-25 15:15:28 -04:00
|
|
|
|
2008-09-25 16:00:31 -04:00
|
|
|
See @ref overview_refcount_destruct "reference-counted object destruction"
|
2008-09-25 15:15:28 -04:00
|
|
|
for more info.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks Although all remaining fonts are deleted when the application
|
2008-03-09 08:33:59 -04:00
|
|
|
exits, the application should try to clean up all fonts
|
|
|
|
itself. This is because wxWidgets cannot know if a
|
|
|
|
pointer to the font object is stored in an application
|
|
|
|
data structure, and there is a risk of double deletion.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxFont();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the current application's default encoding.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
@see @ref overview_fontencoding, SetDefaultEncoding()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static wxFontEncoding GetDefaultEncoding();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the typeface name associated with the font, or the empty string if
|
2008-09-25 15:15:28 -04:00
|
|
|
there is no typeface information.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetFaceName()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetFaceName() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the font family. See SetFamily() for a list of valid
|
|
|
|
family identifiers.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetFamily()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxFontFamily GetFamily() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the platform-dependent string completely describing this font.
|
|
|
|
Returned string is always non-empty.
|
2008-09-25 15:15:28 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Note that the returned string is not meant to be shown or edited by the user: a
|
2008-09-25 15:15:28 -04:00
|
|
|
typical use of this function is for serializing in string-form a wxFont object.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetNativeFontInfo(),GetNativeFontInfoUserDesc()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxString GetNativeFontInfoDesc() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Returns a user-friendly string for this font object.
|
|
|
|
Returned string is always non-empty.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Some examples of the formats of returned strings (which are platform-dependent)
|
|
|
|
are in SetNativeFontInfoUserDesc().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetNativeFontInfoDesc()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
wxString GetNativeFontInfoUserDesc() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the point size.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetPointSize()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int GetPointSize() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Gets the font style. See wxFontStyle for a list of valid styles.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetStyle()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-25 15:15:28 -04:00
|
|
|
wxFontStyle GetStyle() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the font is underlined, @false otherwise.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetUnderlined()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool GetUnderlined() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Gets the font weight. See wxFontWeight for a list of valid weight identifiers.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetWeight()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxFontWeight GetWeight() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the font is a fixed width (or monospaced) font,
|
|
|
|
@false if it is a proportional one or font is invalid.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool IsFixedWidth() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if this object is a valid font, @false otherwise.
|
|
|
|
*/
|
2008-10-13 07:09:56 -04:00
|
|
|
virtual bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-09-25 16:00:31 -04:00
|
|
|
These functions take the same parameters as
|
|
|
|
@ref wxFont::wxFont "wxFont constructors" and return a new font
|
|
|
|
object allocated on the heap.
|
2008-09-25 15:15:28 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Using @c New() is currently the only way to directly create a font with
|
|
|
|
the given size in pixels on platforms other than wxMSW.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
static wxFont* New(int pointSize, wxFontFamily family, int style,
|
|
|
|
wxFontWeight weight,
|
|
|
|
const bool underline = false,
|
|
|
|
const wxString& faceName = "",
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
|
|
|
static wxFont* New(int pointSize, wxFontFamily family,
|
|
|
|
int flags = wxFONTFLAG_DEFAULT,
|
|
|
|
const wxString& faceName = "",
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
|
|
|
static wxFont* New(const wxSize& pixelSize,
|
|
|
|
wxFontFamily family,
|
|
|
|
int style,
|
|
|
|
wxFontWeight weight,
|
|
|
|
const bool underline = false,
|
|
|
|
const wxString& faceName = "",
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
|
|
|
static wxFont* New(const wxSize& pixelSize,
|
|
|
|
wxFontFamily family,
|
|
|
|
int flags = wxFONTFLAG_DEFAULT,
|
|
|
|
const wxString& faceName = "",
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the default font encoding.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
@see @ref overview_fontencoding, GetDefaultEncoding()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static void SetDefaultEncoding(wxFontEncoding encoding);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the facename for the font.
|
|
|
|
Returns @true if the given face name exists; @false otherwise.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param faceName
|
2008-03-09 08:33:59 -04:00
|
|
|
A valid facename, which should be on the end-user's system.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks To avoid portability problems, don't rely on a specific face,
|
2008-09-25 15:15:28 -04:00
|
|
|
but specify the font family instead or as well.
|
|
|
|
A suitable font will be found on the end-user's system.
|
2008-03-09 08:33:59 -04:00
|
|
|
If both the family and the facename are specified,
|
|
|
|
wxWidgets will first search for the specific face, and
|
|
|
|
then for a font belonging to the same family.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetFaceName(), SetFamily()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool SetFaceName(const wxString& faceName);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the font family.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param family
|
2008-09-25 15:15:28 -04:00
|
|
|
One of the ::wxFontFamily values.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetFamily(), SetFaceName()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetFamily(wxFontFamily family);
|
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Creates the font corresponding to the given native font description string
|
|
|
|
which must have been previously returned by GetNativeFontInfoDesc().
|
|
|
|
|
|
|
|
If the string is invalid, font is unchanged.
|
|
|
|
This function is typically used for de-serializing a wxFont object
|
|
|
|
previously saved in a string-form.
|
|
|
|
|
|
|
|
@return @true if the creation was successful.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetNativeFontInfoUserDesc()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool SetNativeFontInfo(const wxString& info);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Creates the font corresponding to the given native font description string and
|
2008-09-25 15:15:28 -04:00
|
|
|
returns @true if the creation was successful.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
Unlike SetNativeFontInfo(), this function accepts strings which are user-friendly.
|
|
|
|
Examples of accepted string formats are:
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
@beginTable
|
|
|
|
@hdr3col{platform, generic syntax, example}
|
|
|
|
@row3col{wxGTK2, @c [FACE-NAME] [bold] [oblique|italic] [POINTSIZE], Monospace bold 10}
|
|
|
|
@row3col{wxMSW, @c [light|bold] [italic] [FACE-NAME] [POINTSIZE] [ENCODING], Tahoma 10 WINDOWS-1252}
|
|
|
|
@endTable
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
@todo add an example for wxMac
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
For more detailed information about the allowed syntaxes you can look at the
|
2008-09-25 15:15:28 -04:00
|
|
|
documentation of the native API used for font-rendering
|
|
|
|
(e.g. @c pango_font_description_from_string on GTK).
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetNativeFontInfo()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool SetNativeFontInfoUserDesc(const wxString& info);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the point size.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pointSize
|
2008-03-09 08:33:59 -04:00
|
|
|
Size in points.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetPointSize()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetPointSize(int pointSize);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the font style.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-09-25 15:15:28 -04:00
|
|
|
One of the ::wxFontStyle enumeration values.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetStyle()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-25 15:15:28 -04:00
|
|
|
void SetStyle(wxFontStyle style);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets underlining.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-08-30 19:58:45 -04:00
|
|
|
@param underlined
|
2008-03-09 08:33:59 -04:00
|
|
|
@true to underline, @false otherwise.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetUnderlined()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetUnderlined(const bool underlined);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the font weight.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param weight
|
2008-09-25 15:15:28 -04:00
|
|
|
One of the ::wxFontWeight values.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetWeight()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetWeight(wxFontWeight weight);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Inequality operator.
|
2008-09-25 15:15:28 -04:00
|
|
|
|
2008-09-25 16:00:31 -04:00
|
|
|
See @ref overview_refcount_equality "reference-counted object comparison" for
|
2008-03-08 08:52:38 -05:00
|
|
|
more info.
|
|
|
|
*/
|
|
|
|
bool operator !=(const wxFont& font);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Equality operator.
|
2008-09-25 15:15:28 -04:00
|
|
|
|
2008-09-25 16:00:31 -04:00
|
|
|
See @ref overview_refcount_equality "reference-counted object comparison" for
|
2008-03-08 08:52:38 -05:00
|
|
|
more info.
|
|
|
|
*/
|
|
|
|
bool operator ==(const wxFont& font);
|
2008-09-25 15:15:28 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Assignment operator, using @ref overview_refcount "reference counting".
|
|
|
|
*/
|
|
|
|
wxFont& operator =(const wxFont& font);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-04-06 11:28:55 -04:00
|
|
|
An empty wxFont.
|
2008-03-10 11:24:38 -04:00
|
|
|
*/
|
2008-03-23 14:24:32 -04:00
|
|
|
wxFont wxNullFont;
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Equivalent to wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).
|
2008-03-10 11:24:38 -04:00
|
|
|
*/
|
2008-03-23 14:24:32 -04:00
|
|
|
wxFont wxNORMAL_FONT;
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
A font using the wxFONTFAMILY_SWISS family and 2 points smaller than
|
|
|
|
::wxNORMAL_FONT.
|
2008-03-10 11:24:38 -04:00
|
|
|
*/
|
2008-03-23 14:24:32 -04:00
|
|
|
wxFont wxSMALL_FONT;
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
A font using the wxFONTFAMILY_ROMAN family and wxFONTSTYLE_ITALIC style and
|
|
|
|
of the same size of ::wxNORMAL_FONT.
|
2008-03-10 11:24:38 -04:00
|
|
|
*/
|
2008-03-23 14:24:32 -04:00
|
|
|
wxFont wxITALIC_FONT;
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
A font identic to ::wxNORMAL_FONT except for the family used which is
|
|
|
|
wxFONTFAMILY_SWISS.
|
2008-03-10 11:24:38 -04:00
|
|
|
*/
|
2008-03-23 14:24:32 -04:00
|
|
|
wxFont wxSWISS_FONT;
|
|
|
|
|
|
|
|
|
2008-04-06 11:28:55 -04:00
|
|
|
/**
|
|
|
|
@class wxFontList
|
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
A font list is a list containing all fonts which have been created.
|
|
|
|
There is only one instance of this class: ::wxTheFontList.
|
|
|
|
|
|
|
|
Use this object to search for a previously created font of the desired type
|
|
|
|
and create it if not already found.
|
|
|
|
|
2008-04-06 11:28:55 -04:00
|
|
|
In some windowing systems, the font may be a scarce resource, so it is best to
|
|
|
|
reuse old resources if possible. When an application finishes, all fonts will
|
2008-09-25 15:15:28 -04:00
|
|
|
be deleted and their resources freed, eliminating the possibility of 'memory
|
2008-04-06 11:28:55 -04:00
|
|
|
leaks'.
|
|
|
|
|
|
|
|
@library{wxcore}
|
|
|
|
@category{gdi}
|
|
|
|
|
|
|
|
@see wxFont
|
|
|
|
*/
|
|
|
|
class wxFontList : public wxList
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor. The application should not construct its own font list:
|
2008-09-25 15:15:28 -04:00
|
|
|
use the object pointer ::wxTheFontList.
|
2008-04-06 11:28:55 -04:00
|
|
|
*/
|
|
|
|
wxFontList();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Finds a font of the given specification, or creates one and adds it to the
|
2008-09-25 15:15:28 -04:00
|
|
|
list. See the @ref wxFont "wxFont constructor" for details of the arguments.
|
2008-04-06 11:28:55 -04:00
|
|
|
*/
|
|
|
|
wxFont* FindOrCreateFont(int point_size, int family, int style,
|
|
|
|
int weight,
|
|
|
|
bool underline = false,
|
|
|
|
const wxString& facename = NULL,
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
/**
|
|
|
|
The global wxFontList instance.
|
|
|
|
*/
|
|
|
|
wxFontList* wxTheFontList;
|
|
|
|
|
2008-03-23 14:24:32 -04:00
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
/** @ingroup group_funcmacro_misc */
|
|
|
|
//@{
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|
|
|
/**
|
2008-03-23 14:24:32 -04:00
|
|
|
Converts string to a wxFont best represented by the given string. Returns
|
|
|
|
@true on success.
|
|
|
|
|
|
|
|
@see wxToString(const wxFont&)
|
|
|
|
|
|
|
|
@header{wx/font.h}
|
2008-03-10 11:24:38 -04:00
|
|
|
*/
|
2008-03-23 14:24:32 -04:00
|
|
|
bool wxFromString(const wxString& string, wxFont* font);
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|
|
|
/**
|
2008-03-23 14:24:32 -04:00
|
|
|
Converts the given wxFont into a string.
|
|
|
|
|
|
|
|
@see wxFromString(const wxString&, wxFont*)
|
|
|
|
|
|
|
|
@header{wx/font.h}
|
2008-03-10 11:24:38 -04:00
|
|
|
*/
|
2008-03-23 14:24:32 -04:00
|
|
|
wxString wxToString(const wxFont& font);
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-23 14:24:32 -04:00
|
|
|
//@}
|
2008-03-10 11:24:38 -04:00
|
|
|
|