#endif
#ifndef WX_PRECOMP
- #include <stdio.h>
#include "wx/setup.h"
#include "wx/list.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/font.h"
+ #include "wx/log.h"
#endif // WX_PRECOMP
+#include "wx/fontutil.h"
+
#include "wx/msw/private.h"
-#if !USE_SHARED_LIBRARIES
- IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
+IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
- #if wxUSE_PORTABLE_FONTS_IN_MSW
- IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory, wxObject)
- #endif
-#endif
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// the default font size in points
+static const int wxDEFAULT_FONT_SIZE = 12;
// ----------------------------------------------------------------------------
// wxFontRefData - the internal description of the font
public:
wxFontRefData()
{
- Init(12, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
+ Init(wxDEFAULT_FONT_SIZE, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
"", wxFONTENCODING_DEFAULT);
}
{
if ( !::DeleteObject((HFONT) m_hFont) )
{
- wxLogLastError("DeleteObject(font)");
+ wxLogLastError(wxT("DeleteObject(font)"));
}
}
}
wxTheFontList->Append(this);
}
+bool wxFont::Create(const wxNativeFontInfo& info)
+{
+ return Create(info.pointSize, info.family, info.style, info.weight,
+ info.underlined, info.faceName, info.encoding);
+}
+
+wxFont::wxFont(const wxString& fontdesc)
+{
+ wxNativeFontInfo info;
+ if ( info.FromString(fontdesc) )
+ (void)Create(info);
+}
+
/* Constructor for a font. Note that the real construction is done
* in wxDC::SetFont, when information is available about scaling etc.
*/
wxFontEncoding encoding)
{
UnRef();
+
+ // wxDEFAULT is a valid value for the font size too so we must treat it
+ // specially here (otherwise the size would be 70 == wxDEFAULT value)
+ if ( pointSize == wxDEFAULT )
+ pointSize = wxDEFAULT_FONT_SIZE;
+
m_refData = new wxFontRefData(pointSize, family, style, weight,
underlined, faceName, encoding);
{
// VZ: the old code returned FALSE in this case, but it doesn't seem
// to make sense because the font _was_ created
- wxLogDebug(wxT("Calling wxFont::RealizeResource() twice"));
-
return TRUE;
}
LOGFONT lf;
wxFillLogFont(&lf, this);
M_FONTDATA->m_hFont = (WXHFONT)::CreateFontIndirect(&lf);
+ M_FONTDATA->m_faceName = lf.lfFaceName;
if ( !M_FONTDATA->m_hFont )
{
- wxLogLastError("CreateFont");
+ wxLogLastError(wxT("CreateFont"));
return FALSE;
}
{
if ( !::DeleteObject((HFONT) M_FONTDATA->m_hFont) )
{
- wxLogLastError("DeleteObject(font)");
+ wxLogLastError(wxT("DeleteObject(font)"));
}
M_FONTDATA->m_hFont = 0;
}
WXHANDLE wxFont::GetResourceHandle()
+{
+ return GetHFONT();
+}
+
+WXHFONT wxFont::GetHFONT() const
{
if ( !M_FONTDATA )
return 0;