diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-09-03 18:07:34 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-09-06 17:35:45 +0200 |
commit | b7e56788135c1c6179cbc5387e41a66a85a7460b (patch) | |
tree | 3ad9a41dc98f3eb9b4090f3ff7c6cf6147e9f179 /vcl/generic | |
parent | c1c8adca05b561afbbf3346b73225d80f2b82ee4 (diff) |
basic support for temporary fonts
To be used when loading fonts embedded in documents.
Change-Id: I634af1b35eba48872d045e726d1d879f455d6f2c
Diffstat (limited to 'vcl/generic')
-rw-r--r-- | vcl/generic/fontmanager/fontmanager.cxx | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx index 2a3d29ae8293..7b9294aeecdf 100644 --- a/vcl/generic/fontmanager/fontmanager.cxx +++ b/vcl/generic/fontmanager/fontmanager.cxx @@ -43,6 +43,8 @@ #include "vcl/fontmanager.hxx" #include "vcl/strhelper.hxx" #include "vcl/ppdparser.hxx" +#include <vcl/svapp.hxx> +#include <vcl/outdev.hxx> #include "tools/urlobj.hxx" #include "tools/stream.hxx" @@ -51,6 +53,7 @@ #include "osl/file.hxx" #include "osl/process.h" +#include <rtl/bootstrap.hxx> #include "rtl/tencinfo.h" #include "rtl/ustrbuf.hxx" #include "rtl/strbuf.hxx" @@ -1034,6 +1037,7 @@ PrintFontManager::~PrintFontManager() delete m_pAtoms; if( m_pFontCache ) delete m_pFontCache; + cleanTemporaryFonts(); } // ------------------------------------------------------------------------- @@ -1660,6 +1664,8 @@ void PrintFontManager::initialize() CALLGRIND_ZERO_STATS(); #endif + cleanTemporaryFonts(); + long aDirEntBuffer[ (sizeof(struct dirent)+_PC_NAME_MAX)+1 ]; if( ! m_pFontCache ) @@ -3057,4 +3063,41 @@ bool PrintFontManager::readOverrideMetrics() return true; } +void PrintFontManager::cleanTemporaryFonts() +{ + OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}"; + rtl::Bootstrap::expandMacros( path ); + path += "/user/temp/fonts/"; + osl::Directory dir( path ); + dir.reset(); + for(;;) + { + osl::DirectoryItem item; + if( dir.getNextItem( item ) != osl::Directory::E_None ) + break; + osl::FileStatus status( osl_FileStatus_Mask_FileURL ); + if( item.getFileStatus( status ) == osl::File::E_None ) + osl::File::remove( status.getFileURL()); + } +} + +OUString PrintFontManager::fileUrlForTemporaryFont( const OUString& fontName, const char* fontStyle ) +{ + OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}"; + rtl::Bootstrap::expandMacros( path ); + path += "/user/temp/fonts/"; + osl::Directory::createPath( path ); + OUString filename = fontName; + filename += OStringToOUString( fontStyle, RTL_TEXTENCODING_ASCII_US ); + filename += ".ttf"; // TODO is it always ttf? + return path + filename; +} + +void PrintFontManager::activateTemporaryFont( const OUString& fontName, const OUString& fileUrl ) +{ + OutputDevice *pDevice = Application::GetDefaultDevice(); + pDevice->AddTempDevFont( fileUrl, fontName ); + pDevice->ImplUpdateAllFontData( true ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |