diff --git a/docs/changes.txt b/docs/changes.txt index 75cee4d718..911bf19aec 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -126,6 +126,7 @@ All (GUI): - Fix drawing rotated and/or underlined text on wxPostScriptDC. - Support multiline strings in wxPostScriptDC::DrawText(), DrawRotatedText(). - Deprecate wxEVT_STC_KEY and wxEVT_STC_URIDROPPED events (NewPagodi). +- Optimize font registration in PostScript code emitted by wxPostScriptDC. wxGTK: diff --git a/include/wx/generic/dcpsg.h b/include/wx/generic/dcpsg.h index dc09c24ba0..636a4a8ef2 100644 --- a/include/wx/generic/dcpsg.h +++ b/include/wx/generic/dcpsg.h @@ -150,6 +150,7 @@ protected: double m_underlineThickness; wxPrintData m_printData; double m_pageHeight; + wxArrayString m_definedPSFonts; private: wxDECLARE_DYNAMIC_CLASS(wxPostScriptDCImpl); diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 7f699bb0fc..303653cd3d 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -1124,8 +1124,13 @@ void wxPostScriptDCImpl::SetFont( const wxFont& font ) if (!m_pstream) return; - PsPrint( name ); - PsPrint( " reencodeISO def\n" ); + // Generate PS code to register the font only once. + if ( m_definedPSFonts.Index(name) == wxNOT_FOUND ) + { + PsPrint( name ); + PsPrint( " reencodeISO def\n" ); + m_definedPSFonts.Add(name); + } PsPrint( name ); PsPrint( " findfont\n" ); @@ -1784,6 +1789,9 @@ bool wxPostScriptDCImpl::StartDoc( const wxString& WXUNUSED(message) ) SetDeviceOrigin( 0,0 ); m_pageNumber = 1; + // Reset the list of fonts for which PS font registration code was generated. + m_definedPSFonts.Empty(); + return true; } @@ -1802,6 +1810,9 @@ void wxPostScriptDCImpl::EndDoc () m_pstream = NULL; } + // Reset the list of fonts for which PS font registration code was generated. + m_definedPSFonts.Empty(); + #if 0 // THE FOLLOWING HAS BEEN CONTRIBUTED BY Andy Fyfe wxCoord wx_printer_translate_x, wx_printer_translate_y;