+ wxFontRefData(const wxNativeFontInfo& info)
+ {
+ Init(info);
+ }
+
+ virtual ~wxFontRefData();
+
+protected:
+ // common part of all ctors
+ void Init(int size,
+ int family,
+ int style,
+ int weight,
+ bool underlined,
+ const wxString& faceName,
+ wxFontEncoding encoding);
+
+ void Init(const wxNativeFontInfo& info);
+
+ // If TRUE, the pointer to the actual font is temporary and SHOULD NOT BE
+ // DELETED by destructor
+ bool m_temporary;
+
+ int m_fontId;
+
+ // font characterstics
+ int m_pointSize;
+ int m_family;
+ int m_style;
+ int m_weight;
+ bool m_underlined;
+ wxString m_faceName;
+ wxFontEncoding m_encoding;
+
+ // Windows font handle
+ WXHFONT m_hFont;
+
+ // Native font info
+ wxNativeFontInfo m_nativeFontInfo;
+ bool m_nativeFontInfoOk;
+};
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxFontRefData
+// ----------------------------------------------------------------------------
+
+void wxFontRefData::Init(int pointSize,
+ int family,
+ int style,
+ int weight,
+ bool underlined,
+ const wxString& faceName,
+ wxFontEncoding encoding)
+{
+ m_style = style;
+ m_pointSize = pointSize;
+ m_family = family;
+ m_style = style;
+ m_weight = weight;
+ m_underlined = underlined;
+ m_faceName = faceName;
+ m_encoding = encoding;
+
+ m_fontId = 0;
+ m_temporary = FALSE;
+
+ m_hFont = 0;
+
+ m_nativeFontInfoOk = FALSE;
+}
+
+void wxFontRefData::Init(const wxNativeFontInfo& info)
+{
+ // extract family from pitch-and-family
+ int lfFamily = info.lf.lfPitchAndFamily;
+ if ( lfFamily & FIXED_PITCH )
+ lfFamily -= FIXED_PITCH;
+ if ( lfFamily & VARIABLE_PITCH )
+ lfFamily -= VARIABLE_PITCH;
+
+ switch ( lfFamily )
+ {
+ case FF_ROMAN:
+ m_family = wxROMAN;
+ break;
+
+ case FF_SWISS:
+ m_family = wxSWISS;
+ break;
+
+ case FF_SCRIPT:
+ m_family = wxSCRIPT;
+ break;
+
+ case FF_MODERN:
+ m_family = wxMODERN;
+ break;
+
+ case FF_DECORATIVE:
+ m_family = wxDECORATIVE;
+ break;
+
+ default:
+ m_family = wxSWISS;
+ }
+
+ // weight and style
+ switch ( info.lf.lfWeight )
+ {
+ case FW_LIGHT:
+ m_weight = wxLIGHT;
+ break;
+
+ default:
+ case FW_NORMAL:
+ m_weight = wxNORMAL;
+ break;
+
+ case FW_BOLD:
+ m_weight = wxBOLD;
+ break;
+ }
+
+ m_style = info.lf.lfItalic ? wxITALIC : wxNORMAL;
+
+ m_underlined = info.lf.lfUnderline != 0;
+
+ m_faceName = info.lf.lfFaceName;
+
+ // remember that 1pt = 1/72inch
+ int height = abs(info.lf.lfHeight);
+
+#if wxUSE_SCREEN_DPI
+ HDC dc = ::GetDC(NULL);
+ static const int ppInch = GetDeviceCaps(dc, LOGPIXELSY);
+ ::ReleaseDC(NULL, dc);
+#else
+ static const int ppInch = 96;