[Libreoffice-commits] core.git: vcl/generic vcl/headless vcl/inc vcl/unx
Michael Meeks
michael.meeks at collabora.com
Mon Jun 22 06:56:20 PDT 2015
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 588ab971f2bbf3f81aa6c606aeabc4ba8099c366
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Jun 22 14:02:26 2015 +0100
Re-factor AddTempDevFont to share it with headless backend.
Change-Id: Ic316b18eace3445edef346fe319cbb0e557607fa
Reviewed-on: https://gerrit.libreoffice.org/16412
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index cdb41f8..dfaca3d 100644
--- a/vcl/generic/print/genpspgraphics.cxx
+++ b/vcl/generic/print/genpspgraphics.cxx
@@ -873,6 +873,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 a2acf00..e58c95c 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 5173c65..762b0d2 100644
--- a/vcl/inc/generic/genpspgraphics.h
+++ b/vcl/inc/generic/genpspgraphics.h
@@ -36,6 +36,7 @@ namespace psp { struct JobData; class PrinterGfx; }
class ServerFont;
class ImplDevFontAttributes;
class SalInfoPrinter;
+class GlyphCache;
class VCL_DLLPUBLIC GenPspGraphics : public SalGraphics
{
@@ -100,6 +101,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()
More information about the Libreoffice-commits
mailing list