+ // operations
+ bool Alloc();
+
+ void Free();
+
+ // all wxFont accessors
+ int GetPointSize() const
+ {
+ return m_nativeFontInfo.GetPointSize();
+ }
+
+ wxSize GetPixelSize() const
+ {
+ return m_nativeFontInfo.GetPixelSize();
+ }
+
+ bool IsUsingSizeInPixels() const
+ {
+ return m_sizeUsingPixels;
+ }
+
+ wxFontFamily GetFamily() const
+ {
+ return m_nativeFontInfo.GetFamily();
+ }
+
+ wxFontStyle GetStyle() const
+ {
+ return m_nativeFontInfo.GetStyle();
+ }
+
+ wxFontWeight GetWeight() const
+ {
+ return m_nativeFontInfo.GetWeight();
+ }
+
+ bool GetUnderlined() const
+ {
+ return m_nativeFontInfo.GetUnderlined();
+ }
+
+ wxString GetFaceName() const
+ {
+ wxString facename = m_nativeFontInfo.GetFaceName();
+ if ( facename.empty() )
+ {
+ facename = GetMSWFaceName();
+ if ( !facename.empty() )
+ {
+ // cache the face name, it shouldn't change unless the family
+ // does and wxNativeFontInfo::SetFamily() resets the face name
+ const_cast<wxFontRefData *>(this)->SetFaceName(facename);
+ }
+ }
+
+ return facename;
+ }
+
+ wxFontEncoding GetEncoding() const
+ {
+ return m_nativeFontInfo.GetEncoding();
+ }
+
+ WXHFONT GetHFONT() const
+ {
+ AllocIfNeeded();
+
+ return (WXHFONT)m_hFont;
+ }
+
+ bool HasHFONT() const
+ {
+ return m_hFont != 0;
+ }
+
+ // ... and setters: notice that all of them invalidate the currently
+ // allocated HFONT, if any, so that the next call to GetHFONT() recreates a
+ // new one
+ void SetPointSize(int pointSize)
+ {
+ Free();
+
+ m_nativeFontInfo.SetPointSize(pointSize);
+ m_sizeUsingPixels = false;
+ }
+
+ void SetPixelSize(const wxSize& pixelSize)
+ {
+ wxCHECK_RET( pixelSize.GetWidth() >= 0, "negative font width" );
+ wxCHECK_RET( pixelSize.GetHeight() != 0, "zero font height" );
+
+ Free();
+
+ m_nativeFontInfo.SetPixelSize(pixelSize);
+ m_sizeUsingPixels = true;
+ }
+
+ void SetFamily(wxFontFamily family)
+ {
+ Free();
+
+ m_nativeFontInfo.SetFamily(family);
+ }
+
+ void SetStyle(wxFontStyle style)
+ {
+ Free();
+
+ m_nativeFontInfo.SetStyle(style);
+ }
+
+ void SetWeight(wxFontWeight weight)
+ {
+ Free();
+
+ m_nativeFontInfo.SetWeight(weight);
+ }
+
+ bool SetFaceName(const wxString& faceName)
+ {
+ Free();
+
+ return m_nativeFontInfo.SetFaceName(faceName);
+ }
+
+ void SetUnderlined(bool underlined)
+ {
+ Free();
+
+ m_nativeFontInfo.SetUnderlined(underlined);
+ }
+
+ void SetEncoding(wxFontEncoding encoding)
+ {
+ Free();
+
+ m_nativeFontInfo.SetEncoding(encoding);
+ }
+
+ const wxNativeFontInfo& GetNativeFontInfo() const
+ {
+ // we need to create the font now to get the corresponding LOGFONT if
+ // it hadn't been done yet
+ AllocIfNeeded();
+
+ // ensure that we have a valid face name in our font information:
+ // GetFaceName() will try to retrieve it from our HFONT and save it if
+ // it was successful
+ (void)GetFaceName();
+
+ return m_nativeFontInfo;
+ }
+
+ void SetNativeFontInfo(const wxNativeFontInfo& nativeFontInfo)
+ {
+ Free();
+
+ m_nativeFontInfo = nativeFontInfo;
+ }
+