X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/873fd4af5f9ed1f078636af1ae9ea21bbed06b5a..457e5a40e7d49f761887208f1874cb31068a31f1:/src/dfb/font.cpp?ds=sidebyside diff --git a/src/dfb/font.cpp b/src/dfb/font.cpp index f33dd66e8f..4bf8087c5b 100644 --- a/src/dfb/font.cpp +++ b/src/dfb/font.cpp @@ -29,84 +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; -}; - -#define M_FONTDATA (wxFontRefData*)m_refData) - +typedef wxFontMgrFontRefData wxFontRefData; +#define M_FONTDATA ((wxFontRefData*)m_refData) // ---------------------------------------------------------------------------- // wxFont @@ -148,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 { wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); - return M_FONTDATA->m_info.family; + return M_FONTDATA->GetFamily(); } int wxFont::GetStyle() const { wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); - return M_FONTDATA->m_info.style; + return M_FONTDATA->GetStyle(); } int wxFont::GetWeight() const { wxCHECK_MSG( Ok(), 0, 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(); } @@ -202,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(); } // ---------------------------------------------------------------------------- @@ -226,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) { AllocExclusive(); - - M_FONTDATA->m_info.family = (wxFontFamily)family; + M_FONTDATA->SetFamily(family); } void wxFont::SetStyle(int style) { AllocExclusive(); - - M_FONTDATA->m_info.style = (wxFontStyle)style; + M_FONTDATA->SetStyle(style); } void wxFont::SetWeight(int 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); }