vcl/generic/print/genpspgraphics.cxx | 37 ++++++++++++++++++++++++++++++++ vcl/headless/svptextrender.cxx | 7 +++--- vcl/inc/generic/genpspgraphics.h | 5 ++++ vcl/unx/generic/gdi/cairotextrender.cxx | 33 ---------------------------- 4 files changed, 47 insertions(+), 35 deletions(-)
New commits: commit 72fe5a608793d0669da5f66030d0eb622b414e7d Author: Michael Meeks <michael.me...@collabora.com> Date: Mon Jun 22 14:02:26 2015 +0100 Re-factor AddTempDevFont to share it with headless backend. Change-Id: Ic316b18eace3445edef346fe319cbb0e557607fa diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx index beedfaa..79e61c6 100644 --- a/vcl/generic/print/genpspgraphics.cxx +++ b/vcl/generic/print/genpspgraphics.cxx @@ -872,6 +872,43 @@ bool GenPspGraphics::AddTempDevFont( PhysicalFontCollection*, const OUString&,co return false; } +bool GenPspGraphics::AddTempDevFontHelper( PhysicalFontCollection* pFontCollection, + const OUString& rFileURL, + const OUString& rFontName, + GlyphCache &rGC ) +{ + // inform PSP font manager + OUString aUSystemPath; + OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFileURL, aUSystemPath ) ); + rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); + OString aOFileName( OUStringToOString( aUSystemPath, aEncoding ) ); + psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); + std::vector<psp::fontID> aFontIds = rMgr.addFontFile( aOFileName ); + if( aFontIds.empty() ) + return false; + + for (std::vector<psp::fontID>::iterator aI = aFontIds.begin(), aEnd = aFontIds.end(); aI != aEnd; ++aI) + { + // prepare font data + psp::FastPrintFontInfo aInfo; + rMgr.getFontFastInfo( *aI, aInfo ); + aInfo.m_aFamilyName = rFontName; + + // inform glyph cache of new font + ImplDevFontAttributes aDFA = GenPspGraphics::Info2DevFontAttributes( aInfo ); + aDFA.mnQuality += 5800; + + int nFaceNum = rMgr.getFontFaceNumber( aInfo.m_nID ); + + const OString& rFileName = rMgr.getFontFileSysPath( aInfo.m_nID ); + rGC.AddFontFile( rFileName, nFaceNum, aInfo.m_nID, aDFA ); + } + + // announce new font to device's font list + rGC.AnnounceFonts( pFontCollection ); + return true; +} + void GenPspGraphics::GetDevFontList( PhysicalFontCollection *pFontCollection ) { ::std::list< psp::fontID > aList; diff --git a/vcl/headless/svptextrender.cxx b/vcl/headless/svptextrender.cxx index f25e534..80969c0 100644 --- a/vcl/headless/svptextrender.cxx +++ b/vcl/headless/svptextrender.cxx @@ -291,10 +291,11 @@ void SvpTextRender::ClearDevFontCache() rGC.ClearFontCache(); } -bool SvpTextRender::AddTempDevFont( PhysicalFontCollection*, - const OUString&, const OUString& ) +bool SvpTextRender::AddTempDevFont( PhysicalFontCollection* pFontCollection, + const OUString& rFileURL, + const OUString& rFontName ) { - return false; + return GenPspGraphics::AddTempDevFontHelper( pFontCollection, rFileURL, rFontName, SvpGlyphCache::GetInstance() ); } bool SvpTextRender::CreateFontSubset( diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h index 8b78faa..1f925cf 100644 --- a/vcl/inc/generic/genpspgraphics.h +++ b/vcl/inc/generic/genpspgraphics.h @@ -35,6 +35,7 @@ namespace psp { struct JobData; class PrinterGfx; } class ServerFont; class ImplDevFontAttributes; class SalInfoPrinter; +class GlyphCache; class VCL_DLLPUBLIC GenPspGraphics : public SalGraphics { @@ -99,6 +100,10 @@ public: virtual bool AddTempDevFont( PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) SAL_OVERRIDE; + static bool AddTempDevFontHelper( PhysicalFontCollection* pFontCollection, + const OUString& rFileURL, + const OUString& rFontName, + GlyphCache &rGC ); virtual bool CreateFontSubset( const OUString& rToFile, const PhysicalFontFace*, diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index a3248b7..ebef272 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -386,38 +386,7 @@ bool CairoTextRender::AddTempDevFont( PhysicalFontCollection* pFontCollection, const OUString& rFileURL, const OUString& rFontName ) { - // inform PSP font manager - OUString aUSystemPath; - OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFileURL, aUSystemPath ) ); - rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); - OString aOFileName( OUStringToOString( aUSystemPath, aEncoding ) ); - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - std::vector<psp::fontID> aFontIds = rMgr.addFontFile( aOFileName ); - if( aFontIds.empty() ) - return false; - - GlyphCache& rGC = getPlatformGlyphCache(); - - for (std::vector<psp::fontID>::iterator aI = aFontIds.begin(), aEnd = aFontIds.end(); aI != aEnd; ++aI) - { - // prepare font data - psp::FastPrintFontInfo aInfo; - rMgr.getFontFastInfo( *aI, aInfo ); - aInfo.m_aFamilyName = rFontName; - - // inform glyph cache of new font - ImplDevFontAttributes aDFA = GenPspGraphics::Info2DevFontAttributes( aInfo ); - aDFA.mnQuality += 5800; - - int nFaceNum = rMgr.getFontFaceNumber( aInfo.m_nID ); - - const OString& rFileName = rMgr.getFontFileSysPath( aInfo.m_nID ); - rGC.AddFontFile( rFileName, nFaceNum, aInfo.m_nID, aDFA ); - } - - // announce new font to device's font list - rGC.AnnounceFonts( pFontCollection ); - return true; + return GenPspGraphics::AddTempDevFontHelper( pFontCollection, rFileURL, rFontName, getPlatformGlyphCache() ); } void CairoTextRender::ClearDevFontCache() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits