summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2013-02-21 23:33:10 +0100
committerDavid Ostrovsky <david@ostrovsky.org>2013-02-21 23:34:47 +0100
commitcad65120c6da901bf9fe33ab16ad22217efed0c0 (patch)
tree1689b74b1ca068d5d4e06b57ab9d35d0e009ee7d /vcl
parenta07dd698bf8044db1c13dbd81a5bc6e62225788c (diff)
Revert "embed also system fonts when embedding fonts in a document"
that's enouph breakage for now. This reverts commit 596bd0f61f8cfc957410148ae221c62331067bdd. Change-Id: I992f439a9a099e47115a30b3d745848f3af09e5e
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vcl.mk2
-rw-r--r--vcl/Package_inc.mk2
-rw-r--r--vcl/generic/fontmanager/fontmanager.cxx2
-rw-r--r--vcl/inc/vcl/temporaryfonts.hxx (renamed from vcl/inc/vcl/embeddedfontshelper.hxx)26
-rw-r--r--vcl/source/app/svmain.cxx6
-rw-r--r--vcl/source/gdi/embeddedfontshelper.cxx104
-rw-r--r--vcl/source/gdi/temporaryfonts.cxx56
7 files changed, 73 insertions, 125 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 49c1c786efae..c71543de585b 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -207,7 +207,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/gdi/configsettings \
vcl/source/gdi/cvtgrf \
vcl/source/gdi/cvtsvm \
- vcl/source/gdi/embeddedfontshelper \
vcl/source/gdi/extoutdevdata \
vcl/source/gdi/font \
vcl/source/gdi/gdimtf \
@@ -256,6 +255,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/gdi/salmisc \
vcl/source/gdi/salnativewidgets-none \
vcl/source/gdi/svgdata \
+ vcl/source/gdi/temporaryfonts \
vcl/source/gdi/textlayout \
vcl/source/gdi/virdev \
vcl/source/gdi/wall \
diff --git a/vcl/Package_inc.mk b/vcl/Package_inc.mk
index 6088b66f2dd3..53a7326279b1 100644
--- a/vcl/Package_inc.mk
+++ b/vcl/Package_inc.mk
@@ -144,7 +144,7 @@ $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/tabctrl.hxx,vcl/tabctrl.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/tabdlg.hxx,vcl/tabdlg.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/tabpage.hxx,vcl/tabpage.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/taskpanelist.hxx,vcl/taskpanelist.hxx))
-$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/embeddedfontshelper.hxx,vcl/embeddedfontshelper.hxx))
+$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/temporaryfonts.hxx,vcl/temporaryfonts.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/textdata.hxx,vcl/textdata.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/texteng.hxx,vcl/texteng.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/textview.hxx,vcl/textview.hxx))
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index c84b15a606c7..b57195505893 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -34,7 +34,7 @@
#include "vcl/fontmanager.hxx"
#include "vcl/strhelper.hxx"
#include "vcl/ppdparser.hxx"
-#include <vcl/embeddedfontshelper.hxx>
+#include <vcl/temporaryfonts.hxx>
#include "tools/urlobj.hxx"
#include "tools/stream.hxx"
diff --git a/vcl/inc/vcl/embeddedfontshelper.hxx b/vcl/inc/vcl/temporaryfonts.hxx
index 96e8226b3b00..f8fe162c67b1 100644
--- a/vcl/inc/vcl/embeddedfontshelper.hxx
+++ b/vcl/inc/vcl/temporaryfonts.hxx
@@ -7,35 +7,31 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#ifndef VCL_EMBEDDEDFONTSHELPER_HXX
-#define VCL_EMBEDDEDFONTSHELPER_HXX
+#ifndef VCL_TEMPORARYFONTS_HXX
+#define VCL_TEMPORARYFONTS_HXX
#include <vcl/dllapi.h>
#include <rtl/ustring.hxx>
-#include <tools/fontenum.hxx>
/**
- Helper functions for handling embedded fonts in documents.
+ Management of temporary fonts (e.g. embedded in documents).
+ This class handles adding of temporary fonts.
+ @since LibreOffice 4.0
*/
-class VCL_DLLPUBLIC EmbeddedFontsHelper
+class VCL_DLLPUBLIC TemporaryFonts
{
public:
/**
- Returns URL for a font file for the given font, or empty if it does not exist.
- */
- static OUString fontFileUrl( const OUString& familyName, FontFamily family, FontItalic italic,
- FontWeight weight, FontPitch pitch, rtl_TextEncoding encoding );
- /**
- Returns an URL for a file where to store contents of a given temporary font.
- The file may or not may not exist yet, and will be cleaned up automatically as appropriate.
+ Returns an URL for a file where to store contents of a temporary font
+ (the file may or may not exist). The file will be cleaned up automatically as appropriate.
Use activateTemporaryFont() to actually enable usage of the font.
@param fontName name of the font (e.g. 'Times New Roman')
@param fontStyle font style, "" for regular, "bi" for bold italic, etc.
*/
- static OUString fileUrlForTemporaryFont( const OUString& fontName, const char* fontStyle );
+ static OUString fileUrlForFont( const OUString& fontName, const char* fontStyle );
/**
Adds the given font to the list of known fonts. The font is used only until application
@@ -47,10 +43,10 @@ public:
static void activateFont( const OUString& fontName, const OUString& fileUrl );
/**
- Removes all temporary fonts in the path used by fileUrlForTemporaryFont().
+ Removes all temporary fonts.
@internal
*/
- static void clearTemporaryFontFiles();
+ static void clear();
};
#endif
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 58cec5773241..9d08192abc9c 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -40,7 +40,7 @@
#include "vcl/unowrap.hxx"
#include "vcl/configsettings.hxx"
#include "vcl/lazydelete.hxx"
-#include "vcl/embeddedfontshelper.hxx"
+#include "vcl/temporaryfonts.hxx"
#ifdef WNT
#include <svsys.h>
@@ -251,7 +251,7 @@ sal_Bool InitVCL()
if( pExceptionHandler != NULL )
return sal_False;
- EmbeddedFontsHelper::clearTemporaryFontFiles();
+ TemporaryFonts::clear();
if( ! ImplGetSVData() )
ImplInitSVData();
@@ -581,7 +581,7 @@ void DeInitVCL()
pOwnSvApp = NULL;
}
- EmbeddedFontsHelper::clearTemporaryFontFiles();
+ TemporaryFonts::clear();
}
// only one call is allowed
diff --git a/vcl/source/gdi/embeddedfontshelper.cxx b/vcl/source/gdi/embeddedfontshelper.cxx
deleted file mode 100644
index b5d1c01d8432..000000000000
--- a/vcl/source/gdi/embeddedfontshelper.cxx
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <vcl/embeddedfontshelper.hxx>
-
-#include <osl/file.hxx>
-#include <rtl/bootstrap.hxx>
-#include <vcl/fontmanager.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/outdev.hxx>
-
-using namespace std;
-
-void EmbeddedFontsHelper::clearTemporaryFontFiles()
-{
- OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
- rtl::Bootstrap::expandMacros( path );
- path += "/user/temp/embeddedfonts/";
- osl::Directory dir( path );
- if( dir.reset() == osl::Directory::E_None )
- {
- 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 EmbeddedFontsHelper::fileUrlForTemporaryFont( const OUString& fontName, const char* fontStyle )
-{
- OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
- rtl::Bootstrap::expandMacros( path );
- path += "/user/temp/embeddedfonts/";
- 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 EmbeddedFontsHelper::activateFont( const OUString& fontName, const OUString& fileUrl )
-{
- OutputDevice *pDevice = Application::GetDefaultDevice();
- pDevice->AddTempDevFont( fileUrl, fontName );
- pDevice->ImplUpdateAllFontData( true );
-}
-
-OUString EmbeddedFontsHelper::fontFileUrl( const OUString& familyName, FontFamily family, FontItalic italic,
- FontWeight weight, FontPitch pitch, rtl_TextEncoding )
-{
- OUString url;
- psp::PrintFontManager& mgr = psp::PrintFontManager::get();
- list< psp::fontID > fontIds;
- mgr.getFontList( fontIds );
- for( list< psp::fontID >::const_iterator it = fontIds.begin();
- it != fontIds.end();
- ++it )
- {
- psp::fontID id = *it;
- psp::FastPrintFontInfo info;
- if( !mgr.getFontFastInfo( id, info ))
- continue;
- if( info.m_aFamilyName == familyName )
- {
- // Ignore comparing text encodings, at least for now. They cannot be trivially compared
- // (e.g. UCS2 and UTF8 are technically the same characters, just have different encoding,
- // and just having a unicode font doesn't say what glyphs it actually contains).
- // It is possible that it still may be needed to do at least some checks here
- // for some encodings (can one font have more font files for more encodings?).
- if(( family == FAMILY_DONTKNOW || info.m_eFamilyStyle == family )
- && ( italic == ITALIC_DONTKNOW || info.m_eItalic == italic )
- && ( weight == WEIGHT_DONTKNOW || info.m_eWeight == weight )
- && ( pitch == PITCH_DONTKNOW || info.m_ePitch == pitch ))
- { // Exact match, return it immediately.
- OUString ret;
- osl::File::getFileURLFromSystemPath(
- OStringToOUString( mgr.getFontFileSysPath( id ), RTL_TEXTENCODING_UTF8 ), ret );
- return ret;
- }
- if(( info.m_eFamilyStyle == FAMILY_DONTKNOW || family == FAMILY_DONTKNOW || info.m_eFamilyStyle == family )
- && ( info.m_eItalic == ITALIC_DONTKNOW || italic == ITALIC_DONTKNOW || info.m_eItalic == italic )
- && ( info.m_eWeight == WEIGHT_DONTKNOW || weight == WEIGHT_DONTKNOW || info.m_eWeight == weight )
- && ( info.m_ePitch == PITCH_DONTKNOW || pitch == PITCH_DONTKNOW || info.m_ePitch == pitch ))
- { // Some fonts specify 'DONTKNOW' for some things, still a good match, if we don't find a better one.
- osl::File::getFileURLFromSystemPath(
- OStringToOUString( mgr.getFontFileSysPath( id ), RTL_TEXTENCODING_UTF8 ), url );
- }
- }
- }
- return url;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/temporaryfonts.cxx b/vcl/source/gdi/temporaryfonts.cxx
new file mode 100644
index 000000000000..292e09e25485
--- /dev/null
+++ b/vcl/source/gdi/temporaryfonts.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <vcl/temporaryfonts.hxx>
+
+#include <osl/file.hxx>
+#include <rtl/bootstrap.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/outdev.hxx>
+
+void TemporaryFonts::clear()
+{
+ OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
+ rtl::Bootstrap::expandMacros( path );
+ path += "/user/temp/fonts/";
+ osl::Directory dir( path );
+ if( dir.reset() == osl::Directory::E_None )
+ {
+ 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 TemporaryFonts::fileUrlForFont( 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 TemporaryFonts::activateFont( const OUString& fontName, const OUString& fileUrl )
+{
+ OutputDevice *pDevice = Application::GetDefaultDevice();
+ pDevice->AddTempDevFont( fileUrl, fontName );
+ pDevice->ImplUpdateAllFontData( true );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */