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 1f3a91cf2a 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>
This commit is contained in:
committed by
Caolán McNamara
parent
6230cdd2d8
commit
24657548a7
@@ -50,24 +50,9 @@ struct PrinterInfo : JobData
|
||||
// a list of special features separated by ',' not used by psprint
|
||||
// but assigned from the outside (currently for "fax","pdf=","autoqueue","external_dialog")
|
||||
OUString m_aFeatures;
|
||||
// a mapping of fonts to other fonts.
|
||||
// this provides a method for the user
|
||||
// to replace arbitrary fonts by printer builtin fonts
|
||||
// currently this is only a mapping between font names
|
||||
// assuming that only adbobe standard encoding fonts are
|
||||
// built into the printer. in future it may be necessary
|
||||
// to map to a font name and UCS2 vector which should be mapped
|
||||
// this vector is currently implicitly given by the adobe
|
||||
// standard encoding
|
||||
bool m_bPerformFontSubstitution;
|
||||
boost::unordered_map< OUString, OUString, OUStringHash >
|
||||
m_aFontSubstitutes;
|
||||
boost::unordered_map< fontID, fontID >
|
||||
m_aFontSubstitutions;
|
||||
|
||||
PrinterInfo() :
|
||||
JobData(),
|
||||
m_bPerformFontSubstitution( false )
|
||||
JobData()
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -133,10 +118,6 @@ protected:
|
||||
|
||||
virtual void initialize();
|
||||
|
||||
// fill in font substitutions
|
||||
// the resulting boost::unordered_map maps from source to target font ids
|
||||
void fillFontSubstitutions( PrinterInfo& rInfo ) const;
|
||||
|
||||
// fill default paper if not configured in config file
|
||||
// default paper is e.g. locale dependent
|
||||
// if a paper is already set it will not be overwritten
|
||||
|
||||
@@ -61,23 +61,6 @@
|
||||
; if key is absent the default value is driver specific
|
||||
; PPD_PageSize=A4
|
||||
|
||||
; Note: the following two key types are in the global section to provide
|
||||
; defaults for newly added printers.
|
||||
; PerformFontSubstitution: whether to replace downloadable fonts
|
||||
; with resident fonts or not
|
||||
PerformFontSubstitution=false
|
||||
|
||||
; SubstFont_<downloadable font>: the resident font to replace
|
||||
; <downloadable font> if PerformFontSubstitution is true
|
||||
SubstFont_Helmet=Helvetica
|
||||
SubstFont_Albany=Helvetica
|
||||
SubstFont_Courier New=Courier
|
||||
SubstFont_Arial=Helvetica
|
||||
SubstFont_Times New Roman=Times
|
||||
SubstFont_Thorndale=Times
|
||||
SubstFont_Timmons=Times
|
||||
SubstFont_Cumberland=Courier
|
||||
|
||||
|
||||
[Generic Printer]
|
||||
; for every printer a group with at least the keys
|
||||
@@ -114,18 +97,3 @@ Command=
|
||||
; external_dialog to notify that the print command of a printer will show a dialog
|
||||
; and therefore the application should not show its own dialog.
|
||||
;Features=
|
||||
|
||||
; PerformFontSubstitution: whether to replace downloadable fonts
|
||||
; with resident fonts or not
|
||||
PerformFontSubstitution=false
|
||||
|
||||
; SubstFont_<downloadable font>: the resident font to replace
|
||||
; <downloadable font> if PerformFontSubstitution is true
|
||||
SubstFont_Helmet=Helvetica
|
||||
SubstFont_Albany=Helvetica
|
||||
SubstFont_Courier New=Courier
|
||||
SubstFont_Arial=Helvetica
|
||||
SubstFont_Times New Roman=Times
|
||||
SubstFont_Thorndale=Times
|
||||
SubstFont_Timmons=Times
|
||||
SubstFont_Cumberland=Courier
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
mpFont[0] = rGfx.GetFontID();
|
||||
mpFont[1] = rGfx.getFallbackID();
|
||||
|
||||
PrintFontManager &rMgr = PrintFontManager::get();
|
||||
mbSymbol = mpFont[1] != -1 ?
|
||||
rMgr.getFontEncoding(mpFont[1]) == RTL_TEXTENCODING_SYMBOL : false;
|
||||
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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -122,11 +122,6 @@ bool PrinterInfoManager::addOrRemovePossible() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void PrinterInfoManager::fillFontSubstitutions( PrinterInfo& /* rInfo */ ) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PrinterInfoManager::getSystemPrintCommands( std::list< OUString >& /* rCommands */ )
|
||||
{
|
||||
|
||||
|
||||
@@ -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() )
|
||||
|
||||
Reference in New Issue
Block a user