From 7c55c50ea9780b361937c205074eb4325ce4eafa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 6 May 2006 20:23:36 +0000 Subject: [PATCH] clamp the point size of the font to a reaosnable range (second part of patch 1481722) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39082 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/unix/fontutil.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index 2d04279540..8a9a029b26 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -277,7 +277,32 @@ bool wxNativeFontInfo::FromString(const wxString& s) if (description) pango_font_description_free( description ); - description = pango_font_description_from_string( wxGTK_CONV_SYS( s ) ); + // there is a bug in at least pango <= 1.13 which makes it (or its backends) + // segfault for very big point sizes and for negative point sizes. + // To workaround that bug for pango <= 1.13 + // (see http://bugzilla.gnome.org/show_bug.cgi?id=340229) + // we do the check on the size here using same (arbitrary) limits used by + // pango > 1.13. Note that the segfault could happen also for pointsize + // smaller than this limit !! + wxString str(s); + const size_t pos = str.find_last_of(_T(" ")); + double size; + if ( pos != wxString::npos && wxString(str, pos + 1).ToDouble(&size) ) + { + wxString sizeStr; + if ( size < 1 ) + sizeStr = _T("1"); + else if ( n >= 1E6 ) + sizeStr = _T("1E6"); + + if ( !sizeStr.empty() ) + { + // replace the old size with the adjusted one + str = wxString(s, 0, pos) + sizeStr; + } + } + + description = pango_font_description_from_string( wxGTK_CONV_SYS( str ) ); return true; } -- 2.45.2