X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/52c8d32a71bb7553dd89324fa6d56faac95eb5d0..03f3617bf36573a7c368614191444364267ed718:/src/dfb/font.cpp diff --git a/src/dfb/font.cpp b/src/dfb/font.cpp index e17ff385fd..83fc2138a6 100644 --- a/src/dfb/font.cpp +++ b/src/dfb/font.cpp @@ -29,82 +29,11 @@ #include "wx/app.h" #endif -#include "wx/fontutil.h" #include "wx/dfb/private.h" +#include "wx/private/fontmgr.h" -// ---------------------------------------------------------------------------- -// wxFontRefData -// ---------------------------------------------------------------------------- - -// FIXME: for now, always use single font -static wxIDirectFBFontPtr gs_font = NULL; -static unsigned gs_fontRefCnt = 0; - -class wxFontRefData : public wxObjectRefData -{ -public: - wxFontRefData(int size = wxDEFAULT, - int family = wxDEFAULT, - int style = wxDEFAULT, - int weight = wxDEFAULT, - bool underlined = false, - const wxString& faceName = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT) - { - if ( family == wxDEFAULT ) - family = wxSWISS; - if ( style == wxDEFAULT ) - style = wxNORMAL; - if ( weight == wxDEFAULT ) - weight = wxNORMAL; - if ( size == wxDEFAULT ) - size = 12; - - m_info.family = (wxFontFamily)family; - m_info.faceName = faceName; - m_info.style = (wxFontStyle)style; - m_info.weight = (wxFontWeight)weight; - m_info.pointSize = size; - m_info.underlined = underlined; - m_info.encoding = encoding; - - // FIXME: always use default font for now - if ( !gs_font ) - { - DFBFontDescription desc; - desc.flags = (DFBFontDescriptionFlags)0; - wxIDirectFBFontPtr f(wxIDirectFB::Get()->CreateFont(NULL, &desc)); - if ( f ) - gs_font = f; - } - if ( gs_font ) // the above may fail - { - gs_fontRefCnt++; - m_font = gs_font; - } - } - - wxFontRefData(const wxFontRefData& data) - { - m_info = data.m_info; - m_font = data.m_font; - } - - ~wxFontRefData() - { - if ( m_font ) - { - m_font.Reset(); - // FIXME - if ( --gs_fontRefCnt == 0 ) - gs_font = NULL; - } - } - - wxNativeFontInfo m_info; - wxIDirectFBFontPtr m_font; -}; - +typedef wxFontMgrFontRefData wxFontRefData; +#define M_FONTDATA ((wxFontRefData*)m_refData) // ---------------------------------------------------------------------------- // wxFont @@ -119,9 +48,9 @@ bool wxFont::Create(const wxNativeFontInfo& info) } bool wxFont::Create(int pointSize, - int family, - int style, - int weight, + wxFontFamily family, + wxFontStyle style, + wxFontWeight weight, bool underlined, const wxString& face, wxFontEncoding encoding) @@ -131,12 +60,12 @@ bool wxFont::Create(int pointSize, return true; } -wxObjectRefData *wxFont::CreateRefData() const +wxGDIRefData *wxFont::CreateGDIRefData() const { return new wxFontRefData; } -wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const +wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const { return new wxFontRefData(*(wxFontRefData *)data); } @@ -146,53 +75,55 @@ wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const // accessors // ---------------------------------------------------------------------------- -wxIDirectFBFontPtr wxFont::GetDirectFBFont() const +wxIDirectFBFontPtr wxFont::GetDirectFBFont(bool antialiased) const { wxCHECK_MSG( Ok(), NULL, wxT("invalid font") ); - return M_FONTDATA->m_font; + // we don't support DC scaling yet, so use scale=1 + wxFontInstance *i = M_FONTDATA->GetFontInstance(1.0, antialiased); + return i ? i->GetDirectFBFont() : wxIDirectFBFontPtr(); } int wxFont::GetPointSize() const { wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); - return M_FONTDATA->m_info.pointSize; + return M_FONTDATA->GetPointSize(); } wxString wxFont::GetFaceName() const { wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") ); - return M_FONTDATA->m_info.faceName; + return M_FONTDATA->GetFaceName(); } -int wxFont::GetFamily() const +wxFontFamily wxFont::GetFamily() const { - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX, wxT("invalid font") ); - return M_FONTDATA->m_info.family; + return M_FONTDATA->GetFamily(); } -int wxFont::GetStyle() const +wxFontStyle wxFont::GetStyle() const { - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX, wxT("invalid font") ); - return M_FONTDATA->m_info.style; + return M_FONTDATA->GetStyle(); } -int wxFont::GetWeight() const +wxFontWeight wxFont::GetWeight() const { - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); + wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX, wxT("invalid font") ); - return M_FONTDATA->m_info.weight; + return M_FONTDATA->GetWeight(); } bool wxFont::GetUnderlined() const { wxCHECK_MSG( Ok(), false, wxT("invalid font") ); - return M_FONTDATA->m_info.underlined; + return M_FONTDATA->GetUnderlined(); } @@ -200,21 +131,28 @@ wxFontEncoding wxFont::GetEncoding() const { wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); - return M_FONTDATA->m_info.encoding; + return M_FONTDATA->GetEncoding(); } bool wxFont::IsFixedWidth() const { wxCHECK_MSG( Ok(), false, wxT("invalid font") ); - return true; // FIXME_DFB + return M_FONTDATA->IsFixedWidth(); } const wxNativeFontInfo *wxFont::GetNativeFontInfo() const { wxCHECK_MSG( Ok(), NULL, wxT("invalid font") ); - return &(M_FONTDATA->m_info); + return M_FONTDATA->GetNativeFontInfo(); +} + +bool wxFont::GetNoAntiAliasing() const +{ + wxCHECK_MSG( Ok(), false, wxT("invalid font") ); + + return M_FONTDATA->GetNoAntiAliasing(); } // ---------------------------------------------------------------------------- @@ -224,50 +162,48 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const void wxFont::SetPointSize(int pointSize) { AllocExclusive(); - - M_FONTDATA->m_info.pointSize = pointSize; + M_FONTDATA->SetPointSize(pointSize); } -void wxFont::SetFamily(int family) +void wxFont::SetFamily(wxFontFamily family) { AllocExclusive(); - - M_FONTDATA->m_info.family = (wxFontFamily)family; + M_FONTDATA->SetFamily(family); } -void wxFont::SetStyle(int style) +void wxFont::SetStyle(wxFontStyle style) { AllocExclusive(); - - M_FONTDATA->m_info.style = (wxFontStyle)style; + M_FONTDATA->SetStyle(style); } -void wxFont::SetWeight(int weight) +void wxFont::SetWeight(wxFontWeight weight) { AllocExclusive(); - - M_FONTDATA->m_info.weight = (wxFontWeight)weight; + M_FONTDATA->SetWeight(weight); } bool wxFont::SetFaceName(const wxString& faceName) { AllocExclusive(); - - M_FONTDATA->m_info.faceName = faceName; - + M_FONTDATA->SetFaceName(faceName); return wxFontBase::SetFaceName(faceName); } void wxFont::SetUnderlined(bool underlined) { AllocExclusive(); - - M_FONTDATA->m_info.underlined = underlined; + M_FONTDATA->SetUnderlined(underlined); } void wxFont::SetEncoding(wxFontEncoding encoding) { AllocExclusive(); + M_FONTDATA->SetEncoding(encoding); +} - M_FONTDATA->m_info.encoding = encoding; +void wxFont::SetNoAntiAliasing(bool no) +{ + AllocExclusive(); + M_FONTDATA->SetNoAntiAliasing(no); }