1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file for wxFont and related classes
9 // Copyright: (c) 2002 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
19 #include <wx/fontutil.h>
20 #include <wx/fontmap.h>
21 #include <wx/fontenum.h>
24 //---------------------------------------------------------------------------
30 wxFONTFAMILY_DEFAULT = wxDEFAULT,
31 wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
32 wxFONTFAMILY_ROMAN = wxROMAN,
33 wxFONTFAMILY_SCRIPT = wxSCRIPT,
34 wxFONTFAMILY_SWISS = wxSWISS,
35 wxFONTFAMILY_MODERN = wxMODERN,
36 wxFONTFAMILY_TELETYPE = wxTELETYPE,
38 wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
44 wxFONTSTYLE_NORMAL = wxNORMAL,
45 wxFONTSTYLE_ITALIC = wxITALIC,
46 wxFONTSTYLE_SLANT = wxSLANT,
53 wxFONTWEIGHT_NORMAL = wxNORMAL,
54 wxFONTWEIGHT_LIGHT = wxLIGHT,
55 wxFONTWEIGHT_BOLD = wxBOLD,
60 // the font flag bits for the new font ctor accepting one combined flags word
63 // no special flags: font with default weight/slant/anti-aliasing
66 // slant flags (default: no slant)
70 // weight flags (default: medium)
74 // anti-aliasing flag: force on or off (default: the current system default)
75 wxFONTFLAG_ANTIALIASED,
76 wxFONTFLAG_NOT_ANTIALIASED,
78 // underlined/strikethrough flags (default: no lines)
79 wxFONTFLAG_UNDERLINED,
80 wxFONTFLAG_STRIKETHROUGH,
82 // the mask of all currently used flags
90 wxFONTENCODING_SYSTEM = -1, // system default
91 wxFONTENCODING_DEFAULT, // current default encoding
93 // ISO8859 standard defines a number of single-byte charsets
94 wxFONTENCODING_ISO8859_1, // West European (Latin1)
95 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
96 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
97 wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
98 wxFONTENCODING_ISO8859_5, // Cyrillic
99 wxFONTENCODING_ISO8859_6, // Arabic
100 wxFONTENCODING_ISO8859_7, // Greek
101 wxFONTENCODING_ISO8859_8, // Hebrew
102 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
103 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
104 wxFONTENCODING_ISO8859_11, // Thai
105 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
106 // here anyhow to make all ISO8859
107 // consecutive numbers
108 wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
109 wxFONTENCODING_ISO8859_14, // Latin8
110 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
111 wxFONTENCODING_ISO8859_MAX,
113 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
114 wxFONTENCODING_KOI8, // KOI8 Russian
115 wxFONTENCODING_KOI8_U, // KOI8 Ukrainian
116 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
117 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
119 // what would we do without Microsoft? They have their own encodings
121 wxFONTENCODING_CP437, // original MS-DOS codepage
122 wxFONTENCODING_CP850, // CP437 merged with Latin1
123 wxFONTENCODING_CP852, // CP437 merged with Latin2
124 wxFONTENCODING_CP855, // another cyrillic encoding
125 wxFONTENCODING_CP866, // and another one
127 wxFONTENCODING_CP874, // WinThai
128 wxFONTENCODING_CP932, // Japanese (shift-JIS)
129 wxFONTENCODING_CP936, // Chinese simplified (GB)
130 wxFONTENCODING_CP949, // Korean (Hangul charset)
131 wxFONTENCODING_CP950, // Chinese (traditional - Big5)
132 wxFONTENCODING_CP1250, // WinLatin2
133 wxFONTENCODING_CP1251, // WinCyrillic
134 wxFONTENCODING_CP1252, // WinLatin1
135 wxFONTENCODING_CP1253, // WinGreek (8859-7)
136 wxFONTENCODING_CP1254, // WinTurkish
137 wxFONTENCODING_CP1255, // WinHebrew
138 wxFONTENCODING_CP1256, // WinArabic
139 wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
140 wxFONTENCODING_CP12_MAX,
142 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
143 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
144 wxFONTENCODING_EUC_JP, // Extended Unix Codepage for Japanese
145 wxFONTENCODING_UTF16BE, // UTF-16 Big Endian Unicode encoding
146 wxFONTENCODING_UTF16LE, // UTF-16 Little Endian Unicode encoding
147 wxFONTENCODING_UTF32BE, // UTF-32 Big Endian Unicode encoding
148 wxFONTENCODING_UTF32LE, // UTF-32 Little Endian Unicode encoding
150 wxFONTENCODING_MACROMAN, // the standard mac encodings
151 wxFONTENCODING_MACJAPANESE,
152 wxFONTENCODING_MACCHINESETRAD,
153 wxFONTENCODING_MACKOREAN,
154 wxFONTENCODING_MACARABIC,
155 wxFONTENCODING_MACHEBREW,
156 wxFONTENCODING_MACGREEK,
157 wxFONTENCODING_MACCYRILLIC,
158 wxFONTENCODING_MACDEVANAGARI,
159 wxFONTENCODING_MACGURMUKHI,
160 wxFONTENCODING_MACGUJARATI,
161 wxFONTENCODING_MACORIYA,
162 wxFONTENCODING_MACBENGALI,
163 wxFONTENCODING_MACTAMIL,
164 wxFONTENCODING_MACTELUGU,
165 wxFONTENCODING_MACKANNADA,
166 wxFONTENCODING_MACMALAJALAM,
167 wxFONTENCODING_MACSINHALESE,
168 wxFONTENCODING_MACBURMESE,
169 wxFONTENCODING_MACKHMER,
170 wxFONTENCODING_MACTHAI,
171 wxFONTENCODING_MACLAOTIAN,
172 wxFONTENCODING_MACGEORGIAN,
173 wxFONTENCODING_MACARMENIAN,
174 wxFONTENCODING_MACCHINESESIMP,
175 wxFONTENCODING_MACTIBETAN,
176 wxFONTENCODING_MACMONGOLIAN,
177 wxFONTENCODING_MACETHIOPIC,
178 wxFONTENCODING_MACCENTRALEUR,
179 wxFONTENCODING_MACVIATNAMESE,
180 wxFONTENCODING_MACARABICEXT,
181 wxFONTENCODING_MACSYMBOL,
182 wxFONTENCODING_MACDINGBATS,
183 wxFONTENCODING_MACTURKISH,
184 wxFONTENCODING_MACCROATIAN,
185 wxFONTENCODING_MACICELANDIC,
186 wxFONTENCODING_MACROMANIAN,
187 wxFONTENCODING_MACCELTIC,
188 wxFONTENCODING_MACGAELIC,
189 wxFONTENCODING_MACKEYBOARD,
191 wxFONTENCODING_MACMIN = wxFONTENCODING_MACROMAN ,
192 wxFONTENCODING_MACMAX = wxFONTENCODING_MACKEYBOARD ,
194 wxFONTENCODING_MAX, // highest enumerated encoding value
197 // aliases for endian-dependent UTF encodings
198 wxFONTENCODING_UTF16, // native UTF-16
199 wxFONTENCODING_UTF32, // native UTF-32
201 // alias for the native Unicode encoding on this platform
202 // (this is used by wxEncodingConverter and wxUTFFile only for now)
203 wxFONTENCODING_UNICODE = wxFONTENCODING_UTF16,
205 // alternative names for Far Eastern encodings
207 wxFONTENCODING_GB2312 = wxFONTENCODING_CP936, // Simplified Chinese
208 wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, // Traditional Chinese
210 // Japanese (see http://zsigri.tripod.com/fontboard/cjk/jis.html)
211 wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932 // Shift JIS
214 //---------------------------------------------------------------------------
217 // wxNativeFontInfo is platform-specific font representation: this struct
218 // should be considered as opaque font description only used by the native
219 // functions, the user code can only get the objects of this type from
220 // somewhere and pass it somewhere else (possibly save them somewhere using
221 // ToString() and restore them using FromString())
222 struct wxNativeFontInfo
228 // reset to the default state
231 // init with the parameters of the given font
232 void InitFromFont(const wxFont& font);
234 // accessors and modifiers for the font elements
235 int GetPointSize() const;
237 wxSize GetPixelSize() const;
239 wxFontStyle GetStyle() const;
240 wxFontWeight GetWeight() const;
241 bool GetUnderlined() const;
242 wxString GetFaceName() const;
243 wxFontFamily GetFamily() const;
244 wxFontEncoding GetEncoding() const;
246 void SetPointSize(int pointsize);
248 void SetPixelSize(const wxSize& pixelSize);
250 void SetStyle(wxFontStyle style);
251 void SetWeight(wxFontWeight weight);
252 void SetUnderlined(bool underlined);
253 bool SetFaceName(wxString facename);
254 void SetFamily(wxFontFamily family);
255 void SetEncoding(wxFontEncoding encoding);
258 // // sets the first facename in the given array which is found
259 // // to be valid. If no valid facename is given, sets the
260 // // first valid facename returned by wxFontEnumerator::GetFacenames().
261 // // Does not return a bool since it cannot fail.
262 // void SetFaceName(const wxArrayString &facenames);
265 // it is important to be able to serialize wxNativeFontInfo objects to be
266 // able to store them (in config file, for example)
267 bool FromString(const wxString& s);
268 wxString ToString() const;
272 return self->ToString();
276 // we also want to present the native font descriptions to the user in some
277 // human-readable form (it is not platform independent neither, but can
278 // hopefully be understood by the user)
279 bool FromUserString(const wxString& s);
280 wxString ToUserString() const;
282 %property(Encoding, GetEncoding, SetEncoding, doc="See `GetEncoding` and `SetEncoding`");
283 %property(FaceName, GetFaceName, SetFaceName, doc="See `GetFaceName` and `SetFaceName`");
284 %property(Family, GetFamily, SetFamily, doc="See `GetFamily` and `SetFamily`");
285 %property(PointSize, GetPointSize, SetPointSize, doc="See `GetPointSize` and `SetPointSize`");
286 %property(Style, GetStyle, SetStyle, doc="See `GetStyle` and `SetStyle`");
287 %property(Underlined, GetUnderlined, SetUnderlined, doc="See `GetUnderlined` and `SetUnderlined`");
288 %property(Weight, GetWeight, SetWeight, doc="See `GetWeight` and `SetWeight`");
294 struct wxNativeEncodingInfo
296 wxString facename; // may be empty meaning "any"
297 wxFontEncoding encoding; // so that we know what this struct represents
299 wxNativeEncodingInfo();
300 ~wxNativeEncodingInfo();
302 // this struct is saved in config by wxFontMapper, so it should know to
303 // serialise itself (implemented in platform-specific code)
304 bool FromString(const wxString& s);
305 wxString ToString() const;
310 // translate a wxFontEncoding into native encoding parameter (defined above),
311 // returning a wxNativeEncodingInfo if an (exact) match could be found, NULL
314 wxNativeEncodingInfo* wxGetNativeFontEncoding(wxFontEncoding encoding) {
315 static wxNativeEncodingInfo info;
316 if ( wxGetNativeFontEncoding(encoding, &info) )
323 // test for the existence of the font described by this facename/encoding,
324 // return True if such font(s) exist, False otherwise
325 bool wxTestFontEncoding(const wxNativeEncodingInfo& info);
330 wxNativeEncodingInfo* wxGetNativeFontEncoding(wxFontEncoding encoding)
331 { wxPyRaiseNotImplemented(); return NULL; }
333 bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
334 { wxPyRaiseNotImplemented(); return false; }
338 //---------------------------------------------------------------------------
341 // wxFontMapper manages user-definable correspondence between logical font
342 // names and the fonts present on the machine.
344 // The default implementations of all functions will ask the user if they are
345 // not capable of finding the answer themselves and store the answer in a
346 // config file (configurable via SetConfigXXX functions). This behaviour may
347 // be disabled by giving the value of False to "interactive" parameter.
348 // However, the functions will always consult the config file to allow the
349 // user-defined values override the default logic and there is no way to
350 // disable this - which shouldn't be ever needed because if "interactive" was
351 // never True, the config file is never created anyhow.
353 // This is a singleton class, font mapper objects can only be accessed using
354 // wxFontMapper::Get().
362 // return instance of the wxFontMapper singleton
363 static wxFontMapper *Get();
364 // set the singleton to 'mapper' instance and return previous one
365 static wxFontMapper *Set(wxFontMapper *mapper);
368 // returns the encoding for the given charset (in the form of RFC 2046) or
369 // wxFONTENCODING_SYSTEM if couldn't decode it
371 // interactive parameter is ignored in the base class, we behave as if it
373 virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
374 bool interactive = true);
377 // get the number of font encodings we know about
378 static size_t GetSupportedEncodingsCount();
380 // get the n-th supported encoding
381 static wxFontEncoding GetEncoding(size_t n);
383 // return canonical name of this encoding (this is a short string,
384 // GetEncodingDescription() returns a longer one)
385 static wxString GetEncodingName(wxFontEncoding encoding);
387 // // return a list of all names of this encoding (see GetEncodingName)
388 // static const wxChar** GetAllEncodingNames(wxFontEncoding encoding);
390 // return user-readable string describing the given encoding
392 // NB: hard-coded now, but might change later (read it from config?)
393 static wxString GetEncodingDescription(wxFontEncoding encoding);
395 // find the encoding corresponding to the given name, inverse of
396 // GetEncodingName() and less general than CharsetToEncoding()
398 // returns wxFONTENCODING_MAX if the name is not a supported encoding
399 static wxFontEncoding GetEncodingFromName(const wxString& name);
402 // set the root config path to use (should be an absolute path)
403 void SetConfigPath(const wxString& prefix);
405 // return default config path
406 static const wxString GetDefaultConfigPath();
410 // Find an alternative for the given encoding (which is supposed to not be
411 // available on this system). If successful, returns the encoding otherwise
414 PyObject* GetAltForEncoding(wxFontEncoding encoding,
415 const wxString& facename = wxPyEmptyString,
416 bool interactive = true) {
417 wxFontEncoding alt_enc;
418 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
419 return PyInt_FromLong(alt_enc);
428 // checks whether given encoding is available in given face or not.
429 // If no facename is given (default), return true if it's available in any
431 bool IsEncodingAvailable(wxFontEncoding encoding,
432 const wxString& facename = wxPyEmptyString);
434 // the parent window for modal dialogs
435 void SetDialogParent(wxWindow *parent);
437 // the title for the dialogs (note that default is quite reasonable)
438 void SetDialogTitle(const wxString& title);
441 %property(AltForEncoding, GetAltForEncoding, doc="See `GetAltForEncoding`");
446 //---------------------------------------------------------------------------
451 MustHaveApp(wxFont::GetDefaultEncoding);
452 MustHaveApp(wxFont::SetDefaultEncoding);
455 "A font is an object which determines the appearance of text. Fonts are
456 used for drawing text to a device context, and setting the appearance
459 You can retrieve the current system font settings with `wx.SystemSettings`.", "
461 The possible values for the family parameter of wx.Font constructor are:
463 ======================== =============================
464 wx.FONTFAMILY_DEFAULT Chooses a default font.
465 wx.FONTFAMILY_DECORATIVE A decorative font.
466 wx.FONTFAMILY_ROMAN A formal, serif font.
467 wx.FONTFAMILY_SCRIPT A handwriting font.
468 wx.FONTFAMILY_SWISS A sans-serif font.
469 wx.FONTFAMILY_MODERN Usually a fixed pitch font.
470 wx.FONTFAMILY_TELETYPE A teletype font.
471 ======================== =============================
473 The possible values for the weight parameter are:
475 ==================== ==
479 ==================== ==
481 The known font encodings are:
483 =========================== ====================================
484 wx.FONTENCODING_SYSTEM system default
485 wx.FONTENCODING_DEFAULT current default encoding
486 wx.FONTENCODING_ISO8859_1 West European (Latin1)
487 wx.FONTENCODING_ISO8859_2 Central and East European (Latin2)
488 wx.FONTENCODING_ISO8859_3 Esperanto (Latin3)
489 wx.FONTENCODING_ISO8859_4 Baltic (old) (Latin4)
490 wx.FONTENCODING_ISO8859_5 Cyrillic
491 wx.FONTENCODING_ISO8859_6 Arabic
492 wx.FONTENCODING_ISO8859_7 Greek
493 wx.FONTENCODING_ISO8859_8 Hebrew
494 wx.FONTENCODING_ISO8859_9 Turkish (Latin5)
495 wx.FONTENCODING_ISO8859_10 Variation of Latin4 (Latin6)
496 wx.FONTENCODING_ISO8859_11 Thai
497 wx.FONTENCODING_ISO8859_12 doesn't exist currently, but put it
498 here anyhow to make all ISO8859
500 wx.FONTENCODING_ISO8859_13 Baltic (Latin7)
501 wx.FONTENCODING_ISO8859_14 Latin8
502 wx.FONTENCODING_ISO8859_15 Latin9 (a.k.a. Latin0, includes euro)
503 wx.FONTENCODING_KOI8 Cyrillic charset
504 wx.FONTENCODING_ALTERNATIVE same as MS-DOS CP866
505 wx.FONTENCODING_BULGARIAN used under Linux in Bulgaria
506 wx.FONTENCODING_CP437 original MS-DOS codepage
507 wx.FONTENCODING_CP850 CP437 merged with Latin1
508 wx.FONTENCODING_CP852 CP437 merged with Latin2
509 wx.FONTENCODING_CP855 another cyrillic encoding
510 wx.FONTENCODING_CP866 and another one
511 wx.FONTENCODING_CP874 WinThai
512 wx.FONTENCODING_CP1250 WinLatin2
513 wx.FONTENCODING_CP1251 WinCyrillic
514 wx.FONTENCODING_CP1252 WinLatin1
515 wx.FONTENCODING_CP1253 WinGreek (8859-7)
516 wx.FONTENCODING_CP1254 WinTurkish
517 wx.FONTENCODING_CP1255 WinHebrew
518 wx.FONTENCODING_CP1256 WinArabic
519 wx.FONTENCODING_CP1257 WinBaltic (same as Latin 7)
520 wx.FONTENCODING_UTF7 UTF-7 Unicode encoding
521 wx.FONTENCODING_UTF8 UTF-8 Unicode encoding
522 =========================== ====================================
526 class wxFont : public wxGDIObject {
528 %pythonPrepend wxFont "if kwargs.has_key('faceName'): kwargs['face'] = kwargs['faceName'];del kwargs['faceName']"
531 wxFont( int pointSize, int family, int style, int weight,
532 bool underline=false, const wxString& face = wxPyEmptyString,
533 wxFontEncoding encoding = wxFONTENCODING_DEFAULT),
534 "Creates a font object with the specified attributes.
536 :param pointSize: The size of the font in points.
538 :param family: Font family. A generic way of referring to fonts
539 without specifying actual facename. It can be One of
540 the ``wx.FONTFAMILY_xxx`` constants.
542 :param style: One of the ``wx.FONTSTYLE_xxx`` constants.
544 :param weight: Font weight, sometimes also referred to as font
545 boldness. One of the ``wx.FONTWEIGHT_xxx`` constants.
547 :param underline: The value can be ``True`` or ``False`` and
548 indicates whether the font will include an underline. This
549 may not be supported on all platforms.
551 :param face: An optional string specifying the actual typeface to
552 be used. If it is an empty string, a default typeface will be
553 chosen based on the family.
555 :param encoding: An encoding which may be one of the
556 ``wx.FONTENCODING_xxx`` constants. If the specified encoding isn't
557 available, no font is created.
559 :see: `wx.FFont`, `wx.FontFromPixelSize`, `wx.FFontFromPixelSize`,
560 `wx.FontFromNativeInfoString`, `wx.FontFromNativeInfo`
567 "Construct a `wx.Font` from a `wx.NativeFontInfo` object.", "",
568 wxFont(const wxNativeFontInfo& info));
572 FontFromNativeInfoString,
573 "Construct a `wx.Font` from the string representation of a
574 `wx.NativeFontInfo` object.", "",
575 wxFont(const wxString& info))
577 wxNativeFontInfo nfi;
578 nfi.FromString(info);
579 return new wxFont(nfi);
587 "A bit of a simpler way to create a `wx.Font` using flags instead of
588 individual attribute settings. The value of flags can be a
589 combination of the following:
591 ============================ ==
597 wx.FONTFLAG_ANTIALIASED
598 wx.FONTFLAG_NOT_ANTIALIASED
599 wx.FONTFLAG_UNDERLINED
600 wx.FONTFLAG_STRIKETHROUGH
601 ============================ ==
603 :see: `wx.Font.__init__`", "",
605 wxFont(int pointSize,
607 int flags = wxFONTFLAG_DEFAULT,
608 const wxString& face = wxPyEmptyString,
609 wxFontEncoding encoding = wxFONTENCODING_DEFAULT))
611 return wxFont::New(pointSize, family, flags, face, encoding);
615 // There is a real ctor for this on wxMSW, but not the others, so just
616 // use the factory function in all cases.
620 "Creates a font using a size in pixels rather than points. If there is
621 platform API support for this then it is used, otherwise a font with
622 the closest size is found using a binary search.
624 :see: `wx.Font.__init__`", "",
625 wxFont(const wxSize& pixelSize,
629 bool underlined = false,
630 const wxString& face = wxEmptyString,
631 wxFontEncoding encoding = wxFONTENCODING_DEFAULT))
633 return wxFontBase::New(pixelSize, family,
634 style, weight, underlined,
640 "Creates a font using a size in pixels rather than points. If there is
641 platform API support for this then it is used, otherwise a font with
642 the closest size is found using a binary search.
644 :see: `wx.Font.__init__`, `wx.FFont`", "",
645 wxFont(const wxSize& pixelSize,
647 int flags = wxFONTFLAG_DEFAULT,
648 const wxString& face = wxEmptyString,
649 wxFontEncoding encoding = wxFONTENCODING_DEFAULT))
651 return wxFontBase::New(pixelSize, family, flags, face, encoding);
657 // was the font successfully created?
660 "Returns ``True`` if this font was successfully created.", "");
661 %pythoncode { def __nonzero__(self): return self.Ok() }
666 bool __eq__(const wxFont* other) { return other ? (*self == *other) : false; }
667 bool __ne__(const wxFont* other) { return other ? (*self != *other) : true; }
672 virtual int , GetPointSize() const,
673 "Gets the point size.", "");
676 virtual wxSize , GetPixelSize() const,
677 "Returns the size in pixels if the font was constructed with a pixel
681 virtual bool , IsUsingSizeInPixels() const,
682 "Returns ``True`` if the font is using a pixelSize.", "");
686 virtual int , GetFamily() const,
687 "Gets the font family. ", "");
690 virtual int , GetStyle() const,
691 "Gets the font style.", "");
694 virtual int , GetWeight() const,
695 "Gets the font weight. ", "");
698 virtual bool , GetUnderlined() const,
699 "Returns ``True`` if the font is underlined, ``False`` otherwise.", "");
702 virtual wxString , GetFaceName() const,
703 "Returns the typeface name associated with the font, or the empty
704 string if there is no typeface information.", "");
707 virtual wxFontEncoding , GetEncoding() const,
708 "Get the font's encoding.", "");
711 virtual const wxNativeFontInfo *, GetNativeFontInfo() const,
712 "Constructs a `wx.NativeFontInfo` object from this font.", "");
716 virtual bool , IsFixedWidth() const,
717 "Returns true if the font is a fixed width (or monospaced) font, false
718 if it is a proportional one or font is invalid.", "");
722 wxString , GetNativeFontInfoDesc() const,
723 "Returns the platform-dependent string completely describing this font
724 or an empty string if the font isn't valid.", "");
727 wxString , GetNativeFontInfoUserDesc() const,
728 "Returns a human readable version of `GetNativeFontInfoDesc`.", "");
731 // change the font characteristics
733 virtual void , SetPointSize( int pointSize ),
734 "Sets the point size.", "");
737 virtual void , SetPixelSize( const wxSize& pixelSize ),
738 "Sets the size in pixels rather than points. If there is platform API
739 support for this then it is used, otherwise a font with the closest
740 size is found using a binary search.", "");
743 virtual void , SetFamily( int family ),
744 "Sets the font family.", "");
747 virtual void , SetStyle( int style ),
748 "Sets the font style.", "");
751 virtual void , SetWeight( int weight ),
752 "Sets the font weight.", "");
755 virtual bool , SetFaceName( const wxString& faceName ),
756 "Sets the facename for the font. The facename, which should be a valid
757 font installed on the end-user's system.
759 To avoid portability problems, don't rely on a specific face, but
760 specify the font family instead or as well. A suitable font will be
761 found on the end-user's system. If both the family and the facename
762 are specified, wxWidgets will first search for the specific face, and
763 then for a font belonging to the same family.", "");
766 virtual void , SetUnderlined( bool underlined ),
767 "Sets underlining.", "");
770 virtual void , SetEncoding(wxFontEncoding encoding),
771 "Set the font encoding.", "");
774 void , SetNativeFontInfo(const wxNativeFontInfo& info),
775 "Set the font's attributes from a `wx.NativeFontInfo` object.", "");
779 bool , SetNativeFontInfo(const wxString& info),
780 "Set the font's attributes from string representation of a
781 `wx.NativeFontInfo` object.", "",
782 SetNativeFontInfoFromString);
785 bool , SetNativeFontInfoUserDesc(const wxString& info),
786 "Set the font's attributes from a string formerly returned from
787 `GetNativeFontInfoDesc`.", "");
791 wxString , GetFamilyString() const,
792 "Returns a string representation of the font family.", "");
795 wxString , GetStyleString() const,
796 "Returns a string representation of the font style.", "");
799 wxString , GetWeightString() const,
800 "Return a string representation of the font weight.", "");
803 virtual void SetNoAntiAliasing( bool no = true );
804 virtual bool GetNoAntiAliasing() const;
806 // the default encoding is used for creating all fonts with default
807 // encoding parameter
809 static wxFontEncoding , GetDefaultEncoding(),
810 "Returns the encoding used for all fonts created with an encoding of
811 ``wx.FONTENCODING_DEFAULT``.", "");
814 static void , SetDefaultEncoding(wxFontEncoding encoding),
815 "Sets the default font encoding.", "");
817 %property(Encoding, GetEncoding, SetEncoding, doc="See `GetEncoding` and `SetEncoding`");
818 %property(FaceName, GetFaceName, SetFaceName, doc="See `GetFaceName` and `SetFaceName`");
819 %property(Family, GetFamily, SetFamily, doc="See `GetFamily` and `SetFamily`");
820 %property(FamilyString, GetFamilyString, doc="See `GetFamilyString`");
821 %property(NativeFontInfo, GetNativeFontInfo, SetNativeFontInfo, doc="See `GetNativeFontInfo` and `SetNativeFontInfo`");
822 %property(NativeFontInfoDesc, GetNativeFontInfoDesc, doc="See `GetNativeFontInfoDesc`");
823 %property(NativeFontInfoUserDesc, GetNativeFontInfoUserDesc, SetNativeFontInfoUserDesc, doc="See `GetNativeFontInfoUserDesc` and `SetNativeFontInfoUserDesc`");
824 %property(NoAntiAliasing, GetNoAntiAliasing, SetNoAntiAliasing, doc="See `GetNoAntiAliasing` and `SetNoAntiAliasing`");
825 %property(PixelSize, GetPixelSize, SetPixelSize, doc="See `GetPixelSize` and `SetPixelSize`");
826 %property(PointSize, GetPointSize, SetPointSize, doc="See `GetPointSize` and `SetPointSize`");
827 %property(Style, GetStyle, SetStyle, doc="See `GetStyle` and `SetStyle`");
828 %property(StyleString, GetStyleString, doc="See `GetStyleString`");
829 %property(Underlined, GetUnderlined, SetUnderlined, doc="See `GetUnderlined` and `SetUnderlined`");
830 %property(Weight, GetWeight, SetWeight, doc="See `GetWeight` and `SetWeight`");
831 %property(WeightString, GetWeightString, doc="See `GetWeightString`");
835 %pythoncode { Font2 = wx._deprecated(FFont, "Use `wx.FFont` instead.") }
837 //---------------------------------------------------------------------------
842 class wxPyFontEnumerator : public wxFontEnumerator {
844 wxPyFontEnumerator() {}
845 ~wxPyFontEnumerator() {}
847 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
848 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
853 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
854 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
858 MustHaveApp(wxPyFontEnumerator);
860 %rename(FontEnumerator) wxPyFontEnumerator;
861 class wxPyFontEnumerator {
863 %pythonAppend wxPyFontEnumerator "self._setCallbackInfo(self, FontEnumerator, 0)"
865 wxPyFontEnumerator();
866 ~wxPyFontEnumerator();
867 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
869 bool EnumerateFacenames(
870 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
871 bool fixedWidthOnly = false);
873 bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
876 static PyObject* GetEncodings() {
878 wxArrayString arr = wxFontEnumerator::GetEncodings();
879 wxPyBlock_t blocked = wxPyBeginBlockThreads();
880 ret = wxArrayString2PyList_helper(arr);
881 wxPyEndBlockThreads(blocked);
885 static PyObject* GetFacenames() {
887 wxArrayString arr = wxFontEnumerator::GetFacenames();
888 wxPyBlock_t blocked = wxPyBeginBlockThreads();
889 ret = wxArrayString2PyList_helper(arr);
890 wxPyEndBlockThreads(blocked);
896 static bool , IsValidFacename(const wxString &str),
897 "Convenience function that returns true if the given face name exist in
898 the user's system", "");
905 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
908 //---------------------------------------------------------------------------