From f1b06f854029292c58a040d3e4f31f1737cf7a94 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 19 Mar 2011 12:27:23 +0000 Subject: [PATCH] Fix very poor performance on wxGTK when loading a lot of paragraphs with fonts due to pango calls in font accessors called from FindOrCreateFont. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@67247 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextxml.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index bda4f8c857..3cfe6f4786 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -738,9 +738,9 @@ bool wxRichTextXMLHandler::ExportXML(wxOutputStream& stream, wxMBConv* convMem, { OutputIndentation(stream, indent); OutputString(stream, wxT("<") + objectName, convMem, convFile); - + OutputString(stream, style + wxT(">"), convMem, convFile); - + if (!fragment.empty() && (fragment[0] == wxT(' ') || fragment[fragment.length()-1] == wxT(' '))) { OutputString(stream, wxT("\""), convMem, convFile); @@ -749,7 +749,7 @@ bool wxRichTextXMLHandler::ExportXML(wxOutputStream& stream, wxMBConv* convMem, } else OutputStringEnt(stream, fragment, convMem, convFile); - + OutputString(stream, wxT(""), convMem, convFile); } } @@ -1190,8 +1190,14 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is attr.SetFlags(fontFlags); + // FindOrCreateFont is an expensive operation on GTK+ (because pango functions are called) + // so only use it on other platforms if (attr.HasFlag(wxTEXT_ATTR_FONT)) +#ifdef __WXGTK__ + attr.SetFont(wxFont(fontSize, fontFamily, fontStyle, fontWeight, fontUnderlined, fontFacename)); +#else attr.SetFont(* wxTheFontList->FindOrCreateFont(fontSize, fontFamily, fontStyle, fontWeight, fontUnderlined, fontFacename)); +#endif // Restore correct font flags attr.SetFlags(fontFlags);