font.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/font.h
  3. // Purpose: wxFontBase class: the interface of wxFont
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 20.09.99
  7. // Copyright: (c) wxWidgets team
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_FONT_H_BASE_
  11. #define _WX_FONT_H_BASE_
  12. // ----------------------------------------------------------------------------
  13. // headers
  14. // ----------------------------------------------------------------------------
  15. #include "wx/defs.h" // for wxDEFAULT &c
  16. #include "wx/fontenc.h" // the font encoding constants
  17. #include "wx/gdiobj.h" // the base class
  18. #include "wx/gdicmn.h" // for wxGDIObjListBase
  19. // ----------------------------------------------------------------------------
  20. // forward declarations
  21. // ----------------------------------------------------------------------------
  22. class WXDLLIMPEXP_FWD_CORE wxFont;
  23. // ----------------------------------------------------------------------------
  24. // font constants
  25. // ----------------------------------------------------------------------------
  26. // standard font families: these may be used only for the font creation, it
  27. // doesn't make sense to query an existing font for its font family as,
  28. // especially if the font had been created from a native font description, it
  29. // may be unknown
  30. enum wxFontFamily
  31. {
  32. wxFONTFAMILY_DEFAULT = wxDEFAULT,
  33. wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
  34. wxFONTFAMILY_ROMAN = wxROMAN,
  35. wxFONTFAMILY_SCRIPT = wxSCRIPT,
  36. wxFONTFAMILY_SWISS = wxSWISS,
  37. wxFONTFAMILY_MODERN = wxMODERN,
  38. wxFONTFAMILY_TELETYPE = wxTELETYPE,
  39. wxFONTFAMILY_MAX,
  40. wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
  41. };
  42. // font styles
  43. enum wxFontStyle
  44. {
  45. wxFONTSTYLE_NORMAL = wxNORMAL,
  46. wxFONTSTYLE_ITALIC = wxITALIC,
  47. wxFONTSTYLE_SLANT = wxSLANT,
  48. wxFONTSTYLE_MAX
  49. };
  50. // font weights
  51. enum wxFontWeight
  52. {
  53. wxFONTWEIGHT_NORMAL = wxNORMAL,
  54. wxFONTWEIGHT_LIGHT = wxLIGHT,
  55. wxFONTWEIGHT_BOLD = wxBOLD,
  56. wxFONTWEIGHT_MAX
  57. };
  58. // Symbolic font sizes as defined in CSS specification.
  59. enum wxFontSymbolicSize
  60. {
  61. wxFONTSIZE_XX_SMALL = -3,
  62. wxFONTSIZE_X_SMALL,
  63. wxFONTSIZE_SMALL,
  64. wxFONTSIZE_MEDIUM,
  65. wxFONTSIZE_LARGE,
  66. wxFONTSIZE_X_LARGE,
  67. wxFONTSIZE_XX_LARGE
  68. };
  69. // the font flag bits for the new font ctor accepting one combined flags word
  70. enum wxFontFlag
  71. {
  72. // no special flags: font with default weight/slant/anti-aliasing
  73. wxFONTFLAG_DEFAULT = 0,
  74. // slant flags (default: no slant)
  75. wxFONTFLAG_ITALIC = 1 << 0,
  76. wxFONTFLAG_SLANT = 1 << 1,
  77. // weight flags (default: medium)
  78. wxFONTFLAG_LIGHT = 1 << 2,
  79. wxFONTFLAG_BOLD = 1 << 3,
  80. // anti-aliasing flag: force on or off (default: the current system default)
  81. wxFONTFLAG_ANTIALIASED = 1 << 4,
  82. wxFONTFLAG_NOT_ANTIALIASED = 1 << 5,
  83. // underlined/strikethrough flags (default: no lines)
  84. wxFONTFLAG_UNDERLINED = 1 << 6,
  85. wxFONTFLAG_STRIKETHROUGH = 1 << 7,
  86. // the mask of all currently used flags
  87. wxFONTFLAG_MASK = wxFONTFLAG_ITALIC |
  88. wxFONTFLAG_SLANT |
  89. wxFONTFLAG_LIGHT |
  90. wxFONTFLAG_BOLD |
  91. wxFONTFLAG_ANTIALIASED |
  92. wxFONTFLAG_NOT_ANTIALIASED |
  93. wxFONTFLAG_UNDERLINED |
  94. wxFONTFLAG_STRIKETHROUGH
  95. };
  96. // ----------------------------------------------------------------------------
  97. // wxFontInfo describes a wxFont
  98. // ----------------------------------------------------------------------------
  99. class wxFontInfo
  100. {
  101. public:
  102. // Default ctor uses the default font size appropriate for the current
  103. // platform.
  104. wxFontInfo()
  105. { InitPointSize(-1); }
  106. // These ctors specify the font size, either in points or in pixels.
  107. wxEXPLICIT wxFontInfo(int pointSize)
  108. { InitPointSize(pointSize); }
  109. wxEXPLICIT wxFontInfo(const wxSize& pixelSize) : m_pixelSize(pixelSize)
  110. { Init(); }
  111. // Setters for the various attributes. All of them return the object itself
  112. // so that the calls to them could be chained.
  113. wxFontInfo& Family(wxFontFamily family)
  114. { m_family = family; return *this; }
  115. wxFontInfo& FaceName(const wxString& faceName)
  116. { m_faceName = faceName; return *this; }
  117. wxFontInfo& Bold(bool bold = true)
  118. { SetFlag(wxFONTFLAG_BOLD, bold); return *this; }
  119. wxFontInfo& Light(bool light = true)
  120. { SetFlag(wxFONTFLAG_LIGHT, light); return *this; }
  121. wxFontInfo& Italic(bool italic = true)
  122. { SetFlag(wxFONTFLAG_ITALIC, italic); return *this; }
  123. wxFontInfo& Slant(bool slant = true)
  124. { SetFlag(wxFONTFLAG_SLANT, slant); return *this; }
  125. wxFontInfo& AntiAliased(bool antiAliased = true)
  126. { SetFlag(wxFONTFLAG_ANTIALIASED, antiAliased); return *this; }
  127. wxFontInfo& Underlined(bool underlined = true)
  128. { SetFlag(wxFONTFLAG_UNDERLINED, underlined); return *this; }
  129. wxFontInfo& Strikethrough(bool strikethrough = true)
  130. { SetFlag(wxFONTFLAG_STRIKETHROUGH, strikethrough); return *this; }
  131. wxFontInfo& Encoding(wxFontEncoding encoding)
  132. { m_encoding = encoding; return *this; }
  133. // Set all flags at once.
  134. wxFontInfo& AllFlags(int flags)
  135. { m_flags = flags; return *this; }
  136. // Accessors are mostly meant to be used by wxFont itself to extract the
  137. // various pieces of the font description.
  138. bool IsUsingSizeInPixels() const { return m_pixelSize != wxDefaultSize; }
  139. int GetPointSize() const { return m_pointSize; }
  140. wxSize GetPixelSize() const { return m_pixelSize; }
  141. wxFontFamily GetFamily() const { return m_family; }
  142. const wxString& GetFaceName() const { return m_faceName; }
  143. wxFontStyle GetStyle() const
  144. {
  145. return m_flags & wxFONTFLAG_ITALIC
  146. ? wxFONTSTYLE_ITALIC
  147. : m_flags & wxFONTFLAG_SLANT
  148. ? wxFONTSTYLE_SLANT
  149. : wxFONTSTYLE_NORMAL;
  150. }
  151. wxFontWeight GetWeight() const
  152. {
  153. return m_flags & wxFONTFLAG_LIGHT
  154. ? wxFONTWEIGHT_LIGHT
  155. : m_flags & wxFONTFLAG_BOLD
  156. ? wxFONTWEIGHT_BOLD
  157. : wxFONTWEIGHT_NORMAL;
  158. }
  159. bool IsAntiAliased() const
  160. {
  161. return (m_flags & wxFONTFLAG_ANTIALIASED) != 0;
  162. }
  163. bool IsUnderlined() const
  164. {
  165. return (m_flags & wxFONTFLAG_UNDERLINED) != 0;
  166. }
  167. bool IsStrikethrough() const
  168. {
  169. return (m_flags & wxFONTFLAG_STRIKETHROUGH) != 0;
  170. }
  171. wxFontEncoding GetEncoding() const { return m_encoding; }
  172. // Default copy ctor, assignment operator and dtor are OK.
  173. private:
  174. // Common part of all ctor, initializing everything except the size (which
  175. // is initialized by the ctors themselves).
  176. void Init()
  177. {
  178. m_family = wxFONTFAMILY_DEFAULT;
  179. m_flags = wxFONTFLAG_DEFAULT;
  180. m_encoding = wxFONTENCODING_DEFAULT;
  181. }
  182. void InitPointSize(int pointSize)
  183. {
  184. Init();
  185. m_pointSize = pointSize;
  186. m_pixelSize = wxDefaultSize;
  187. }
  188. // Turn on or off the given bit in m_flags depending on the value of the
  189. // boolean argument.
  190. void SetFlag(int flag, bool on)
  191. {
  192. if ( on )
  193. m_flags |= flag;
  194. else
  195. m_flags &= ~flag;
  196. }
  197. // The size information: if m_pixelSize is valid (!= wxDefaultSize), then
  198. // it is used. Otherwise m_pointSize is used, taking into account that if
  199. // it is == -1, it means that the platform dependent font size should be
  200. // used.
  201. int m_pointSize;
  202. wxSize m_pixelSize;
  203. wxFontFamily m_family;
  204. wxString m_faceName;
  205. int m_flags;
  206. wxFontEncoding m_encoding;
  207. };
  208. // ----------------------------------------------------------------------------
  209. // wxFontBase represents a font object
  210. // ----------------------------------------------------------------------------
  211. class WXDLLIMPEXP_FWD_CORE wxNativeFontInfo;
  212. class WXDLLIMPEXP_CORE wxFontBase : public wxGDIObject
  213. {
  214. public:
  215. /*
  216. derived classes should provide the following ctors:
  217. wxFont();
  218. wxFont(const wxFontInfo& info);
  219. wxFont(const wxString& nativeFontInfoString);
  220. wxFont(const wxNativeFontInfo& info);
  221. wxFont(int size,
  222. wxFontFamily family,
  223. wxFontStyle style,
  224. wxFontWeight weight,
  225. bool underlined = false,
  226. const wxString& face = wxEmptyString,
  227. wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
  228. wxFont(const wxSize& pixelSize,
  229. wxFontFamily family,
  230. wxFontStyle style,
  231. wxFontWeight weight,
  232. bool underlined = false,
  233. const wxString& face = wxEmptyString,
  234. wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
  235. */
  236. // creator function
  237. virtual ~wxFontBase();
  238. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  239. // from the font components
  240. static wxFont *New(
  241. int pointSize, // size of the font in points
  242. int family, // see wxFontFamily enum
  243. int style, // see wxFontStyle enum
  244. int weight, // see wxFontWeight enum
  245. bool underlined = false, // not underlined by default
  246. const wxString& face = wxEmptyString, // facename
  247. wxFontEncoding encoding = wxFONTENCODING_DEFAULT) // ISO8859-X, ...
  248. { return New(pointSize, (wxFontFamily)family, (wxFontStyle)style,
  249. (wxFontWeight)weight, underlined, face, encoding); }
  250. // from the font components
  251. static wxFont *New(
  252. const wxSize& pixelSize, // size of the font in pixels
  253. int family, // see wxFontFamily enum
  254. int style, // see wxFontStyle enum
  255. int weight, // see wxFontWeight enum
  256. bool underlined = false, // not underlined by default
  257. const wxString& face = wxEmptyString, // facename
  258. wxFontEncoding encoding = wxFONTENCODING_DEFAULT) // ISO8859-X, ...
  259. { return New(pixelSize, (wxFontFamily)family, (wxFontStyle)style,
  260. (wxFontWeight)weight, underlined, face, encoding); }
  261. #endif
  262. // from the font components
  263. static wxFont *New(
  264. int pointSize, // size of the font in points
  265. wxFontFamily family, // see wxFontFamily enum
  266. wxFontStyle style, // see wxFontStyle enum
  267. wxFontWeight weight, // see wxFontWeight enum
  268. bool underlined = false, // not underlined by default
  269. const wxString& face = wxEmptyString, // facename
  270. wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
  271. // from the font components
  272. static wxFont *New(
  273. const wxSize& pixelSize, // size of the font in pixels
  274. wxFontFamily family, // see wxFontFamily enum
  275. wxFontStyle style, // see wxFontStyle enum
  276. wxFontWeight weight, // see wxFontWeight enum
  277. bool underlined = false, // not underlined by default
  278. const wxString& face = wxEmptyString, // facename
  279. wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
  280. // from the font components but using the font flags instead of separate
  281. // parameters for each flag
  282. static wxFont *New(int pointSize,
  283. wxFontFamily family,
  284. int flags = wxFONTFLAG_DEFAULT,
  285. const wxString& face = wxEmptyString,
  286. wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
  287. // from the font components but using the font flags instead of separate
  288. // parameters for each flag
  289. static wxFont *New(const wxSize& pixelSize,
  290. wxFontFamily family,
  291. int flags = wxFONTFLAG_DEFAULT,
  292. const wxString& face = wxEmptyString,
  293. wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
  294. // from the (opaque) native font description object
  295. static wxFont *New(const wxNativeFontInfo& nativeFontDesc);
  296. // from the string representation of wxNativeFontInfo
  297. static wxFont *New(const wxString& strNativeFontDesc);
  298. // comparison
  299. bool operator==(const wxFont& font) const;
  300. bool operator!=(const wxFont& font) const { return !(*this == font); }
  301. // accessors: get the font characteristics
  302. virtual int GetPointSize() const = 0;
  303. virtual wxSize GetPixelSize() const;
  304. virtual bool IsUsingSizeInPixels() const;
  305. wxFontFamily GetFamily() const;
  306. virtual wxFontStyle GetStyle() const = 0;
  307. virtual wxFontWeight GetWeight() const = 0;
  308. virtual bool GetUnderlined() const = 0;
  309. virtual bool GetStrikethrough() const { return false; }
  310. virtual wxString GetFaceName() const = 0;
  311. virtual wxFontEncoding GetEncoding() const = 0;
  312. virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0;
  313. virtual bool IsFixedWidth() const;
  314. wxString GetNativeFontInfoDesc() const;
  315. wxString GetNativeFontInfoUserDesc() const;
  316. // change the font characteristics
  317. virtual void SetPointSize( int pointSize ) = 0;
  318. virtual void SetPixelSize( const wxSize& pixelSize );
  319. virtual void SetFamily( wxFontFamily family ) = 0;
  320. virtual void SetStyle( wxFontStyle style ) = 0;
  321. virtual void SetWeight( wxFontWeight weight ) = 0;
  322. virtual void SetUnderlined( bool underlined ) = 0;
  323. virtual void SetStrikethrough( bool WXUNUSED(strikethrough) ) {}
  324. virtual void SetEncoding(wxFontEncoding encoding) = 0;
  325. virtual bool SetFaceName( const wxString& faceName );
  326. void SetNativeFontInfo(const wxNativeFontInfo& info)
  327. { DoSetNativeFontInfo(info); }
  328. bool SetNativeFontInfo(const wxString& info);
  329. bool SetNativeFontInfoUserDesc(const wxString& info);
  330. // Symbolic font sizes support: set the font size to "large" or "very
  331. // small" either absolutely (i.e. compared to the default font size) or
  332. // relatively to the given font size.
  333. void SetSymbolicSize(wxFontSymbolicSize size);
  334. void SetSymbolicSizeRelativeTo(wxFontSymbolicSize size, int base)
  335. {
  336. SetPointSize(AdjustToSymbolicSize(size, base));
  337. }
  338. // Adjust the base size in points according to symbolic size.
  339. static int AdjustToSymbolicSize(wxFontSymbolicSize size, int base);
  340. // translate the fonts into human-readable string (i.e. GetStyleString()
  341. // will return "wxITALIC" for an italic font, ...)
  342. wxString GetFamilyString() const;
  343. wxString GetStyleString() const;
  344. wxString GetWeightString() const;
  345. // the default encoding is used for creating all fonts with default
  346. // encoding parameter
  347. static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
  348. static void SetDefaultEncoding(wxFontEncoding encoding);
  349. // this doesn't do anything and is kept for compatibility only
  350. #if WXWIN_COMPATIBILITY_2_8
  351. wxDEPRECATED_INLINE(void SetNoAntiAliasing(bool no = true), wxUnusedVar(no);)
  352. wxDEPRECATED_INLINE(bool GetNoAntiAliasing() const, return false;)
  353. #endif // WXWIN_COMPATIBILITY_2_8
  354. protected:
  355. // the function called by both overloads of SetNativeFontInfo()
  356. virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
  357. // The function called by public GetFamily(): it can return
  358. // wxFONTFAMILY_UNKNOWN unlike the public method (see comment there).
  359. virtual wxFontFamily DoGetFamily() const = 0;
  360. // Helper functions to recover wxFONTSTYLE/wxFONTWEIGHT and underlined flag
  361. // values from flags containing a combination of wxFONTFLAG_XXX.
  362. static wxFontStyle GetStyleFromFlags(int flags)
  363. {
  364. return flags & wxFONTFLAG_ITALIC
  365. ? wxFONTSTYLE_ITALIC
  366. : flags & wxFONTFLAG_SLANT
  367. ? wxFONTSTYLE_SLANT
  368. : wxFONTSTYLE_NORMAL;
  369. }
  370. static wxFontWeight GetWeightFromFlags(int flags)
  371. {
  372. return flags & wxFONTFLAG_LIGHT
  373. ? wxFONTWEIGHT_LIGHT
  374. : flags & wxFONTFLAG_BOLD
  375. ? wxFONTWEIGHT_BOLD
  376. : wxFONTWEIGHT_NORMAL;
  377. }
  378. static bool GetUnderlinedFromFlags(int flags)
  379. {
  380. return (flags & wxFONTFLAG_UNDERLINED) != 0;
  381. }
  382. static bool GetStrikethroughFromFlags(int flags)
  383. {
  384. return (flags & wxFONTFLAG_STRIKETHROUGH) != 0;
  385. }
  386. private:
  387. // the currently default encoding: by default, it's the default system
  388. // encoding, but may be changed by the application using
  389. // SetDefaultEncoding() to make all subsequent fonts created without
  390. // specifying encoding parameter using this encoding
  391. static wxFontEncoding ms_encodingDefault;
  392. };
  393. // wxFontBase <-> wxString utilities, used by wxConfig
  394. WXDLLIMPEXP_CORE wxString wxToString(const wxFontBase& font);
  395. WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font);
  396. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  397. #define wxDECLARE_FONT_COMPAT_SETTER \
  398. wxDEPRECATED_FUTURE( void SetFamily(int family) ) \
  399. { SetFamily((wxFontFamily)family); } \
  400. wxDEPRECATED_FUTURE( void SetStyle(int style) ) \
  401. { SetStyle((wxFontStyle)style); } \
  402. wxDEPRECATED_FUTURE( void SetWeight(int weight) ) \
  403. { SetWeight((wxFontWeight)weight); } \
  404. wxDEPRECATED_FUTURE( void SetFamily(wxDeprecatedGUIConstants family) ) \
  405. { SetFamily((wxFontFamily)family); } \
  406. wxDEPRECATED_FUTURE( void SetStyle(wxDeprecatedGUIConstants style) ) \
  407. { SetStyle((wxFontStyle)style); } \
  408. wxDEPRECATED_FUTURE( void SetWeight(wxDeprecatedGUIConstants weight) ) \
  409. { SetWeight((wxFontWeight)weight); }
  410. #else
  411. #define wxDECLARE_FONT_COMPAT_SETTER /*empty*/
  412. #endif
  413. // this macro must be used in all derived wxFont classes declarations
  414. #define wxDECLARE_COMMON_FONT_METHODS() \
  415. wxDECLARE_FONT_COMPAT_SETTER \
  416. \
  417. /* functions for modifying font in place */ \
  418. wxFont& MakeBold(); \
  419. wxFont& MakeItalic(); \
  420. wxFont& MakeUnderlined(); \
  421. wxFont& MakeStrikethrough(); \
  422. wxFont& MakeLarger() { return Scale(1.2f); } \
  423. wxFont& MakeSmaller() { return Scale(1/1.2f); } \
  424. wxFont& Scale(float x); \
  425. /* functions for creating fonts based on this one */ \
  426. wxFont Bold() const; \
  427. wxFont Italic() const; \
  428. wxFont Underlined() const; \
  429. wxFont Strikethrough() const; \
  430. wxFont Larger() const { return Scaled(1.2f); } \
  431. wxFont Smaller() const { return Scaled(1/1.2f); } \
  432. wxFont Scaled(float x) const
  433. // include the real class declaration
  434. #if defined(__WXMSW__)
  435. #include "wx/msw/font.h"
  436. #elif defined(__WXMOTIF__)
  437. #include "wx/motif/font.h"
  438. #elif defined(__WXGTK20__)
  439. #include "wx/gtk/font.h"
  440. #elif defined(__WXGTK__)
  441. #include "wx/gtk1/font.h"
  442. #elif defined(__WXX11__)
  443. #include "wx/x11/font.h"
  444. #elif defined(__WXDFB__)
  445. #include "wx/dfb/font.h"
  446. #elif defined(__WXMAC__)
  447. #include "wx/osx/font.h"
  448. #elif defined(__WXCOCOA__)
  449. #include "wx/cocoa/font.h"
  450. #elif defined(__WXPM__)
  451. #include "wx/os2/font.h"
  452. #endif
  453. class WXDLLIMPEXP_CORE wxFontList: public wxGDIObjListBase
  454. {
  455. public:
  456. wxFont *FindOrCreateFont(int pointSize,
  457. wxFontFamily family,
  458. wxFontStyle style,
  459. wxFontWeight weight,
  460. bool underline = false,
  461. const wxString& face = wxEmptyString,
  462. wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
  463. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  464. wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
  465. bool underline = false,
  466. const wxString& face = wxEmptyString,
  467. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  468. { return FindOrCreateFont(pointSize, (wxFontFamily)family, (wxFontStyle)style,
  469. (wxFontWeight)weight, underline, face, encoding); }
  470. #endif
  471. #if WXWIN_COMPATIBILITY_2_6
  472. wxDEPRECATED( void AddFont(wxFont*) );
  473. wxDEPRECATED( void RemoveFont(wxFont*) );
  474. #endif
  475. };
  476. extern WXDLLIMPEXP_DATA_CORE(wxFontList*) wxTheFontList;
  477. // provide comparison operators to allow code such as
  478. //
  479. // if ( font.GetStyle() == wxFONTSTYLE_SLANT )
  480. //
  481. // to compile without warnings which it would otherwise provoke from some
  482. // compilers as it compares elements of different enums
  483. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  484. // Unfortunately some compilers have ambiguity issues when enum comparisons are
  485. // overloaded so we have to disable the overloads in this case, see
  486. // wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details.
  487. #ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM
  488. inline bool operator==(wxFontFamily s, wxDeprecatedGUIConstants t)
  489. { return static_cast<int>(s) == static_cast<int>(t); }
  490. inline bool operator!=(wxFontFamily s, wxDeprecatedGUIConstants t)
  491. { return !(s == t); }
  492. inline bool operator==(wxFontStyle s, wxDeprecatedGUIConstants t)
  493. { return static_cast<int>(s) == static_cast<int>(t); }
  494. inline bool operator!=(wxFontStyle s, wxDeprecatedGUIConstants t)
  495. { return !(s == t); }
  496. inline bool operator==(wxFontWeight s, wxDeprecatedGUIConstants t)
  497. { return static_cast<int>(s) == static_cast<int>(t); }
  498. inline bool operator!=(wxFontWeight s, wxDeprecatedGUIConstants t)
  499. { return !(s == t); }
  500. #endif // // wxCOMPILER_NO_OVERLOAD_ON_ENUM
  501. #endif // FUTURE_WXWIN_COMPATIBILITY_3_0
  502. #endif
  503. // _WX_FONT_H_BASE_