diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2013-11-26 16:37:16 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-12-04 04:59:47 -0600 |
commit | 24657548a71355e1a087b87d725647793785daa9 (patch) | |
tree | 19995e7809e75e0f592efb8511b467bd7108d942 /vcl/generic | |
parent | 6230cdd2d8971147dcb629c8bd61daa1fefcb7c7 (diff) |
Don't perform printer font substitution
The so called printer resident fonts is a relic of a bygone era, when
life was simple and there was only ASCII and Type1 fonts.
It is just broken by design these days, offers nothing useful and can go
wrong in many ways. Since 1f3a91cf2ace315fb332c0149808a2433eb9ae71 this
"feature" is disabled by default anyway, so scrap this code to make room
for some long due cleanup.
Change-Id: Id124b2cad1a484099701a885c4d96e6a12af8d9a
Reviewed-on: https://gerrit.libreoffice.org/6858
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/generic')
-rw-r--r-- | vcl/generic/print/common_gfx.cxx | 25 | ||||
-rw-r--r-- | vcl/generic/print/genpspgraphics.cxx | 8 | ||||
-rw-r--r-- | vcl/generic/print/printerjob.cxx | 30 | ||||
-rw-r--r-- | vcl/generic/print/text_gfx.cxx | 62 |
4 files changed, 34 insertions, 91 deletions
diff --git a/vcl/generic/print/common_gfx.cxx b/vcl/generic/print/common_gfx.cxx index 05825375fc7b..851739a55898 100644 --- a/vcl/generic/print/common_gfx.cxx +++ b/vcl/generic/print/common_gfx.cxx @@ -60,12 +60,6 @@ PrinterGfx::Init (PrinterJob &rPrinterJob) mnDpi = rPrinterJob.GetResolution(); rPrinterJob.GetScale (mfScaleX, mfScaleY); const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( rPrinterJob.GetPrinterName() ) ); - if( mpFontSubstitutes ) - delete const_cast< ::boost::unordered_map<fontID,fontID>* >(mpFontSubstitutes); - if( rInfo.m_bPerformFontSubstitution ) - mpFontSubstitutes = new ::boost::unordered_map< fontID, fontID >( rInfo.m_aFontSubstitutions ); - else - mpFontSubstitutes = NULL; mbUploadPS42Fonts = rInfo.m_pParser ? ( rInfo.m_pParser->isType42Capable() ? sal_True : sal_False ) : sal_False; return sal_True; @@ -84,12 +78,6 @@ PrinterGfx::Init (const JobData& rData) mfScaleX = (double)72.0 / (double)mnDpi; mfScaleY = (double)72.0 / (double)mnDpi; const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( rData.m_aPrinterName ) ); - if( mpFontSubstitutes ) - delete const_cast< ::boost::unordered_map<fontID,fontID>* >(mpFontSubstitutes); - if( rInfo.m_bPerformFontSubstitution ) - mpFontSubstitutes = new ::boost::unordered_map< fontID, fontID >( rInfo.m_aFontSubstitutions ); - else - mpFontSubstitutes = NULL; mbUploadPS42Fonts = rInfo.m_pParser ? ( rInfo.m_pParser->isType42Capable() ? sal_True : sal_False ) : sal_False; return sal_True; @@ -112,8 +100,7 @@ PrinterGfx::PrinterGfx() : mbCompressBmp (sal_True), maFillColor (0xff,0,0), maTextColor (0,0,0), - maLineColor (0, 0xff, 0), - mpFontSubstitutes( NULL ) + maLineColor (0, 0xff, 0) { maVirtualStatus.mfLineWidth = 1.0; maVirtualStatus.mnTextHeight = 12; @@ -124,16 +111,6 @@ PrinterGfx::PrinterGfx() : PrinterGfx::~PrinterGfx() { - /* - * the original reasoning why mpFontSubstitutes is a pointer was - * that applications should release all PrinterGfx when printers change - * because they are really invalid; the corresponding printers may have - * changed their settings or even not exist anymore. - * - * Alas, this is not always done real time. So we keep a local copy of - * the font substitutes now in case of bad timing. - */ - delete const_cast< ::boost::unordered_map<fontID,fontID>* >(mpFontSubstitutes); } void diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx index 542986a23ca6..682eaa1de950 100644 --- a/vcl/generic/print/genpspgraphics.cxx +++ b/vcl/generic/print/genpspgraphics.cxx @@ -912,14 +912,8 @@ void GenPspGraphics::ClearDevFontCache() GlyphCache::GetInstance().ClearFontCache(); } -void GenPspGraphics::GetDevFontSubstList( OutputDevice* pOutDev ) +void GenPspGraphics::GetDevFontSubstList( OutputDevice* ) { - const psp::PrinterInfo& rInfo = psp::PrinterInfoManager::get().getPrinterInfo( m_pJobData->m_aPrinterName ); - if( rInfo.m_bPerformFontSubstitution ) - { - for( boost::unordered_map< OUString, OUString, OUStringHash >::const_iterator it = rInfo.m_aFontSubstitutes.begin(); it != rInfo.m_aFontSubstitutes.end(); ++it ) - pOutDev->ImplAddDevFontSubstitute( it->first, it->second, FONT_SUBSTITUTE_ALWAYS ); - } } void GenPspGraphics::GetFontMetric( ImplFontMetricData *pMetric, int ) diff --git a/vcl/generic/print/printerjob.cxx b/vcl/generic/print/printerjob.cxx index a979d5c66f96..287f545c6bfb 100644 --- a/vcl/generic/print/printerjob.cxx +++ b/vcl/generic/print/printerjob.cxx @@ -971,30 +971,24 @@ bool PrinterJob::writeSetup( osl::File* pFile, const JobData& rJob ) WritePS (pFile, "%%BeginSetup\n%\n"); // download fonts - std::list< OString > aFonts[2]; - m_pGraphics->writeResources( pFile, aFonts[0], aFonts[1] ); + std::list< OString > aFonts; + m_pGraphics->writeResources( pFile, aFonts ); - for( int i = 0; i < 2; i++ ) + if( !aFonts.empty() ) { - if( !aFonts[i].empty() ) + std::list< OString >::const_iterator it = aFonts.begin(); + OStringBuffer aLine( 256 ); + aLine.append( "%%DocumentSuppliedResources: font " ); + aLine.append( *it ); + aLine.append( "\n" ); + WritePS ( pFile, aLine.getStr() ); + while( (++it) != aFonts.end() ) { - std::list< OString >::const_iterator it = aFonts[i].begin(); - OStringBuffer aLine( 256 ); - if( i == 0 ) - aLine.append( "%%DocumentSuppliedResources: font " ); - else - aLine.append( "%%DocumentNeededResources: font " ); + aLine.setLength(0); + aLine.append( "%%+ font " ); aLine.append( *it ); aLine.append( "\n" ); WritePS ( pFile, aLine.getStr() ); - while( (++it) != aFonts[i].end() ) - { - aLine.setLength(0); - aLine.append( "%%+ font " ); - aLine.append( *it ); - aLine.append( "\n" ); - WritePS ( pFile, aLine.getStr() ); - } } } diff --git a/vcl/generic/print/text_gfx.cxx b/vcl/generic/print/text_gfx.cxx index 7dfa13068c4f..313f3b92e1e7 100644 --- a/vcl/generic/print/text_gfx.cxx +++ b/vcl/generic/print/text_gfx.cxx @@ -36,42 +36,39 @@ using namespace psp ; namespace psp { /* container for a font and its helper fonts: - 1st font is the font substitute e.g. helvetica substitutes arial on the printer - 2nd is the font itself - 3rd is a fallback font, usually a font with unicode glyph repertoir (e.g. andale) + 1st is the font itself + 2nd is a fallback font, usually a font with unicode glyph repertoir (e.g. andale) symbol fonts (adobe-fontspecific) may need special glyphmapping (symbol page vc. latin page) */ -class Font3 +class Font2 { private: - #define Font3Size 3 + #define Font2Size 2 - fontID mpFont [Font3Size]; + fontID mpFont [Font2Size]; bool mbSymbol; public: fontID GetFont (int nIdx) const - { return nIdx < Font3Size ? mpFont[nIdx] : -1 ; } + { return nIdx < Font2Size ? mpFont[nIdx] : -1 ; } bool IsSymbolFont () const { return mbSymbol; } - Font3 (const PrinterGfx &rGfx); - ~Font3 () {} + Font2 (const PrinterGfx &rGfx); + ~Font2 () {} }; -Font3::Font3(const PrinterGfx &rGfx) +Font2::Font2(const PrinterGfx &rGfx) { - mpFont[0] = rGfx.getFontSubstitute(); - mpFont[1] = rGfx.GetFontID(); - mpFont[2] = rGfx.getFallbackID(); - // mpFont[2] = rGfx.GetFontID(); - - PrintFontManager &rMgr = PrintFontManager::get(); - mbSymbol = mpFont[1] != -1 ? - rMgr.getFontEncoding(mpFont[1]) == RTL_TEXTENCODING_SYMBOL : false; + mpFont[0] = rGfx.GetFontID(); + mpFont[1] = rGfx.getFallbackID(); + + PrintFontManager &rMgr = PrintFontManager::get(); + mbSymbol = mpFont[0] != -1 ? + rMgr.getFontEncoding(mpFont[0]) == RTL_TEXTENCODING_SYMBOL : false; } } // namespace psp @@ -311,7 +308,7 @@ PrinterGfx::DrawText ( // setup font[substitutes] and map the string into the symbol area in case of // symbol font - Font3 aFont(*this); + Font2 aFont(*this); sal_Unicode *pEffectiveStr; if ( aFont.IsSymbolFont() ) { @@ -610,12 +607,12 @@ PrinterGfx::getCharWidth (sal_Bool b_vert, sal_Unicode n_char, CharacterMetric * } fontID -PrinterGfx::getCharMetric (const Font3 &rFont, sal_Unicode n_char, CharacterMetric *p_bbox) +PrinterGfx::getCharMetric (const Font2 &rFont, sal_Unicode n_char, CharacterMetric *p_bbox) { p_bbox->width = -1; p_bbox->height = -1; - for (fontID n = 0; n < 3; n++) + for (fontID n = 0; n < Font2Size; n++) { fontID n_font = rFont.GetFont(n); if (n_font != -1) @@ -629,24 +626,10 @@ PrinterGfx::getCharMetric (const Font3 &rFont, sal_Unicode n_char, CharacterMetr return rFont.GetFont(0) != -1 ? rFont.GetFont(0) : rFont.GetFont(1); } -fontID -PrinterGfx::getFontSubstitute () const -{ - if( mpFontSubstitutes ) - { - ::boost::unordered_map< fontID, fontID >::const_iterator it = - mpFontSubstitutes->find( mnFontID ); - if( it != mpFontSubstitutes->end() ) - return it->second; - } - - return -1; -} - sal_Int32 PrinterGfx::GetCharWidth (sal_Unicode nFrom, sal_Unicode nTo, long *pWidthArray) { - Font3 aFont(*this); + Font2 aFont(*this); if (aFont.IsSymbolFont() && (nFrom < 256) && (nTo < 256)) { nFrom += 0xF000; @@ -684,7 +667,7 @@ PrinterGfx::OnEndJob () } void -PrinterGfx::writeResources( osl::File* pFile, std::list< OString >& rSuppliedFonts, std::list< OString >& rNeededFonts ) +PrinterGfx::writeResources( osl::File* pFile, std::list< OString >& rSuppliedFonts ) { // write all type 1 fonts std::list< sal_Int32 >::iterator aFont; @@ -739,11 +722,6 @@ PrinterGfx::writeResources( osl::File* pFile, std::list< OString >& rSuppliedFon // || aIter->GetFontType() == fonttype::Builtin ) { aIter->PSUploadEncoding (pFile, *this); - if( aIter->GetFontType() == fonttype::Builtin ) - rNeededFonts.push_back( - OUStringToOString( - mrFontMgr.getPSName( aIter->GetFontID() ), - RTL_TEXTENCODING_ASCII_US ) ); } } } |