Kaydet (Commit) 72fe5a60 authored tarafından Michael Meeks's avatar Michael Meeks

Re-factor AddTempDevFont to share it with headless backend.

Change-Id: Ic316b18eace3445edef346fe319cbb0e557607fa
üst 801f24f0
......@@ -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;
......
......@@ -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(
......
......@@ -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*,
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment