X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f9671150978a0bbb5d5b52f1442e3e3e3d023871..4888e623a6869c6af62cfe42da6303f9c8870585:/src/gtk1/font.cpp diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index 1da01a2ed0..940b38d81a 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -146,37 +146,6 @@ wxFontRefData::~wxFontRefData() } } -// ---------------------------------------------------------------------------- -// wxNativeFontInfo -// ---------------------------------------------------------------------------- - -bool wxNativeFontInfo::FromString(const wxString& s) -{ - wxStringTokenizer tokenizer(s, _T(";")); - - wxString token = tokenizer.GetNextToken(); - // - // Ignore the version for now - // - - xFontName = tokenizer.GetNextToken(); - if(!xFontName) - return FALSE; - - return TRUE; -} - -wxString wxNativeFontInfo::ToString() const -{ - wxString s; - - s.Printf(_T("%d;%s"), - 0, // version - xFontName.c_str()); - - return s; -} - // ---------------------------------------------------------------------------- // wxFont // ---------------------------------------------------------------------------- @@ -185,8 +154,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) void wxFont::Init() { - if (wxTheFontList) - wxTheFontList->Append( this ); } wxFont::wxFont(const wxNativeFontInfo& info) @@ -219,7 +186,7 @@ bool wxFont::Create(const wxString& fontname, wxFontEncoding enc) { if( !fontname ) { - *this = wxSystemSettings::GetSystemFont( wxSYS_DEFAULT_GUI_FONT); + *this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT); return TRUE; } @@ -334,14 +301,17 @@ void wxFont::Unshare() wxFont::~wxFont() { - if (wxTheFontList) - wxTheFontList->DeleteObject( this ); } // ---------------------------------------------------------------------------- // accessors // ---------------------------------------------------------------------------- +bool wxFont::HasNativeFont() const +{ + return !M_FONTDATA->m_nativeFontInfo.xFontName.empty(); +} + int wxFont::GetPointSize() const { wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); @@ -402,6 +372,21 @@ wxNativeFontInfo *wxFont::GetNativeFontInfo() const return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo); } +bool wxFont::IsFixedWidth() const +{ + wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") ); + + if ( HasNativeFont() ) + { + // the monospace fonts are supposed to have "M" in the spacing field + wxString spacing = M_FONTDATA-> + m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING); + + return spacing.Upper() == _T('M'); + } + + return wxFontBase::IsFixedWidth(); +} // ---------------------------------------------------------------------------- // change font attributes @@ -493,6 +478,12 @@ GdkFont *GtkGetDefaultGuiFont() } gtk_widget_destroy( widget ); } + else + { + // already have it, but ref it once more before returning + gdk_font_ref(g_systemDefaultGuiFont); + } + return g_systemDefaultGuiFont; } @@ -516,7 +507,7 @@ GdkFont *wxFont::GetInternalFont( float scale ) const } else { - if (*this == wxSystemSettings::GetSystemFont( wxSYS_DEFAULT_GUI_FONT)) + if (*this == wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT)) { font = GtkGetDefaultGuiFont(); }