+ wxLogLastError(wxT("CreateFont"));
+
+ return FALSE;
+ }
+
+ m_hFont = (WXHFONT)hfont;
+
+ return TRUE;
+}
+
+void wxFontRefData::Free()
+{
+ if ( m_hFont )
+ {
+ if ( !::DeleteObject((HFONT) m_hFont) )
+ {
+ wxLogLastError(wxT("DeleteObject(font)"));
+ }
+
+ m_hFont = 0;
+ }
+}
+
+// ----------------------------------------------------------------------------
+// wxNativeFontInfo
+// ----------------------------------------------------------------------------
+
+void wxNativeFontInfo::Init()
+{
+ wxZeroMemory(lf);
+}
+
+int wxNativeFontInfo::GetPointSize() const
+{
+ // FIXME: using the screen here results in incorrect font size calculation
+ // for printing!
+ const int ppInch = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
+
+ return (int) (((72.0*(double)abs(lf.lfHeight)) / (double) ppInch) + 0.5);
+}
+
+wxFontStyle wxNativeFontInfo::GetStyle() const
+{
+ return lf.lfItalic ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL;
+}
+
+wxFontWeight wxNativeFontInfo::GetWeight() const
+{
+ if ( lf.lfWeight <= 300 )
+ return wxFONTWEIGHT_LIGHT;
+
+ if ( lf.lfWeight >= 600 )
+ return wxFONTWEIGHT_BOLD;
+
+ return wxFONTWEIGHT_NORMAL;
+}
+
+bool wxNativeFontInfo::GetUnderlined() const
+{
+ return lf.lfUnderline != 0;
+}
+
+wxString wxNativeFontInfo::GetFaceName() const
+{
+ return lf.lfFaceName;
+}
+
+wxFontEncoding wxNativeFontInfo::GetEncoding() const
+{
+ return wxGetFontEncFromCharSet(lf.lfCharSet);
+}
+
+void wxNativeFontInfo::SetPointSize(int pointsize)
+{
+#if wxFONT_SIZE_COMPATIBILITY
+ // Incorrect, but compatible with old wxWindows behaviour
+ lf.lfHeight = (pointSize*ppInch)/72;
+#else // wxFONT_SIZE_COMPATIBILITY
+ // FIXME: using the screen here results in incorrect font size calculation
+ // for printing!
+ const int ppInch = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
+
+ lf.lfHeight = -(int)((pointsize*((double)ppInch)/72.0) + 0.5);
+#endif // wxFONT_SIZE_COMPATIBILITY/!wxFONT_SIZE_COMPATIBILITY
+}
+
+void wxNativeFontInfo::SetStyle(wxFontStyle style)
+{
+ switch ( style )
+ {
+ default:
+ wxFAIL_MSG( _T("unknown font style") );
+ // fall through
+
+ case wxFONTSTYLE_NORMAL: