summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2013-11-26 16:37:16 +0200
committerCaolán McNamara <caolanm@redhat.com>2013-12-04 04:59:47 -0600
commit24657548a71355e1a087b87d725647793785daa9 (patch)
tree19995e7809e75e0f592efb8511b467bd7108d942 /vcl
parent6230cdd2d8971147dcb629c8bd61daa1fefcb7c7 (diff)
Don't perform printer font substitution
The so called printer resident fonts is a relic of a bygone era, when life was simple and there was only ASCII and Type1 fonts. It is just broken by design these days, offers nothing useful and can go wrong in many ways. Since 1f3a91cf2ace315fb332c0149808a2433eb9ae71 this "feature" is disabled by default anyway, so scrap this code to make room for some long due cleanup. Change-Id: Id124b2cad1a484099701a885c4d96e6a12af8d9a Reviewed-on: https://gerrit.libreoffice.org/6858 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/generic/print/common_gfx.cxx25
-rw-r--r--vcl/generic/print/genpspgraphics.cxx8
-rw-r--r--vcl/generic/print/printerjob.cxx30
-rw-r--r--vcl/generic/print/text_gfx.cxx62
-rw-r--r--vcl/inc/generic/printergfx.hxx14
-rw-r--r--vcl/null/printerinfomanager.cxx5
-rw-r--r--vcl/unx/generic/printer/printerinfomanager.cxx153
7 files changed, 41 insertions, 256 deletions
diff --git a/vcl/generic/print/common_gfx.cxx b/vcl/generic/print/common_gfx.cxx
index 05825375fc7b..851739a55898 100644
--- a/vcl/generic/print/common_gfx.cxx
+++ b/vcl/generic/print/common_gfx.cxx
@@ -60,12 +60,6 @@ PrinterGfx::Init (PrinterJob &rPrinterJob)
mnDpi = rPrinterJob.GetResolution();
rPrinterJob.GetScale (mfScaleX, mfScaleY);
const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( rPrinterJob.GetPrinterName() ) );
- if( mpFontSubstitutes )
- delete const_cast< ::boost::unordered_map<fontID,fontID>* >(mpFontSubstitutes);
- if( rInfo.m_bPerformFontSubstitution )
- mpFontSubstitutes = new ::boost::unordered_map< fontID, fontID >( rInfo.m_aFontSubstitutions );
- else
- mpFontSubstitutes = NULL;
mbUploadPS42Fonts = rInfo.m_pParser ? ( rInfo.m_pParser->isType42Capable() ? sal_True : sal_False ) : sal_False;
return sal_True;
@@ -84,12 +78,6 @@ PrinterGfx::Init (const JobData& rData)
mfScaleX = (double)72.0 / (double)mnDpi;
mfScaleY = (double)72.0 / (double)mnDpi;
const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( rData.m_aPrinterName ) );
- if( mpFontSubstitutes )
- delete const_cast< ::boost::unordered_map<fontID,fontID>* >(mpFontSubstitutes);
- if( rInfo.m_bPerformFontSubstitution )
- mpFontSubstitutes = new ::boost::unordered_map< fontID, fontID >( rInfo.m_aFontSubstitutions );
- else
- mpFontSubstitutes = NULL;
mbUploadPS42Fonts = rInfo.m_pParser ? ( rInfo.m_pParser->isType42Capable() ? sal_True : sal_False ) : sal_False;
return sal_True;
@@ -112,8 +100,7 @@ PrinterGfx::PrinterGfx() :
mbCompressBmp (sal_True),
maFillColor (0xff,0,0),
maTextColor (0,0,0),
- maLineColor (0, 0xff, 0),
- mpFontSubstitutes( NULL )
+ maLineColor (0, 0xff, 0)
{
maVirtualStatus.mfLineWidth = 1.0;
maVirtualStatus.mnTextHeight = 12;
@@ -124,16 +111,6 @@ PrinterGfx::PrinterGfx() :
PrinterGfx::~PrinterGfx()
{
- /*
- * the original reasoning why mpFontSubstitutes is a pointer was
- * that applications should release all PrinterGfx when printers change
- * because they are really invalid; the corresponding printers may have
- * changed their settings or even not exist anymore.
- *
- * Alas, this is not always done real time. So we keep a local copy of
- * the font substitutes now in case of bad timing.
- */
- delete const_cast< ::boost::unordered_map<fontID,fontID>* >(mpFontSubstitutes);
}
void
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index 542986a23ca6..682eaa1de950 100644
--- a/vcl/generic/print/genpspgraphics.cxx
+++ b/vcl/generic/print/genpspgraphics.cxx
@@ -912,14 +912,8 @@ void GenPspGraphics::ClearDevFontCache()
GlyphCache::GetInstance().ClearFontCache();
}
-void GenPspGraphics::GetDevFontSubstList( OutputDevice* pOutDev )
+void GenPspGraphics::GetDevFontSubstList( OutputDevice* )
{
- const psp::PrinterInfo& rInfo = psp::PrinterInfoManager::get().getPrinterInfo( m_pJobData->m_aPrinterName );
- if( rInfo.m_bPerformFontSubstitution )
- {
- for( boost::unordered_map< OUString, OUString, OUStringHash >::const_iterator it = rInfo.m_aFontSubstitutes.begin(); it != rInfo.m_aFontSubstitutes.end(); ++it )
- pOutDev->ImplAddDevFontSubstitute( it->first, it->second, FONT_SUBSTITUTE_ALWAYS );
- }
}
void GenPspGraphics::GetFontMetric( ImplFontMetricData *pMetric, int )
diff --git a/vcl/generic/print/printerjob.cxx b/vcl/generic/print/printerjob.cxx
index a979d5c66f96..287f545c6bfb 100644
--- a/vcl/generic/print/printerjob.cxx
+++ b/vcl/generic/print/printerjob.cxx
@@ -971,30 +971,24 @@ bool PrinterJob::writeSetup( osl::File* pFile, const JobData& rJob )
WritePS (pFile, "%%BeginSetup\n%\n");
// download fonts
- std::list< OString > aFonts[2];
- m_pGraphics->writeResources( pFile, aFonts[0], aFonts[1] );
+ std::list< OString > aFonts;
+ m_pGraphics->writeResources( pFile, aFonts );
- for( int i = 0; i < 2; i++ )
+ if( !aFonts.empty() )
{
- if( !aFonts[i].empty() )
+ std::list< OString >::const_iterator it = aFonts.begin();
+ OStringBuffer aLine( 256 );
+ aLine.append( "%%DocumentSuppliedResources: font " );
+ aLine.append( *it );
+ aLine.append( "\n" );
+ WritePS ( pFile, aLine.getStr() );
+ while( (++it) != aFonts.end() )
{
- std::list< OString >::const_iterator it = aFonts[i].begin();
- OStringBuffer aLine( 256 );
- if( i == 0 )
- aLine.append( "%%DocumentSuppliedResources: font " );
- else
- aLine.append( "%%DocumentNeededResources: font " );
+ aLine.setLength(0);
+ aLine.append( "%%+ font " );
aLine.append( *it );
aLine.append( "\n" );
WritePS ( pFile, aLine.getStr() );
- while( (++it) != aFonts[i].end() )
- {
- aLine.setLength(0);
- aLine.append( "%%+ font " );
- aLine.append( *it );
- aLine.append( "\n" );
- WritePS ( pFile, aLine.getStr() );
- }
}
}
diff --git a/vcl/generic/print/text_gfx.cxx b/vcl/generic/print/text_gfx.cxx
index 7dfa13068c4f..313f3b92e1e7 100644
--- a/vcl/generic/print/text_gfx.cxx
+++ b/vcl/generic/print/text_gfx.cxx
@@ -36,42 +36,39 @@ using namespace psp ;
namespace psp {
/*
container for a font and its helper fonts:
- 1st font is the font substitute e.g. helvetica substitutes arial on the printer
- 2nd is the font itself
- 3rd is a fallback font, usually a font with unicode glyph repertoir (e.g. andale)
+ 1st is the font itself
+ 2nd is a fallback font, usually a font with unicode glyph repertoir (e.g. andale)
symbol fonts (adobe-fontspecific) may need special glyphmapping
(symbol page vc. latin page)
*/
-class Font3
+class Font2
{
private:
- #define Font3Size 3
+ #define Font2Size 2
- fontID mpFont [Font3Size];
+ fontID mpFont [Font2Size];
bool mbSymbol;
public:
fontID GetFont (int nIdx) const
- { return nIdx < Font3Size ? mpFont[nIdx] : -1 ; }
+ { return nIdx < Font2Size ? mpFont[nIdx] : -1 ; }
bool IsSymbolFont () const
{ return mbSymbol; }
- Font3 (const PrinterGfx &rGfx);
- ~Font3 () {}
+ Font2 (const PrinterGfx &rGfx);
+ ~Font2 () {}
};
-Font3::Font3(const PrinterGfx &rGfx)
+Font2::Font2(const PrinterGfx &rGfx)
{
- mpFont[0] = rGfx.getFontSubstitute();
- mpFont[1] = rGfx.GetFontID();
- mpFont[2] = rGfx.getFallbackID();
- // mpFont[2] = rGfx.GetFontID();
-
- PrintFontManager &rMgr = PrintFontManager::get();
- mbSymbol = mpFont[1] != -1 ?
- rMgr.getFontEncoding(mpFont[1]) == RTL_TEXTENCODING_SYMBOL : false;
+ mpFont[0] = rGfx.GetFontID();
+ mpFont[1] = rGfx.getFallbackID();
+
+ PrintFontManager &rMgr = PrintFontManager::get();
+ mbSymbol = mpFont[0] != -1 ?
+ rMgr.getFontEncoding(mpFont[0]) == RTL_TEXTENCODING_SYMBOL : false;
}
} // namespace psp
@@ -311,7 +308,7 @@ PrinterGfx::DrawText (
// setup font[substitutes] and map the string into the symbol area in case of
// symbol font
- Font3 aFont(*this);
+ Font2 aFont(*this);
sal_Unicode *pEffectiveStr;
if ( aFont.IsSymbolFont() )
{
@@ -610,12 +607,12 @@ PrinterGfx::getCharWidth (sal_Bool b_vert, sal_Unicode n_char, CharacterMetric *
}
fontID
-PrinterGfx::getCharMetric (const Font3 &rFont, sal_Unicode n_char, CharacterMetric *p_bbox)
+PrinterGfx::getCharMetric (const Font2 &rFont, sal_Unicode n_char, CharacterMetric *p_bbox)
{
p_bbox->width = -1;
p_bbox->height = -1;
- for (fontID n = 0; n < 3; n++)
+ for (fontID n = 0; n < Font2Size; n++)
{
fontID n_font = rFont.GetFont(n);
if (n_font != -1)
@@ -629,24 +626,10 @@ PrinterGfx::getCharMetric (const Font3 &rFont, sal_Unicode n_char, CharacterMetr
return rFont.GetFont(0) != -1 ? rFont.GetFont(0) : rFont.GetFont(1);
}
-fontID
-PrinterGfx::getFontSubstitute () const
-{
- if( mpFontSubstitutes )
- {
- ::boost::unordered_map< fontID, fontID >::const_iterator it =
- mpFontSubstitutes->find( mnFontID );
- if( it != mpFontSubstitutes->end() )
- return it->second;
- }
-
- return -1;
-}
-
sal_Int32
PrinterGfx::GetCharWidth (sal_Unicode nFrom, sal_Unicode nTo, long *pWidthArray)
{
- Font3 aFont(*this);
+ Font2 aFont(*this);
if (aFont.IsSymbolFont() && (nFrom < 256) && (nTo < 256))
{
nFrom += 0xF000;
@@ -684,7 +667,7 @@ PrinterGfx::OnEndJob ()
}
void
-PrinterGfx::writeResources( osl::File* pFile, std::list< OString >& rSuppliedFonts, std::list< OString >& rNeededFonts )
+PrinterGfx::writeResources( osl::File* pFile, std::list< OString >& rSuppliedFonts )
{
// write all type 1 fonts
std::list< sal_Int32 >::iterator aFont;
@@ -739,11 +722,6 @@ PrinterGfx::writeResources( osl::File* pFile, std::list< OString >& rSuppliedFon
// || aIter->GetFontType() == fonttype::Builtin )
{
aIter->PSUploadEncoding (pFile, *this);
- if( aIter->GetFontType() == fonttype::Builtin )
- rNeededFonts.push_back(
- OUStringToOString(
- mrFontMgr.getPSName( aIter->GetFontID() ),
- RTL_TEXTENCODING_ASCII_US ) );
}
}
}
diff --git a/vcl/inc/generic/printergfx.hxx b/vcl/inc/generic/printergfx.hxx
index b2ecf2a86fdd..e56183dc9e20 100644
--- a/vcl/inc/generic/printergfx.hxx
+++ b/vcl/inc/generic/printergfx.hxx
@@ -117,7 +117,7 @@ public:
* forward declarations
*/
-class Font3;
+class Font2;
class GlyphSet;
class PrinterJob;
class PrintFontManager;
@@ -171,7 +171,7 @@ struct GraphicsStatus
GraphicsStatus();
};
-class Font3;
+class Font2;
class VCL_DLLPUBLIC PrinterGfx
{
@@ -242,14 +242,12 @@ private:
std::list< GraphicsStatus > maGraphicsStack;
GraphicsStatus& currentState() { return maGraphicsStack.front(); }
- /* font / font substitution */
- friend class Font3;
- const ::boost::unordered_map< fontID, fontID >* mpFontSubstitutes;
+ /* font */
+ friend class Font2;
int getCharWidth (sal_Bool b_vert, sal_Unicode n_char,
CharacterMetric *p_bbox);
- fontID getCharMetric (const Font3 &rFont, sal_Unicode n_char,
+ fontID getCharMetric (const Font2 &rFont, sal_Unicode n_char,
CharacterMetric *p_bbox);
- fontID getFontSubstitute () const;
fontID getFallbackID () const { return mnFallbackID; }
public:
@@ -301,7 +299,7 @@ public:
void OnEndPage ();
void OnEndJob ();
- void writeResources( osl::File* pFile, std::list< OString >& rSuppliedFonts, std::list< OString >& rNeededFonts );
+ void writeResources( osl::File* pFile, std::list< OString >& rSuppliedFonts );
PrintFontManager& GetFontMgr () { return mrFontMgr; }
void drawVerticalizedText (const Point& rPoint,
diff --git a/vcl/null/printerinfomanager.cxx b/vcl/null/printerinfomanager.cxx
index a480856a0fba..cf0bad94a80b 100644
--- a/vcl/null/printerinfomanager.cxx
+++ b/vcl/null/printerinfomanager.cxx
@@ -122,11 +122,6 @@ bool PrinterInfoManager::addOrRemovePossible() const
return false;
}
-void PrinterInfoManager::fillFontSubstitutions( PrinterInfo& /* rInfo */ ) const
-{
-
-}
-
void PrinterInfoManager::getSystemPrintCommands( std::list< OUString >& /* rCommands */ )
{
diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx
index 4f8f56ec75ca..2f3cedda79cb 100644
--- a/vcl/unx/generic/printer/printerinfomanager.cxx
+++ b/vcl/unx/generic/printer/printerinfomanager.cxx
@@ -23,7 +23,6 @@
#include <signal.h>
#include "cupsmgr.hxx"
-#include "vcl/fontmanager.hxx"
#include "vcl/strhelper.hxx"
#include "unx/saldata.hxx"
@@ -232,7 +231,6 @@ void PrinterInfoManager::initialize()
// need a parser for the PPDContext. generic printer should do.
m_aGlobalDefaults.m_pParser = PPDParser::getParser( OUString( "SGENPRT" ) );
m_aGlobalDefaults.m_aContext.setParser( m_aGlobalDefaults.m_pParser );
- m_aGlobalDefaults.m_bPerformFontSubstitution = true;
m_bDisableCUPS = false;
if( ! m_aGlobalDefaults.m_pParser )
@@ -293,15 +291,6 @@ void PrinterInfoManager::initialize()
if (!aValue.isEmpty())
m_aGlobalDefaults.m_nPDFDevice = aValue.toInt32();
- aValue = aConfig.ReadKey( "PerformFontSubstitution" );
- if (!aValue.isEmpty())
- {
- if (!aValue.equals("0") && !aValue.equalsIgnoreAsciiCase("false"))
- m_aGlobalDefaults.m_bPerformFontSubstitution = true;
- else
- m_aGlobalDefaults.m_bPerformFontSubstitution = false;
- }
-
aValue = aConfig.ReadKey( "DisableCUPS" );
if (!aValue.isEmpty())
{
@@ -327,19 +316,10 @@ void PrinterInfoManager::initialize()
sal_True );
}
}
- else if (aKey.startsWith("SubstFont_"))
- {
- aValue = aConfig.ReadKey( aKey );
- m_aGlobalDefaults.m_aFontSubstitutes[ OStringToOUString( aKey.copy( 10 ), RTL_TEXTENCODING_ISO_8859_1 ) ] = OStringToOUString( aValue, RTL_TEXTENCODING_ISO_8859_1 );
- }
}
- #if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "global settings: fontsubst = %s, %" SAL_PRI_SIZET "u substitutes\n", m_aGlobalDefaults.m_bPerformFontSubstitution ? "true" : "false", m_aGlobalDefaults.m_aFontSubstitutes.size() );
- #endif
}
}
setDefaultPaper( m_aGlobalDefaults.m_aContext );
- fillFontSubstitutions( m_aGlobalDefaults );
// now collect all available printers
for( print_dir_it = aDirList.begin(); print_dir_it != aDirList.end(); ++print_dir_it )
@@ -393,11 +373,6 @@ void PrinterInfoManager::initialize()
Printer aPrinter;
// initialize to global defaults
aPrinter.m_aInfo = m_aGlobalDefaults;
- // global settings do not default the printer substitution
- // list ! the substitution list in there is only used for
- // newly created printers
- aPrinter.m_aInfo.m_aFontSubstitutes.clear();
- aPrinter.m_aInfo.m_aFontSubstitutions.clear();
aPrinterName = OStringToOUString(aValue.copy(nNamePos+1),
RTL_TEXTENCODING_UTF8);
@@ -511,15 +486,8 @@ void PrinterInfoManager::initialize()
if (!aValue.isEmpty())
aPrinter.m_aInfo.m_nPDFDevice = aValue.toInt32();
- aValue = aConfig.ReadKey( "PerformFontSubstitution" );
- if (!aValue.equals("0") && !aValue.equalsIgnoreAsciiCase("false"))
- aPrinter.m_aInfo.m_bPerformFontSubstitution = true;
- else
- aPrinter.m_aInfo.m_bPerformFontSubstitution = false;
-
// now iterate over all keys to extract multi key information:
// 1. PPDContext information
- // 2. Font substitution table
for( int nKey = 0; nKey < aConfig.GetKeyCount(); ++nKey )
{
OString aKey( aConfig.GetKeyName( nKey ) );
@@ -535,15 +503,9 @@ void PrinterInfoManager::initialize()
sal_True );
}
}
- else if( aKey.startsWith("SubstFont_") )
- {
- aValue = aConfig.ReadKey( aKey );
- aPrinter.m_aInfo.m_aFontSubstitutes[ OStringToOUString( aKey.copy( 10 ), RTL_TEXTENCODING_ISO_8859_1 ) ] = OStringToOUString( aValue, RTL_TEXTENCODING_ISO_8859_1 );
- }
}
setDefaultPaper( aPrinter.m_aInfo.m_aContext );
- fillFontSubstitutions( aPrinter.m_aInfo );
// finally insert printer
FileBase::getFileURLFromSystemPath( aFile.PathToFileName(), aPrinter.m_aFile );
@@ -575,8 +537,7 @@ void PrinterInfoManager::initialize()
return;
// add a default printer for every available print queue
- // merge paper and font substitution from default printer,
- // all else from global defaults
+ // merge paper default printer, all else from global defaults
PrinterInfo aMergeInfo( m_aGlobalDefaults );
aMergeInfo.m_aDriverName = "SGENPRT";
aMergeInfo.m_aFeatures = "autoqueue";
@@ -584,8 +545,6 @@ void PrinterInfoManager::initialize()
if( !m_aDefaultPrinter.isEmpty() )
{
PrinterInfo aDefaultInfo( getPrinterInfo( m_aDefaultPrinter ) );
- aMergeInfo.m_bPerformFontSubstitution = aDefaultInfo.m_bPerformFontSubstitution;
- fillFontSubstitutions( aMergeInfo );
const PPDKey* pDefKey = aDefaultInfo.m_pParser->getKey( OUString( "PageSize" ) );
const PPDKey* pMergeKey = aMergeInfo.m_pParser->getKey( OUString( "PageSize" ) );
@@ -657,8 +616,6 @@ void PrinterInfoManager::changePrinterInfo( const OUString& rPrinter, const Prin
if( it != m_aPrinters.end() )
{
it->second.m_aInfo = rNewInfo;
- // recalculate font substitutions
- fillFontSubstitutions( it->second.m_aInfo );
it->second.m_bModified = true;
writePrinterConfig();
}
@@ -804,16 +761,6 @@ bool PrinterInfoManager::writePrinterConfig()
pConfig->WriteKey(aKey.makeStringAndClear(), aValue.makeStringAndClear());
}
}
-
- // write font substitution table
- pConfig->WriteKey( "PerformFontSubstitution", it->second.m_aInfo.m_bPerformFontSubstitution ? "true" : "false" );
- for( ::boost::unordered_map< OUString, OUString, OUStringHash >::const_iterator subst = it->second.m_aInfo.m_aFontSubstitutes.begin();
- subst != it->second.m_aInfo.m_aFontSubstitutes.end(); ++subst )
- {
- OStringBuffer aKey("SubstFont_");
- aKey.append(OUStringToOString(subst->first, RTL_TEXTENCODING_ISO_8859_1));
- pConfig->WriteKey( aKey.makeStringAndClear(), OUStringToOString( subst->second, RTL_TEXTENCODING_ISO_8859_1 ) );
- }
}
}
@@ -841,7 +788,6 @@ bool PrinterInfoManager::addPrinter( const OUString& rPrinterName, const OUStrin
aPrinter.m_aInfo.m_aContext.setParser( pParser );
aPrinter.m_aInfo.m_aPrinterName = rPrinterName;
- fillFontSubstitutions( aPrinter.m_aInfo );
// merge PPD values with global defaults
for( int nPPDValueModified = 0; nPPDValueModified < m_aGlobalDefaults.m_aContext.countValuesModified(); nPPDValueModified++ )
{
@@ -962,103 +908,6 @@ bool PrinterInfoManager::addOrRemovePossible() const
// -----------------------------------------------------------------
-void PrinterInfoManager::fillFontSubstitutions( PrinterInfo& rInfo ) const
-{
- PrintFontManager& rFontManager( PrintFontManager::get() );
- rInfo.m_aFontSubstitutions.clear();
-
- if( ! rInfo.m_bPerformFontSubstitution ||
- ! rInfo.m_aFontSubstitutes.size() )
- return;
-
- ::std::list< FastPrintFontInfo > aFonts;
- ::boost::unordered_map< OUString, ::std::list< FastPrintFontInfo >, OUStringHash > aPrinterFonts;
- rFontManager.getFontListWithFastInfo( aFonts, rInfo.m_pParser );
-
- // get builtin fonts
- ::std::list< FastPrintFontInfo >::const_iterator it;
- for( it = aFonts.begin(); it != aFonts.end(); ++it )
- if( it->m_eType == fonttype::Builtin )
- aPrinterFonts[ it->m_aFamilyName.toAsciiLowerCase() ].push_back( *it );
-
- // map lower case, so build a local copy of the font substitutions
- ::boost::unordered_map< OUString, OUString, OUStringHash > aSubstitutions;
- ::boost::unordered_map< OUString, OUString, OUStringHash >::const_iterator subst;
- for( subst = rInfo.m_aFontSubstitutes.begin(); subst != rInfo.m_aFontSubstitutes.end(); ++subst )
- {
- OUString aFamily( subst->first.toAsciiLowerCase() );
- // first look if there is a builtin of this family
- // in this case override the substitution table
- if( aPrinterFonts.find( aFamily ) != aPrinterFonts.end() )
- aSubstitutions[ aFamily ] = aFamily;
- else
- aSubstitutions[ aFamily ] = subst->second.toAsciiLowerCase();
- }
-
-
- // now find substitutions
- for( it = aFonts.begin(); it != aFonts.end(); ++it )
- {
- if( it->m_eType != fonttype::Builtin )
- {
- OUString aFamily( it->m_aFamilyName.toAsciiLowerCase() );
- subst = aSubstitutions.find( aFamily );
- if( subst != aSubstitutions.end() )
- {
- // search a substitution
- const ::std::list< FastPrintFontInfo >& rBuiltins( aPrinterFonts[ aSubstitutions[ aFamily ] ] );
- ::std::list< FastPrintFontInfo >::const_iterator builtin;
- int nLastMatch = -10000;
- fontID nSubstitute = -1;
- for( builtin = rBuiltins.begin(); builtin != rBuiltins.end(); ++builtin )
- {
- int nMatch = 0;
- int nDiff;
- if( builtin->m_eItalic == it->m_eItalic )
- nMatch += 8000;
-
- nDiff = builtin->m_eWeight - it->m_eWeight;
- nDiff = nDiff < 0 ? -nDiff : nDiff;
- nMatch += 4000 - 1000*nDiff;
-
- nDiff = builtin->m_eWidth - it->m_eWidth;
- nDiff = nDiff < 0 ? -nDiff : nDiff;
- nMatch += 2000 - 500*nDiff;
-
- if( nMatch > nLastMatch )
- {
- nLastMatch = nMatch;
- nSubstitute = builtin->m_nID;
- }
- }
- if( nSubstitute != -1 )
- {
- rInfo.m_aFontSubstitutions[ it->m_nID ] = nSubstitute;
-#if OSL_DEBUG_LEVEL > 2
- FastPrintFontInfo aInfo;
- rFontManager.getFontFastInfo( nSubstitute, aInfo );
- fprintf( stderr,
- "substitute %s %s %d %d\n"
- " -> %s %s %d %d\n",
- OUStringToOString( it->m_aFamilyName, RTL_TEXTENCODING_ISO_8859_1 ).getStr(),
- it->m_eItalic == ITALIC_NONE ? "r" : it->m_eItalic == ITALIC_OBLIQUE ? "o" : it->m_eItalic == ITALIC_NORMAL ? "i" : "u",
- it->m_eWeight,
- it->m_eWidth,
-
- OUStringToOString( aInfo.m_aFamilyName, RTL_TEXTENCODING_ISO_8859_1 ).getStr(),
- aInfo.m_eItalic == ITALIC_NONE ? "r" : aInfo.m_eItalic == ITALIC_OBLIQUE ? "o" : aInfo.m_eItalic == ITALIC_NORMAL ? "i" : "u",
- aInfo.m_eWeight,
- aInfo.m_eWidth
- );
-#endif
- }
- }
- }
- }
-}
-
-// -----------------------------------------------------------------
-
void PrinterInfoManager::getSystemPrintCommands( std::list< OUString >& rCommands )
{
if( m_pQueueInfo && m_pQueueInfo->hasChanged() )