rpms/openoffice.org/devel openoffice.org-1.9.104-use-fontconfig-everywhere.patch, 1.15, 1.16

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Mon Sep 12 15:45:10 UTC 2005


Author: caolanm

Update of /cvs/dist/rpms/openoffice.org/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv19039

Modified Files:
	openoffice.org-1.9.104-use-fontconfig-everywhere.patch 
Log Message:
try cleaned up patch

openoffice.org-1.9.104-use-fontconfig-everywhere.patch:
 psprint/inc/psprint/fontmanager.hxx           |   13 -
 psprint/source/fontmanager/fontcache.cxx      |    2 
 psprint/source/fontmanager/fontcache.cxx.orig |    2 
 psprint/source/fontmanager/fontconfig.cxx     |  268 ++++++++++++++++----
 psprint/source/fontmanager/fontmanager.cxx    |    9 
 vcl/inc/outdev.h                              |    3 
 vcl/inc/outfont.hxx                           |   15 +
 vcl/source/gdi/outdev3.cxx                    |  333 ++++++++++++++++++--------
 vcl/source/window/window.cxx                  |    5 
 vcl/util/makefile.mk                          |    2 
 10 files changed, 489 insertions(+), 163 deletions(-)

Index: openoffice.org-1.9.104-use-fontconfig-everywhere.patch
===================================================================
RCS file: /cvs/dist/rpms/openoffice.org/devel/openoffice.org-1.9.104-use-fontconfig-everywhere.patch,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- openoffice.org-1.9.104-use-fontconfig-everywhere.patch	21 Aug 2005 13:22:19 -0000	1.15
+++ openoffice.org-1.9.104-use-fontconfig-everywhere.patch	12 Sep 2005 15:45:08 -0000	1.16
@@ -1,200 +1,7 @@
-Index: inc/psprint/fontmanager.hxx
-===================================================================
-RCS file: /cvs/gsl/psprint/inc/psprint/fontmanager.hxx,v
-retrieving revision 1.22
-diff -u -p -u -r1.22 fontmanager.hxx
---- openoffice.org.orig/psprint/inc/psprint/fontmanager.hxx	31 Jan 2005 08:58:54 -0000	1.22
-+++ openoffice.org/psprint/inc/psprint/fontmanager.hxx	4 Aug 2005 09:01:24 -0000
-@@ -79,7 +79,7 @@
- #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
- #include <com/sun/star/lang/Locale.hpp>
- #endif
--
-+#include <fontconfig/fontconfig.h>
- #define ATOM_FAMILYNAME                     2
- #define ATOM_PSNAME                         3
- 
-@@ -415,6 +415,7 @@ class PrintFontManager
-     std::hash_multimap< sal_uInt8, sal_Unicode >	m_aAdobecodeToUnicode;
- 
-     mutable FontCache*							m_pFontCache;
-+    FcFontSet *mpOutlineSet;
-         
-     rtl::OString getAfmFile( PrintFont* pFont ) const;
-     rtl::OString getFontFile( PrintFont* pFont ) const;
-@@ -468,6 +469,7 @@ class PrintFontManager
-     ~PrintFontManager();
- public:
-     static PrintFontManager& get(); // one instance only
-+    FcFontSet* getFontSet() { return mpOutlineSet; }
- 
-     int addFontFile( const rtl::OString& rFileName, int nFaceNum ); 
- 
-Index: source/fontmanager/fontcache.cxx
-===================================================================
-RCS file: /cvs/gsl/psprint/source/fontmanager/fontcache.cxx,v
-retrieving revision 1.13
-diff -u -p -u -r1.13 fontcache.cxx
---- openoffice.org.orig/psprint/source/fontmanager/fontcache.cxx	6 Jun 2005 16:07:21 -0000	1.13
-+++ openoffice.org/psprint/source/fontmanager/fontcache.cxx	4 Aug 2005 09:01:24 -0000
-@@ -703,9 +703,9 @@ bool FontCache::getFontCacheFile( int nD
-         FontDirMap::const_iterator entry = dir->second.m_aEntries.find( rFile );
-         if( entry != dir->second.m_aEntries.end() )
-         {
--            bSuccess = true;
-             for( FontCacheEntry::const_iterator font = entry->second.m_aEntry.begin(); font != entry->second.m_aEntry.end(); ++font )
-             {
-+                bSuccess = true;
-                 PrintFontManager::PrintFont* pFont = clonePrintFont( *font );
-                 rNewFonts.push_back( pFont );
-             }
-Index: source/fontmanager/fontconfig.cxx
-===================================================================
-RCS file: /cvs/gsl/psprint/source/fontmanager/fontconfig.cxx,v
-retrieving revision 1.7
-diff -u -p -u -r1.7 fontconfig.cxx
---- openoffice.org.orig/psprint/source/fontmanager/fontconfig.cxx	13 Oct 2004 08:22:03 -0000	1.7
-+++ openoffice.org/psprint/source/fontmanager/fontconfig.cxx	4 Aug 2005 09:01:25 -0000
-@@ -113,15 +113,17 @@ class FontCfgWrapper
-     FcPattern*		(*m_pFcPatternCreate)();
-     void			(*m_pFcPatternDestroy)(FcPattern*);
-     FcFontSet*		(*m_pFcFontList)(FcConfig*,FcPattern*,FcObjectSet*);
-+    FcFontSet*          (*m_pFcConfigGetFonts)(FcConfig*,FcSetName);
-     FcFontSet*		(*m_pFcFontSetCreate)();
-     void			(*m_pFcFontSetDestroy)(FcFontSet*);
-     FcBool			(*m_pFcFontSetAdd)(FcFontSet*,FcPattern*);
-+    void            (*m_pFcPatternReference)(FcPattern*);
-     FcResult		(*m_pFcPatternGetString)(const FcPattern*,const char*,int,FcChar8**);
-     FcResult		(*m_pFcPatternGetInteger)(const FcPattern*,const char*,int,int*);
-     FcResult		(*m_pFcPatternGetDouble)(const FcPattern*,const char*,int,double*);
-     FcResult		(*m_pFcPatternGetBool)(const FcPattern*,const char*,int,FcBool*);
-     void			(*m_pFcDefaultSubstitute)(FcPattern *);
--    FcPattern*		(*m_pFcFontMatch)(FcConfig*,FcPattern*,FcResult*);    
-+    FcPattern*      (*m_pFcFontSetMatch)(FcConfig*,FcFontSet**, int, FcPattern*,FcResult*);
-     FcBool			(*m_pFcConfigSubstitute)(FcConfig*,FcPattern*,FcMatchKind);
-     FcBool			(*m_pFcPatternAddInteger)(FcPattern*,const char*,int);
-     FcBool			(*m_pFcPatternAddString)(FcPattern*,const char*,const FcChar8*);
-@@ -164,14 +166,22 @@ public:
-     
-     FcFontSet* FcFontList( FcConfig* pConfig, FcPattern* pPattern, FcObjectSet* pSet )
-     { return m_pFcFontList( pConfig, pPattern, pSet ); }
--    
-+
-+    FcFontSet* FcConfigGetFonts( FcConfig* pConfig, FcSetName eSet)
-+    { return m_pFcConfigGetFonts( pConfig, eSet ); }
-+
-     FcFontSet* FcFontSetCreate()
-     { return m_pFcFontSetCreate(); }
-+
-     void FcFontSetDestroy( FcFontSet* pSet )
-     { m_pFcFontSetDestroy( pSet );}
-+
-     FcBool FcFontSetAdd( FcFontSet* pSet, FcPattern* pPattern )
-     { return m_pFcFontSetAdd( pSet, pPattern ); }
- 
-+    void FcPatternReference( FcPattern* pPattern )
-+    { m_pFcPatternReference( pPattern ); }
-+
-     FcResult FcPatternGetString( const FcPattern* pPattern, const char* object, int n, FcChar8** s )
-     { return m_pFcPatternGetString( pPattern, object, n, s ); }
- 
-@@ -185,8 +195,8 @@ public:
-     { return m_pFcPatternGetBool( pPattern, object, n, s ); }
-     void FcDefaultSubstitute( FcPattern* pPattern )
-     { m_pFcDefaultSubstitute( pPattern ); }
--    FcPattern* FcFontMatch( FcConfig* pConfig, FcPattern* pPattern, FcResult* pResult )
--    { return m_pFcFontMatch( pConfig, pPattern, pResult ); }
-+    FcPattern* FcFontSetMatch(FcConfig* pConfig, FcFontSet** ppFontSet, int nset, FcPattern *pPattern, FcResult *pResult)
-+    { return m_pFcFontSetMatch( pConfig, ppFontSet, nset, pPattern, pResult ); }
-     FcBool FcConfigSubstitute( FcConfig* pConfig, FcPattern* pPattern, FcMatchKind eKind )
-     { return m_pFcConfigSubstitute( pConfig, pPattern, eKind ); }
-     FcBool FcPatternAddInteger( FcPattern* pPattern, const char* pObject, int nValue )
-@@ -239,12 +249,16 @@ FontCfgWrapper::FontCfgWrapper()
-         loadSymbol( "FcPatternDestroy" );
-     m_pFcFontList = (FcFontSet*(*)(FcConfig*,FcPattern*,FcObjectSet*))
-         loadSymbol( "FcFontList" );
-+    m_pFcConfigGetFonts = (FcFontSet*(*)(FcConfig*,FcSetName))
-+        loadSymbol( "FcConfigGetFonts" );
-     m_pFcFontSetCreate = (FcFontSet*(*)())
-         loadSymbol( "FcFontSetCreate" );
-     m_pFcFontSetDestroy = (void(*)(FcFontSet*))
-         loadSymbol( "FcFontSetDestroy" );
-     m_pFcFontSetAdd = (FcBool(*)(FcFontSet*,FcPattern*))
-         loadSymbol( "FcFontSetAdd" );
-+    m_pFcPatternReference = (void(*)(FcPattern*))
-+        loadSymbol( "FcPatternReference" );
-     m_pFcPatternGetString = (FcResult(*)(const FcPattern*,const char*,int,FcChar8**))
-         loadSymbol( "FcPatternGetString" );
-     m_pFcPatternGetInteger = (FcResult(*)(const FcPattern*,const char*,int,int*))
-@@ -255,8 +269,8 @@ FontCfgWrapper::FontCfgWrapper()
-         loadSymbol( "FcPatternGetBool" );
-     m_pFcDefaultSubstitute = (void(*)(FcPattern *))
-         loadSymbol( "FcDefaultSubstitute" );
--    m_pFcFontMatch = (FcPattern*(*)(FcConfig*,FcPattern*,FcResult*))
--        loadSymbol( "FcFontMatch" );
-+    m_pFcFontSetMatch = (FcPattern*(*)(FcConfig*,FcFontSet**, int, FcPattern*,FcResult*))
-+        loadSymbol( "FcFontSetMatch" );
-     m_pFcConfigSubstitute = (FcBool(*)(FcConfig*,FcPattern*,FcMatchKind))
-         loadSymbol( "FcConfigSubstitute" );
-     m_pFcPatternAddInteger = (FcBool(*)(FcPattern*,const char*,int))
-@@ -271,15 +285,17 @@ FontCfgWrapper::FontCfgWrapper()
-             m_pFcPatternCreate				&&
-             m_pFcPatternDestroy				&&
-             m_pFcFontList					&&
-+            m_pFcConfigGetFonts                         &&
-             m_pFcFontSetCreate				&&
-             m_pFcFontSetDestroy				&&
-             m_pFcFontSetAdd					&&
-+            m_pFcPatternReference           &&
-             m_pFcPatternGetString			&&
-             m_pFcPatternGetInteger			&&
-             m_pFcPatternGetDouble			&&
-             m_pFcPatternGetBool				&&
-             m_pFcDefaultSubstitute			&&
--            m_pFcFontMatch					&&
-+            m_pFcFontSetMatch				&&
-             m_pFcConfigSubstitute			&&
-             m_pFcPatternAddInteger			&&
-             m_pFcPatternAddString
-@@ -336,6 +352,21 @@ bool PrintFontManager::initFontconfig()
-     if( ! rWrapper.isValid() )
-         return false;
- 
-+    mpOutlineSet = rWrapper.FcFontSetCreate();
-+
-+    /*cmc add only acceptable fonts to our config, for future fontconfig use*/
-+    FcFontSet *pOrig = rWrapper.FcConfigGetFonts(NULL, FcSetSystem);
-+    for( int i = 0; i < pOrig->nfont; i++ )
-+    {
-+        FcBool outline = false;
-+        FcPattern *pOutlinePattern = pOrig->fonts[i];
-+        FcResult eOutRes = rWrapper.FcPatternGetBool( pOutlinePattern, FC_OUTLINE, 0, &outline );
-+        if (eOutRes == FcResultMatch && !outline)
-+            continue;
-+        rWrapper.FcPatternReference(pOutlinePattern);
-+        rWrapper.FcFontSetAdd(mpOutlineSet, pOutlinePattern);
-+    }
-+
-     FcConfig* pConfig = rWrapper.getDefConfig();
-     FcObjectSet* pOSet = rWrapper.FcObjectSetBuild( FC_FAMILY,
-                                                     FC_STYLE,
-@@ -645,7 +676,7 @@ bool PrintFontManager::matchFont( FastPr
-     rWrapper.FcConfigSubstitute( pConfig, pPattern, FcMatchPattern );
-     rWrapper.FcDefaultSubstitute( pPattern );
-     FcResult eResult = FcResultNoMatch;
--    FcPattern* pResult = rWrapper.FcFontMatch( pConfig, pPattern, &eResult );
-+    FcPattern* pResult = rWrapper.FcFontSetMatch( pConfig, &mpOutlineSet, 1, pPattern, &eResult );
-     bool bSuccess = false;
-     if( pResult )
-     {
-Index: inc/outdev.h
-===================================================================
-RCS file: /cvs/gsl/vcl/inc/outdev.h,v
-retrieving revision 1.17
-diff -u -p -u -r1.17 outdev.h
---- openoffice.org.orig/vcl/inc/outdev.h	9 Nov 2004 16:32:20 -0000	1.17
-+++ openoffice.org/vcl/inc/outdev.h	2 Aug 2005 12:26:17 -0000
-@@ -239,7 +239,8 @@ public:
+diff -ru vcl.preconfig/inc/outdev.h vcl/inc/outdev.h
+--- openoffice.org.orig/vcl/inc/outdev.h	2005-09-12 13:37:38.000000000 +0100
++++ openoffice.org/vcl/inc/outdev.h	2005-09-12 14:10:15.000000000 +0100
+@@ -239,7 +239,8 @@
                               const Font& rFont, const Size& rSize, ImplFontSubstEntry* pDevSpecific );
      ImplFontEntry*      GetFallback( ImplDevFontList* pFontList,
                                       const Font& rFont, const Size& rSize,
@@ -204,22 +11,18 @@
      void                Release( ImplFontEntry* );
      void                Invalidate();
  };
-Index: inc/outfont.hxx
-===================================================================
-RCS file: /cvs/gsl/vcl/inc/outfont.hxx,v
-retrieving revision 1.17
-diff -u -p -u -r1.17 outfont.hxx
---- openoffice.org.orig/vcl/inc/outfont.hxx	31 Jan 2005 09:15:19 -0000	1.17
-+++ openoffice.org/vcl/inc/outfont.hxx	2 Aug 2005 12:26:18 -0000
-@@ -252,6 +252,7 @@ public:
+diff -ru vcl.preconfig/inc/outfont.hxx vcl/inc/outfont.hxx
+--- openoffice.org.orig/vcl/inc/outfont.hxx	2005-09-12 13:37:38.000000000 +0100
++++ openoffice.org/vcl/inc/outfont.hxx	2005-09-12 14:48:01.000000000 +0100
+@@ -252,6 +252,7 @@
      ImplDevFontListData*    FindFontFamily( const String& rFontName ) const;
      ImplDevFontListData*    ImplFindByFont( ImplFontSelectData&, bool bPrinter, ImplFontSubstEntry* pDevSpecificSubst ) const;
      ImplDevFontListData*    ImplFindBySearchName( const String& ) const;
-+    ImplDevFontListData*    ImplGetFontconfigSubstitute( ImplFontSelectData *pFontSelData, ImplFontSubstEntry* pDevSpecific );
++    ImplDevFontListData*    ImplGetFontconfigSubstitute( ImplFontSelectData &rFontSelData, ImplFontSubstEntry* pDevSpecific );
  
      bool                    HasFallbacks() const;
      void                    SetFallbacks( ImplDevFontListData**, int nCount );
-@@ -354,6 +355,10 @@ public:
+@@ -354,6 +355,10 @@
                          ImplFontEntry( const ImplFontSelectData& );
      virtual             ~ImplFontEntry() {}
  
@@ -230,7 +33,7 @@
  public: // TODO: make data members private
      ImplFontSelectData  maFontSelData;      // FontSelectionData
      ImplFontMetricData  maMetric;           // Font Metric
-@@ -364,6 +369,16 @@ public: // TODO: make data members priva
+@@ -364,6 +369,16 @@
      short               mnOwnOrientation;   // text angle if lower layers don't rotate text themselves
      short               mnOrientation;      // text angle in 3600 system
      bool                mbInit;             // true if maMetric member is valid
@@ -247,215 +50,136 @@
  };
  
  
-Index: source/gdi/outdev3.cxx
-===================================================================
-RCS file: /cvs/gsl/vcl/source/gdi/outdev3.cxx,v
-retrieving revision 1.202
-diff -u -p -u -r1.202 outdev3.cxx
---- openoffice.org.orig/vcl/source/gdi/outdev3.cxx	14 Jul 2005 12:36:51 -0000	1.202
-+++ openoffice.org/vcl/source/gdi/outdev3.cxx	2 Aug 2005 12:26:33 -0000
-@@ -185,6 +185,10 @@
+diff -ru vcl.preconfig/source/gdi/outdev3.cxx vcl/source/gdi/outdev3.cxx
+--- openoffice.org.orig/vcl/source/gdi/outdev3.cxx	2005-09-12 13:37:04.000000000 +0100
++++ openoffice.org/vcl/source/gdi/outdev3.cxx	2005-09-12 15:26:08.000000000 +0100
+@@ -185,6 +185,9 @@
  #include <memory>
  #include <algorithm>
  
 +#include <psprint/fontmanager.hxx>
-+#include <fontconfig/fontconfig.h>
 +#include <tools/isolang.hxx>
 +
  // =======================================================================
  
  DBG_NAMEEX( OutputDevice );
-@@ -2668,6 +2672,198 @@ ImplFontCache::~ImplFontCache()
+@@ -2670,6 +2673,124 @@
      }
  }
  
 +
 +// -----------------------------------------------------------------------
 +
-+FcFontSet *GetFcSubstitute( ImplFontSelectData *pFontSelData, ImplDevFontList* pFontList,
-+    sal_Unicode *pMissingUnicodes, int nMissingUnicodes)
++String GetFcSubstitute(const ImplFontSelectData &rFontSelData, sal_Unicode *pMissingGlyphs=0, int nMissingGlyphs=0)
 +{
-+    FcFontSet*  pSet = NULL;
-+    FcPattern*  pPattern = FcPatternCreate();
-+    FcValue     aValue;
-+
-+    // Prefer scalable fonts
-+    FcPatternAddBool( pPattern, FC_SCALABLE, 1 );
-+
-+    if( pFontSelData->GetFamilyName().Len() )
++    std::vector<String> aNames;
++    if( rFontSelData.GetFamilyName().Len() )
 +    {
 +        sal_uInt16 nIndex = 0;
-+        aValue.type = FcTypeString;
-+	 String aTempName;
++	String aTempName;
 +        do
 +        {
-+                aTempName = GetNextFontToken(pFontSelData->GetFamilyName(), nIndex);
-+                OString maTargetName = OUStringToOString(aTempName, RTL_TEXTENCODING_UTF8);
-+                aValue.u.s = (FcChar8*)maTargetName.getStr();
-+                FcPatternAdd( pPattern, FC_FAMILY, aValue, true);
++                aTempName = GetNextFontToken(rFontSelData.GetFamilyName(), nIndex);
++		aNames.push_back(aTempName);
 +        }
 +        while (nIndex != STRING_NOTFOUND);
 +    }
 +
-+    ByteString aLangAttrib = ConvertLanguageToIsoByteString( pFontSelData->meLanguage );
-+    if( aLangAttrib.Len() )
-+    {
-+        aValue.type = FcTypeString;
-+        aValue.u.s = (FcChar8*)aLangAttrib.GetBuffer();
-+        FcPatternAdd( pPattern, FC_LANG, aValue, true);
-+    }
-+
-+    // Add required Unicode characters, if any
-+    FcCharSet *unicodes = NULL;
-+    if ( pMissingUnicodes && (nMissingUnicodes > 0) )
-+    {
-+        int i;
-+
-+        unicodes = FcCharSetCreate();
-+        for (i = 0; i < nMissingUnicodes; i++)
-+            FcCharSetAddChar( unicodes, (FcChar32)pMissingUnicodes[i] );
++    std::vector<sal_Unicode> aGlyphs;
++    for (int i=0; i < nMissingGlyphs; ++i)
++	aGlyphs.push_back(pMissingGlyphs[i]);
 +
-+        aValue.type = FcTypeCharSet;
-+        aValue.u.c = unicodes;
-+        FcPatternAdd( pPattern, FC_CHARSET, aValue, true);
-+    }
++    ByteString aLangAttrib = ConvertLanguageToIsoByteString( rFontSelData.meLanguage );
 +
-+    if( pFontSelData->GetSlant() != ITALIC_DONTKNOW )
++    psp::italic::type eItalic = psp::italic::Unknown;
++    if( rFontSelData.GetSlant() != ITALIC_DONTKNOW )
 +    {
-+        int nSlant = FC_SLANT_ROMAN;
-+        switch( pFontSelData->GetSlant() )
++        switch( rFontSelData.GetSlant() )
 +        {
-+            case ITALIC_NORMAL:     nSlant = FC_SLANT_ITALIC;break;
-+            case ITALIC_OBLIQUE: 	nSlant = FC_SLANT_OBLIQUE;break;
++            case ITALIC_NORMAL:  eItalic = psp::italic::Italic; break;
++            case ITALIC_OBLIQUE: eItalic = psp::italic::Oblique; break;
 +            default:
 +                break;
 +        }
-+        aValue.type = FcTypeInteger;
-+        aValue.u.i = nSlant;
-+        FcPatternAddWeak( pPattern, FC_SLANT, aValue, true);
 +    }
 +
-+    if( pFontSelData->GetWeight() != WEIGHT_DONTKNOW )
++    psp::weight::type eWeight = psp::weight::Unknown;
++    if( rFontSelData.GetWeight() != WEIGHT_DONTKNOW )
 +    {
-+        int nWeight = FC_WEIGHT_NORMAL;
-+        switch( pFontSelData->GetWeight() )
++        switch( rFontSelData.GetWeight() )
 +        {
-+            case WEIGHT_THIN:			nWeight = FC_WEIGHT_THIN;break;
-+            case WEIGHT_ULTRALIGHT:	nWeight = FC_WEIGHT_ULTRALIGHT;break;
-+            case WEIGHT_LIGHT:			nWeight = FC_WEIGHT_LIGHT;break;
-+            case WEIGHT_SEMILIGHT:		nWeight = (FC_WEIGHT_NORMAL - FC_WEIGHT_LIGHT) / 2;break;
-+            case WEIGHT_NORMAL:		nWeight = FC_WEIGHT_NORMAL;break;
-+            case WEIGHT_MEDIUM:		nWeight = FC_WEIGHT_MEDIUM;break;
-+            case WEIGHT_SEMIBOLD:		nWeight = FC_WEIGHT_SEMIBOLD;break;
-+            case WEIGHT_BOLD:			nWeight = FC_WEIGHT_BOLD;break;
-+            case WEIGHT_ULTRABOLD:		nWeight	= FC_WEIGHT_ULTRABOLD;break;
-+            case WEIGHT_BLACK:			nWeight	= FC_WEIGHT_BLACK;break;
++            case WEIGHT_THIN:		eWeight = psp::weight::Thin; break;
++            case WEIGHT_ULTRALIGHT:	eWeight = psp::weight::UltraLight; break;
++            case WEIGHT_LIGHT:		eWeight = psp::weight::Light; break;
++            case WEIGHT_SEMILIGHT:	eWeight = psp::weight::SemiLight; break;
++            case WEIGHT_NORMAL:		eWeight = psp::weight::Normal; break;
++            case WEIGHT_MEDIUM:		eWeight = psp::weight::Medium; break;
++            case WEIGHT_SEMIBOLD:	eWeight = psp::weight::SemiBold; break;
++            case WEIGHT_BOLD:		eWeight = psp::weight::Bold; break;
++            case WEIGHT_ULTRABOLD:	eWeight = psp::weight::UltraBold; break;
++            case WEIGHT_BLACK:		eWeight = psp::weight::Black; break;
 +            default:
 +                break;
 +        }
-+        aValue.type = FcTypeInteger;
-+        aValue.u.i= nWeight;
-+        FcPatternAddWeak( pPattern, FC_WEIGHT, aValue, true);
 +    }
 +
-+    if( pFontSelData->GetWidthType() != WIDTH_DONTKNOW )
++    psp::width::type eWidth = psp::width::Unknown;
++    if( rFontSelData.GetWidthType() != WIDTH_DONTKNOW )
 +    {
-+        int nWidth = FC_WIDTH_NORMAL;
-+        switch( pFontSelData->GetWidthType() )
++        switch( rFontSelData.GetWidthType() )
 +        {
-+            case WIDTH_ULTRA_CONDENSED:	nWidth = FC_WIDTH_ULTRACONDENSED;break;
-+            case WIDTH_EXTRA_CONDENSED: nWidth = FC_WIDTH_EXTRACONDENSED;break;
-+            case WIDTH_CONDENSED:		nWidth = FC_WIDTH_CONDENSED;break;
-+            case WIDTH_SEMI_CONDENSED:	nWidth = FC_WIDTH_SEMICONDENSED;break;
-+            case WIDTH_NORMAL:			nWidth = FC_WIDTH_NORMAL;break;
-+            case WIDTH_SEMI_EXPANDED:	nWidth = FC_WIDTH_SEMIEXPANDED;break;
-+            case WIDTH_EXPANDED:		nWidth = FC_WIDTH_EXPANDED;break;
-+            case WIDTH_EXTRA_EXPANDED:	nWidth = FC_WIDTH_EXTRAEXPANDED;break;
-+            case WIDTH_ULTRA_EXPANDED:	nWidth = FC_WIDTH_ULTRACONDENSED;break;
++            case WIDTH_ULTRA_CONDENSED:	eWidth = psp::width::UltraCondensed; break;
++            case WIDTH_EXTRA_CONDENSED: eWidth = psp::width::ExtraCondensed; break;
++            case WIDTH_CONDENSED:	eWidth = psp::width::Condensed; break;
++            case WIDTH_SEMI_CONDENSED:	eWidth = psp::width::SemiCondensed; break;
++            case WIDTH_NORMAL:		eWidth = psp::width::Normal; break;
++            case WIDTH_SEMI_EXPANDED:	eWidth = psp::width::SemiExpanded; break;
++            case WIDTH_EXPANDED:	eWidth = psp::width::Expanded; break;
++            case WIDTH_EXTRA_EXPANDED:	eWidth = psp::width::ExtraExpanded; break;
++            case WIDTH_ULTRA_EXPANDED:	eWidth = psp::width::UltraExpanded; break;
 +            default:
 +                break;
 +        }
-+        aValue.type = FcTypeInteger;
-+        aValue.u.i= nWidth;
-+        FcPatternAddWeak( pPattern, FC_WIDTH, aValue, true);
 +    }
 +
-+    if( pFontSelData->GetPitch() != PITCH_DONTKNOW )
++    psp::pitch::type ePitch = psp::pitch::Unknown;
++    if( rFontSelData.GetPitch() != PITCH_DONTKNOW )
 +    {
-+        int nSpacing = FC_PROPORTIONAL;
-+        switch(  pFontSelData->GetPitch() )
++        switch(  rFontSelData.GetPitch() )
 +        {
-+            case PITCH_FIXED:			nSpacing = FC_MONO;break;
-+            case PITCH_VARIABLE:		nSpacing = FC_PROPORTIONAL;break;
++            case PITCH_FIXED:    ePitch=psp::pitch::Fixed; break;
++            case PITCH_VARIABLE: ePitch=psp::pitch::Variable; break;
 +            default:
 +                break;
 +        }
-+        aValue.type = FcTypeInteger;
-+        aValue.u.i= nSpacing;
-+        FcPatternAddWeak( pPattern, FC_SPACING, aValue, true);
-+        if (nSpacing == FC_MONO)
-+        {
-+                aValue.type = FcTypeString;
-+                aValue.u.s = (FcChar8*)"monospace";
-+                FcPatternAddWeak( pPattern, FC_FAMILY, aValue, true);
-+        }
 +    }
 +
-+    psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
-+
-+    FcConfigSubstitute( NULL, pPattern, FcMatchPattern );
-+    FcDefaultSubstitute( pPattern );
-+    FcResult eResult = FcResultNoMatch;
-+    FcFontSet *pOutlines = psp::PrintFontManager::get().getFontSet();
-+    FcPattern* pResult = FcFontSetMatch( NULL, &pOutlines, 1, pPattern, &eResult );
-+    FcPatternDestroy( pPattern );
-+
-+    if( pResult )
-+    {
-+        pSet = FcFontSetCreate();
-+        // info: destroying the pSet destroys pResult implicitly
-+        // since pResult was "added" to pSet
-+        FcFontSetAdd( pSet, pResult );
-+    }
-+
-+    return pSet;
++    const psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
++    return rMgr.Substitute(aNames, aGlyphs, aLangAttrib, eItalic, eWeight, eWidth, ePitch);
 +}
 +
 +// -----------------------------------------------------------------------
 +
-+ImplDevFontListData *ImplDevFontList::ImplGetFontconfigSubstitute( ImplFontSelectData *pFontSelData, ImplFontSubstEntry* pDevSpecific )
++ImplDevFontListData *ImplDevFontList::ImplGetFontconfigSubstitute( ImplFontSelectData &rFontSelData, ImplFontSubstEntry* pDevSpecific )
 +{
 +    // We dont' actually want to talk to Fontconfig at all for symbol fonts
-+    if (pFontSelData->IsSymbolFont())
-+        return NULL;
++    if (rFontSelData.IsSymbolFont())
++        return 0;
 +    // StarSymbol is a unicode font, but it still deserves the symbol flag
-+    if( 0 == pFontSelData->maSearchName.CompareIgnoreCaseToAscii( "starsymbol", 10)
-+        ||  0 == pFontSelData->maSearchName.CompareIgnoreCaseToAscii( "opensymbol", 10) )
-+        return NULL;
-+    ImplDevFontListData *pFontFamily = NULL;
-+    FcFontSet* pSet = NULL;
-+
-+    pSet = GetFcSubstitute( pFontSelData, NULL, NULL, 0 );
-+    if ( !pSet )
-+        return NULL;
-+
-+    if( pSet->nfont > 0 )
-+    {
-+        //extract the closest match
-+        FcChar8* family = NULL;
-+        FcResult eFileRes = FcPatternGetString( pSet->fonts[0], FC_FAMILY, 0, &family );
-+        if( eFileRes == FcResultMatch )
-+        {
-+            String aName( (sal_Char*)family, RTL_TEXTENCODING_UTF8 );
-+            String aUserName(aName);
-+            ImplGetEnglishSearchFontName( aName );
-+            ImplFontSubstitute( aName, FONT_SUBSTITUTE_ALWAYS, pDevSpecific );
-+            pFontFamily = ImplFindBySearchName( aName );
-+            if (pFontFamily)
-+                pFontSelData->maTargetName = aUserName;
-+        }
-+    }
-+    FcFontSetDestroy( pSet );
++    if( 0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "starsymbol", 10)
++        ||  0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "opensymbol", 10) )
++        return 0;
++
++    String aName(GetFcSubstitute(rFontSelData));
++    if (!aName.Len())
++        return 0;
++
++    String aUserName(aName);
++    ImplGetEnglishSearchFontName( aName );
++    ImplFontSubstitute( aName, FONT_SUBSTITUTE_ALWAYS, pDevSpecific );
++    ImplDevFontListData *pFontFamily = ImplFindBySearchName( aName );
++    if (pFontFamily)
++        rFontSelData.maTargetName = aUserName;
 +
 +    return pFontFamily;
 +}
@@ -464,13 +188,13 @@
  // -----------------------------------------------------------------------
  
  ImplFontEntry* ImplFontCache::Get( ImplDevFontList* pFontList,
-@@ -2705,8 +2901,12 @@ ImplFontEntry* ImplFontCache::Get( ImplD
+@@ -2707,8 +2828,12 @@
  
      if( !pEntry ) // no direct cache hit
      {
 -        // find the best matching logical font family and update font selector accordingly
 -        pFontFamily = pFontList->ImplFindByFont( aFontSelData, mbPrinter, pDevSpecific );
-+        pFontFamily = pFontList->ImplGetFontconfigSubstitute( &aFontSelData, pDevSpecific );
++        pFontFamily = pFontList->ImplGetFontconfigSubstitute( aFontSelData, pDevSpecific );
 +        if (!pFontFamily)
 +        {
 +            // find the best matching logical font family and update font selector accordingly
@@ -479,7 +203,7 @@
          DBG_ASSERT( (pFontFamily != NULL), "ImplFontCache::Get() No logical font found!" );
          aFontSelData.maSearchName = pFontFamily->GetSearchName();
  
-@@ -3026,109 +3226,122 @@ ImplDevFontListData* ImplDevFontList::Im
+@@ -3028,109 +3153,102 @@
  // -----------------------------------------------------------------------
  
  ImplFontEntry* ImplFontCache::GetFallback( ImplDevFontList* pFontList,
@@ -573,36 +297,19 @@
  
 -            // keep the best font of the glyph fallback sub-list
 -            if( nBestQuality < pFallbackFont->GetMinQuality() )
-+    if ( !cached )
-+    {
-+        FcFontSet*  pSet = NULL;
-+        FcChar8* family = NULL;
-+
-+        pSet = GetFcSubstitute( &aSelData, pFontList, pMissingUnicodes, nMissingUnicodes );
-+        if (pSet)
-+        {
-+            if( FcPatternGetString( pSet->fonts[0], FC_FAMILY, 0, &family ) == FcResultMatch )
-+                aSelData.maSearchName = String( (sal_Char*)family, RTL_TEXTENCODING_UTF8 );
-+
-+            FcFontSetDestroy( pSet );
-+        #if 0
-+            ByteString n( aOrigFontName, RTL_TEXTENCODING_UTF8);
-+            fprintf (stderr, " -- Fallbacks for '%s' are:\n", n.GetBuffer());
-+            for (int i = 0; i < pSet->nfont; i++)
-             {
+-            {
 -                nBestQuality = pFallbackFont->GetMinQuality();
 -                // store available glyph fallback fonts
 -                if( !pFallbackList )
 -                    pFallbackList = new ImplDevFontListData*[ MAX_FALLBACK ];
 -                pFallbackList[ nMaxLevel ] = pFallbackFont;
-+                FcChar8* pfamily;
-+                if (FcPatternGetString( pSet->fonts[i], FC_FAMILY, 0, &pfamily ) == FcResultMatch)
-+                    fprintf (stderr, "    %d) %s\n", i, (const char *)pfamily);
-             }
-+        #endif
-         }
-+        else
-+            fprintf (stderr, "!! Could not get glyph fallbacks from Fontconfig !!\n");
+-            }
+-        }
++    if ( !cached )
++    {
++        String aName(GetFcSubstitute( aSelData, pMissingUnicodes, nMissingUnicodes ));
++	if (aName.Len())
++            aSelData.maSearchName = aName;
 +    }
  
 -        // sort the fonts for glyph fallback by quality (highest first)
@@ -685,7 +392,7 @@
      if( pFallbackFont && !pFallbackFont->mbInit )
      {
          // HACK: maMetrics are irrelevant for fallback fonts, but
-@@ -3137,6 +3350,27 @@ ImplFontEntry* ImplFontCache::GetFallbac
+@@ -3139,6 +3257,27 @@
          pFallbackFont->maMetric.maStyleName = String();
      }
  
@@ -713,7 +420,7 @@
      return pFallbackFont;
  }
  
-@@ -6103,7 +6337,7 @@ SalLayout* OutputDevice::ImplLayout( con
+@@ -6105,7 +6244,7 @@
      // do glyph fallback if needed
      // #105768# avoid fallback for very small font sizes
      if( aLayoutArgs.NeedFallback() )
@@ -722,7 +429,7 @@
              pSalLayout = ImplGlyphFallbackLayout( pSalLayout, aLayoutArgs );
  
      // position, justify, etc. the layout
-@@ -6147,6 +6381,17 @@ SalLayout* OutputDevice::ImplGlyphFallba
+@@ -6149,6 +6288,17 @@
          rLayoutArgs.ResetPos();
      }
  #endif
@@ -740,7 +447,7 @@
  
      ImplFontSelectData aFontSelData = mpFontEntry->maFontSelData;
      Size aFontSize( aFontSelData.mnWidth, aFontSelData.mnHeight );
-@@ -6163,7 +6408,8 @@ SalLayout* OutputDevice::ImplGlyphFallba
+@@ -6165,7 +6315,8 @@
      {
          // find a font family suited for glyph fallback
          ImplFontEntry* pFallbackFont = mpFontCache->GetFallback( mpFontList,
@@ -750,57 +457,630 @@
          if( !pFallbackFont )
              break;
  
-@@ -6214,6 +6460,8 @@ SalLayout* OutputDevice::ImplGlyphFallba
-         if( !rLayoutArgs.PrepareFallback() )
+@@ -6217,6 +6368,8 @@
              break;
      }
-+
-+    delete pMissingUnicodes;
  
++    delete[] pMissingUnicodes;
++
      if( pMultiSalLayout && pMultiSalLayout->LayoutText( rLayoutArgs ) )
          pSalLayout = pMultiSalLayout;
-Index: util/makefile.mk
-===================================================================
-RCS file: /cvs/gsl/vcl/util/makefile.mk,v
-retrieving revision 1.71
-diff -u -p -u -r1.71 makefile.mk
---- openoffice.org.orig/vcl/util/makefile.mk	18 Jul 2005 14:10:12 -0000	1.71
-+++ openoffice.org/vcl/util/makefile.mk	2 Aug 2005 12:26:55 -0000
-@@ -265,7 +265,7 @@ SHL1STDLIBS += -framework Cocoa
+     
+diff -ru vcl.preconfig/source/window/window.cxx vcl/source/window/window.cxx
+--- openoffice.org.orig/vcl/source/window/window.cxx	2005-09-12 13:37:04.000000000 +0100
++++ openoffice.org/vcl/source/window/window.cxx	2005-09-12 16:18:20.000000000 +0100
+@@ -212,6 +212,7 @@
+ #endif
+ 
+ #include <pdfextoutdevdata.hxx>
++#include <psprint/fontmanager.hxx>
+ 
+ using namespace rtl;
+ using namespace ::com::sun::star::uno;
+@@ -350,6 +351,10 @@
+ {
+     ImplInitFontList();
+ 
++    const psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
++    if (rMgr.hasFontconfig())
++        return true;
++
+     String aTestText;
+     aTestText.Append( Button::GetStandardText( BUTTON_OK ) );
+     aTestText.Append( Button::GetStandardText( BUTTON_CANCEL ) );
+diff -ru vcl.preconfig/util/makefile.mk vcl/util/makefile.mk
+--- openoffice.org.orig/vcl/util/makefile.mk	2005-09-12 13:37:38.000000000 +0100
++++ openoffice.org/vcl/util/makefile.mk	2005-09-12 14:55:10.000000000 +0100
+@@ -265,7 +265,7 @@
  .ENDIF
  
  
 -SHL1STDLIBS += -lX11
-+SHL1STDLIBS += -lX11 -lpsp$(VERSION)$(DLLPOSTFIX) -lfontconfig
++SHL1STDLIBS += -lX11 -lpsp$(VERSION)$(DLLPOSTFIX)
  
  .ENDIF          # "$(GUI)"=="UNX"
  
-Index: source/window/window.cxx
-===================================================================
-RCS file: /cvs/gsl/vcl/source/window/window.cxx,v
-retrieving revision 1.215
-diff -u -p -u -r1.215 window.cxx
---- openoffice.org.orig/vcl/source/window/window.cxx	29 Mar 2005 14:38:07 -0000	1.215
-+++ openoffice.org/vcl/source/window/window.cxx	16 Jul 2005 11:34:09 -0000
-@@ -349,20 +349,7 @@ void Window::ImplInitAppFontData( Window
- bool Window::ImplCheckUIFont( const Font& rFont )
+diff -ru psprint.preconfig/inc/psprint/fontmanager.hxx psprint/inc/psprint/fontmanager.hxx
+--- openoffice.org.orig/psprint/inc/psprint/fontmanager.hxx	2005-09-12 13:41:25.000000000 +0100
++++ openoffice.org/psprint/inc/psprint/fontmanager.hxx	2005-09-12 15:43:49.000000000 +0100
+@@ -75,6 +75,9 @@
+ #ifndef _PSPRINT_HELPER_HXX_
+ #include <psprint/helper.hxx>
+ #endif
++#ifndef _STRING_HXX
++#include <tools/string.hxx>
++#endif
+ 
+ #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
+ #include <com/sun/star/lang/Locale.hpp>
+@@ -421,6 +424,7 @@
+     std::hash_multimap< sal_uInt8, sal_Unicode >	m_aAdobecodeToUnicode;
+ 
+     mutable FontCache*							m_pFontCache;
++    bool m_bFontconfigSuccess;
+         
+     rtl::OString getAfmFile( PrintFont* pFont ) const;
+     rtl::OString getFontFile( PrintFont* pFont ) const;
+@@ -506,10 +510,10 @@
+     const rtl::OUString& getPSName( fontID nFontID ) const;
+ 
+     // get a specific fonts style family
+-    family::type PrintFontManager::getFontFamilyType( fontID nFontID ) const;
++    family::type getFontFamilyType( fontID nFontID ) const;
+ 
+     // get a specific fonts family name aliases
+-    void PrintFontManager::getFontFamilyAliases( fontID nFontID ) const;
++    void getFontFamilyAliases( fontID nFontID ) const;
+         
+     // get a specific fonts type
+     fonttype::type getFontType( fontID nFontID ) const
+@@ -731,6 +735,11 @@
+     false else
+      */
+     bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale );
++
++    String Substitute(const std::vector<String> &rNames, const std::vector<sal_Unicode> &rGlyphs, 
++        const ByteString &rLangAttrib, italic::type eItalic, weight::type eWeight, 
++        width::type eWidth, pitch::type ePitch) const;
++    bool hasFontconfig() const { return m_bFontconfigSuccess; }
+ };
+ 
+ } // namespace
+diff -ru psprint.preconfig/source/fontmanager/fontcache.cxx psprint/source/fontmanager/fontcache.cxx
+--- openoffice.org.orig/psprint/source/fontmanager/fontcache.cxx	2005-09-12 13:41:08.000000000 +0100
++++ openoffice.org/psprint/source/fontmanager/fontcache.cxx	2005-09-12 13:43:06.000000000 +0100
+@@ -672,9 +672,9 @@
+         FontDirMap::const_iterator entry = dir->second.m_aEntries.find( rFile );
+         if( entry != dir->second.m_aEntries.end() )
+         {
+-            bSuccess = true;
+             for( FontCacheEntry::const_iterator font = entry->second.m_aEntry.begin(); font != entry->second.m_aEntry.end(); ++font )
+             {
++                bSuccess = true;
+                 PrintFontManager::PrintFont* pFont = clonePrintFont( *font );
+                 rNewFonts.push_back( pFont );
+             }
+diff -ru psprint.preconfig/source/fontmanager/fontcache.cxx.orig psprint/source/fontmanager/fontcache.cxx.orig
+--- openoffice.org.orig/psprint/source/fontmanager/fontcache.cxx.orig	2005-09-12 13:41:08.000000000 +0100
++++ openoffice.org/psprint/source/fontmanager/fontcache.cxx.orig	2005-09-12 13:36:53.000000000 +0100
+@@ -672,9 +672,9 @@
+         FontDirMap::const_iterator entry = dir->second.m_aEntries.find( rFile );
+         if( entry != dir->second.m_aEntries.end() )
+         {
++            bSuccess = true;
+             for( FontCacheEntry::const_iterator font = entry->second.m_aEntry.begin(); font != entry->second.m_aEntry.end(); ++font )
+             {
+-                bSuccess = true;
+                 PrintFontManager::PrintFont* pFont = clonePrintFont( *font );
+                 rNewFonts.push_back( pFont );
+             }
+diff -ru psprint.preconfig/source/fontmanager/fontconfig.cxx psprint/source/fontmanager/fontconfig.cxx
+--- openoffice.org.orig/psprint/source/fontmanager/fontconfig.cxx	2005-09-12 13:41:08.000000000 +0100
++++ openoffice.org/psprint/source/fontmanager/fontconfig.cxx	2005-09-12 16:13:09.000000000 +0100
+@@ -70,10 +70,12 @@
+ typedef void FcObjectSet;
+ typedef void FcPattern;
+ typedef void FcFontSet;
++typedef void FcCharSet;
+ typedef int FcResult;
+ typedef int FcBool;
+ typedef int FcMatchKind;
+ typedef char FcChar8;
++typedef sal_Int32 FcChar32;
+ #endif
+ 
+ #include <cstdio>
+@@ -106,6 +108,7 @@
  {
-     ImplInitFontList();
+     void*			m_pLib;
+     FcConfig*		m_pDefConfig;
++    FcFontSet*      m_pOutlineSet;
+ 
+ 	FcBool          (*m_pFcInit)();
+     FcConfig*		(*m_pFcConfigGetCurrent)();
+@@ -114,17 +117,23 @@
+     FcPattern*		(*m_pFcPatternCreate)();
+     void			(*m_pFcPatternDestroy)(FcPattern*);
+     FcFontSet*		(*m_pFcFontList)(FcConfig*,FcPattern*,FcObjectSet*);
++    FcFontSet*      (*m_pFcConfigGetFonts)(FcConfig*,FcSetName);
+     FcFontSet*		(*m_pFcFontSetCreate)();
++    FcCharSet*		(*m_pFcCharSetCreate)();
++    FcBool			(*m_pFcCharSetAddChar)(FcCharSet *, FcChar32);
+     void			(*m_pFcFontSetDestroy)(FcFontSet*);
+     FcBool			(*m_pFcFontSetAdd)(FcFontSet*,FcPattern*);
++    void            (*m_pFcPatternReference)(FcPattern*);
+     FcResult		(*m_pFcPatternGetString)(const FcPattern*,const char*,int,FcChar8**);
+     FcResult		(*m_pFcPatternGetInteger)(const FcPattern*,const char*,int,int*);
+     FcResult		(*m_pFcPatternGetDouble)(const FcPattern*,const char*,int,double*);
+     FcResult		(*m_pFcPatternGetBool)(const FcPattern*,const char*,int,FcBool*);
+     void			(*m_pFcDefaultSubstitute)(FcPattern *);
+-    FcPattern*		(*m_pFcFontMatch)(FcConfig*,FcPattern*,FcResult*);    
++    FcPattern*      (*m_pFcFontSetMatch)(FcConfig*,FcFontSet**, int, FcPattern*,FcResult*);
+     FcBool			(*m_pFcConfigSubstitute)(FcConfig*,FcPattern*,FcMatchKind);
+     FcBool			(*m_pFcPatternAddInteger)(FcPattern*,const char*,int);
++    FcBool			(*m_pFcPatternAddBool)(FcPattern*,const char*,FcBool);
++    FcBool			(*m_pFcPatternAddCharSet)(FcPattern*,const char*,const FcCharSet*);
+     FcBool			(*m_pFcPatternAddString)(FcPattern*,const char*,const FcChar8*);
+ 
+     void* loadSymbol( const char* );
+@@ -140,6 +149,7 @@
+     { return m_pLib != NULL;}
+ 
+     FcConfig* getDefConfig() { return m_pDefConfig; }
++    FcFontSet* getFontSet() { return m_pOutlineSet; }
+ 
+     FcBool FcInit()
+     { return m_pFcInit(); }
+@@ -169,14 +179,28 @@
+     
+     FcFontSet* FcFontList( FcConfig* pConfig, FcPattern* pPattern, FcObjectSet* pSet )
+     { return m_pFcFontList( pConfig, pPattern, pSet ); }
+-    
++
++    FcFontSet* FcConfigGetFonts( FcConfig* pConfig, FcSetName eSet)
++    { return m_pFcConfigGetFonts( pConfig, eSet ); }
++
+     FcFontSet* FcFontSetCreate()
+     { return m_pFcFontSetCreate(); }
++
++    FcCharSet* FcCharSetCreate()
++    { return m_pFcCharSetCreate(); }
++
++    FcBool FcCharSetAddChar(FcCharSet *fcs, FcChar32 ucs4)
++    { return m_pFcCharSetAddChar(fcs, ucs4); }
++
+     void FcFontSetDestroy( FcFontSet* pSet )
+     { m_pFcFontSetDestroy( pSet );}
++
+     FcBool FcFontSetAdd( FcFontSet* pSet, FcPattern* pPattern )
+     { return m_pFcFontSetAdd( pSet, pPattern ); }
+ 
++    void FcPatternReference( FcPattern* pPattern )
++    { m_pFcPatternReference( pPattern ); }
++
+     FcResult FcPatternGetString( const FcPattern* pPattern, const char* object, int n, FcChar8** s )
+     { return m_pFcPatternGetString( pPattern, object, n, s ); }
+ 
+@@ -190,12 +214,16 @@
+     { return m_pFcPatternGetBool( pPattern, object, n, s ); }
+     void FcDefaultSubstitute( FcPattern* pPattern )
+     { m_pFcDefaultSubstitute( pPattern ); }
+-    FcPattern* FcFontMatch( FcConfig* pConfig, FcPattern* pPattern, FcResult* pResult )
+-    { return m_pFcFontMatch( pConfig, pPattern, pResult ); }
++    FcPattern* FcFontSetMatch(FcConfig* pConfig, FcFontSet** ppFontSet, int nset, FcPattern *pPattern, FcResult *pResult)
++    { return m_pFcFontSetMatch( pConfig, ppFontSet, nset, pPattern, pResult ); }
+     FcBool FcConfigSubstitute( FcConfig* pConfig, FcPattern* pPattern, FcMatchKind eKind )
+     { return m_pFcConfigSubstitute( pConfig, pPattern, eKind ); }
+     FcBool FcPatternAddInteger( FcPattern* pPattern, const char* pObject, int nValue )
+     { return m_pFcPatternAddInteger( pPattern, pObject, nValue ); }
++    FcBool FcPatternAddBool( FcPattern* pPattern, const char* pObject, FcBool b )
++    { return m_pFcPatternAddBool( pPattern, pObject, b ); }
++    FcBool FcPatternAddCharSet( FcPattern* pPattern, const char* pObject, const FcCharSet *c)
++    { return m_pFcPatternAddCharSet( pPattern, pObject, c ); }
+     FcBool FcPatternAddString( FcPattern* pPattern, const char* pObject, const FcChar8* pString )
+     { return m_pFcPatternAddString( pPattern, pObject, pString ); }
+ };
+@@ -212,7 +240,8 @@
+ 
+ FontCfgWrapper::FontCfgWrapper()
+         : m_pLib( NULL ),
+-          m_pDefConfig( NULL )
++          m_pDefConfig( NULL ),
++          m_pOutlineSet( NULL )
+ {
+ #ifdef ENABLE_FONTCONFIG
+     OUString aLib( RTL_CONSTASCII_USTRINGPARAM( "libfontconfig.so.1" ) );
+@@ -246,12 +275,20 @@
+         loadSymbol( "FcPatternDestroy" );
+     m_pFcFontList = (FcFontSet*(*)(FcConfig*,FcPattern*,FcObjectSet*))
+         loadSymbol( "FcFontList" );
++    m_pFcConfigGetFonts = (FcFontSet*(*)(FcConfig*,FcSetName))
++        loadSymbol( "FcConfigGetFonts" );
+     m_pFcFontSetCreate = (FcFontSet*(*)())
+         loadSymbol( "FcFontSetCreate" );
++    m_pFcCharSetCreate = (FcCharSet*(*)())
++        loadSymbol( "FcCharSetCreate" );
++    m_pFcCharSetAddChar = (FcBool(*)(FcCharSet*, FcChar32))
++        loadSymbol( "FcCharSetAddChar" );
+     m_pFcFontSetDestroy = (void(*)(FcFontSet*))
+         loadSymbol( "FcFontSetDestroy" );
+     m_pFcFontSetAdd = (FcBool(*)(FcFontSet*,FcPattern*))
+         loadSymbol( "FcFontSetAdd" );
++    m_pFcPatternReference = (void(*)(FcPattern*))
++        loadSymbol( "FcPatternReference" );
+     m_pFcPatternGetString = (FcResult(*)(const FcPattern*,const char*,int,FcChar8**))
+         loadSymbol( "FcPatternGetString" );
+     m_pFcPatternGetInteger = (FcResult(*)(const FcPattern*,const char*,int,int*))
+@@ -262,12 +299,16 @@
+         loadSymbol( "FcPatternGetBool" );
+     m_pFcDefaultSubstitute = (void(*)(FcPattern *))
+         loadSymbol( "FcDefaultSubstitute" );
+-    m_pFcFontMatch = (FcPattern*(*)(FcConfig*,FcPattern*,FcResult*))
+-        loadSymbol( "FcFontMatch" );
++    m_pFcFontSetMatch = (FcPattern*(*)(FcConfig*,FcFontSet**, int, FcPattern*,FcResult*))
++        loadSymbol( "FcFontSetMatch" );
+     m_pFcConfigSubstitute = (FcBool(*)(FcConfig*,FcPattern*,FcMatchKind))
+         loadSymbol( "FcConfigSubstitute" );
+     m_pFcPatternAddInteger = (FcBool(*)(FcPattern*,const char*,int))
+         loadSymbol( "FcPatternAddInteger" );
++    m_pFcPatternAddBool = (FcBool(*)(FcPattern*,const char*,FcBool))
++        loadSymbol( "FcPatternAddBool" );
++    m_pFcPatternAddCharSet = (FcBool(*)(FcPattern*,const char*,const FcCharSet *))
++        loadSymbol( "FcPatternAddCharSet" );
+     m_pFcPatternAddString = (FcBool(*)(FcPattern*,const char*,const FcChar8*))
+         loadSymbol( "FcPatternAddString" );
+ 
+@@ -279,17 +320,23 @@
+             m_pFcPatternCreate				&&
+             m_pFcPatternDestroy				&&
+             m_pFcFontList					&&
++            m_pFcConfigGetFonts             &&
+             m_pFcFontSetCreate				&&
++            m_pFcCharSetCreate				&&
++            m_pFcCharSetAddChar 			&&
+             m_pFcFontSetDestroy				&&
+             m_pFcFontSetAdd					&&
++            m_pFcPatternReference           &&
+             m_pFcPatternGetString			&&
+             m_pFcPatternGetInteger			&&
+             m_pFcPatternGetDouble			&&
+             m_pFcPatternGetBool				&&
+             m_pFcDefaultSubstitute			&&
+-            m_pFcFontMatch					&&
++            m_pFcFontSetMatch				&&
+             m_pFcConfigSubstitute			&&
+             m_pFcPatternAddInteger			&&
++            m_pFcPatternAddCharSet			&&
++            m_pFcPatternAddBool 			&&
+             m_pFcPatternAddString
+             ) )
+     {
+@@ -307,10 +354,35 @@
+         osl_unloadModule( m_pLib );
+         m_pLib = NULL;
+     }
++
++    m_pOutlineSet = FcFontSetCreate();
++
++    /*
++      add only acceptable outlined fonts to our config, 
++      for future fontconfig use
++    */
++    FcFontSet *pOrig = FcConfigGetFonts(NULL, FcSetSystem);
++
++    if (!pOrig)
++        return;
++
++    for( int i = 0; i < pOrig->nfont; ++i )
++    {
++        FcBool outline = false;
++        FcPattern *pOutlinePattern = pOrig->fonts[i];
++        FcResult eOutRes = 
++			FcPatternGetBool( pOutlinePattern, FC_OUTLINE, 0, &outline );
++        if (eOutRes == FcResultMatch && !outline)
++            continue;
++        FcPatternReference(pOutlinePattern);
++        FcFontSetAdd(m_pOutlineSet, pOutlinePattern);
++    }
+ }
+ 
+ FontCfgWrapper::~FontCfgWrapper()
+ {
++	if( m_pOutlineSet )
++		FcFontSetDestroy( m_pOutlineSet );
+     if( m_pLib )
+         osl_unloadModule( m_pLib );
+ }
+@@ -346,19 +418,10 @@
+         return false;
+ 
+     FcConfig* pConfig = rWrapper.getDefConfig();
+-    FcObjectSet* pOSet = rWrapper.FcObjectSetBuild( FC_FAMILY,
+-                                                    FC_STYLE,
+-                                                    FC_SLANT,
+-                                                    FC_WEIGHT,
+-                                                    FC_SPACING,
+-                                                    FC_FILE,
+-                                                    FC_OUTLINE,
+-                                                    FC_INDEX,
+-                                                    (void *) NULL );
+-    FcPattern* pPattern = rWrapper.FcPatternCreate();
+-    FcFontSet* pFSet = rWrapper.FcFontList( pConfig, pPattern, pOSet );
+     rtl_TextEncoding aThreadTextEncoding = osl_getThreadTextEncoding();
+ 
++    FcFontSet* pFSet = rWrapper.getFontSet();
++
+     if( pFSet )
+     {
+ #if OSL_DEBUG_LEVEL > 1
+@@ -400,6 +463,8 @@
+                      );
+ #endif
+ 
++            OSL_ASSERT(eOutRes != FcResultMatch || outline);
++
+             // only outline fonts are usable to psprint anyway
+             if( eOutRes == FcResultMatch && ! outline )
+                 continue;
+@@ -542,14 +607,6 @@
+         }
+     }
+     
+-    // cleanup
+-    if( pPattern )
+-        rWrapper.FcPatternDestroy( pPattern );
+-    if( pFSet )
+-        rWrapper.FcFontSetDestroy( pFSet );
+-    if( pOSet )
+-        rWrapper.FcObjectSetDestroy( pOSet );
+-    
+     // how does one get rid of the config ?
+ #if OSL_DEBUG_LEVEL > 1
+     fprintf( stderr, "inserted %d fonts from fontconfig\n", nFonts );
+@@ -563,39 +620,14 @@
+     FontCfgWrapper::release();
+ }
+ 
+-bool PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale )
++static void addtopattern(FontCfgWrapper& rWrapper, FcPattern *pPattern, 
++	italic::type eItalic, weight::type eWeight, width::type eWidth, pitch::type ePitch)
+ {
+ #ifdef ENABLE_FONTCONFIG
+-    FontCfgWrapper& rWrapper = FontCfgWrapper::get();
+-    if( ! rWrapper.isValid() )
+-        return false;
 -
--    String aTestText;
--    aTestText.Append( Button::GetStandardText( BUTTON_OK ) );
--    aTestText.Append( Button::GetStandardText( BUTTON_CANCEL ) );
--    aTestText.Append( Button::GetStandardText( BUTTON_YES ) );
--    aTestText.Append( Button::GetStandardText( BUTTON_NO ) );
--    aTestText.Append( Button::GetStandardText( BUTTON_RETRY ) );
--    aTestText.Append( Button::GetStandardText( BUTTON_HELP ) );
--    aTestText.Append( Button::GetStandardText( BUTTON_CLOSE ) );
--    aTestText.Append( Button::GetStandardText( BUTTON_MORE ) );
--    aTestText.Append( Button::GetStandardText( BUTTON_LESS ) );
--    aTestText.Append( Button::GetStandardText( BUTTON_ABORT ) );
+-    FcConfig* pConfig = rWrapper.getDefConfig();
+-    FcPattern* pPattern = rWrapper.FcPatternCreate();
 -
--    return HasGlyphs( rFont, aTestText ) >= aTestText.Len();
-+    return true;
- }
+-    OString aLangAttrib;
+-    // populate pattern with font characteristics
+-    if( rLocale.Language.getLength() )
+-    {
+-        OUStringBuffer aLang(6);
+-        aLang.append( rLocale.Language );
+-        if( rLocale.Country.getLength() )
+-        {
+-            aLang.append( sal_Unicode('-') );
+-            aLang.append( rLocale.Country );
+-        }
+-        aLangAttrib = OUStringToOString( aLang.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
+-    }
+-    if( aLangAttrib.getLength() )
+-        rWrapper.FcPatternAddString( pPattern, FC_LANG, (FcChar8*)aLangAttrib.getStr() );
+-
+-    OString aFamily = OUStringToOString( rInfo.m_aFamilyName, RTL_TEXTENCODING_UTF8 );
+-    if( aFamily.getLength() )
+-        rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)aFamily.getStr() );
+-    if( rInfo.m_eItalic != italic::Unknown )
++    if( eItalic != italic::Unknown )
+     {
+         int nSlant = FC_SLANT_ROMAN;
+-        switch( rInfo.m_eItalic )
++        switch( eItalic )
+         {
+             case italic::Italic:	 	nSlant = FC_SLANT_ITALIC;break;
+             case italic::Oblique:	 	nSlant = FC_SLANT_OBLIQUE;break;
+@@ -604,10 +636,10 @@
+         }
+         rWrapper.FcPatternAddInteger( pPattern, FC_SLANT, nSlant );
+     }
+-    if( rInfo.m_eWeight != weight::Unknown )
++    if( eWeight != weight::Unknown )
+     {
+         int nWeight = FC_WEIGHT_NORMAL;
+-        switch( rInfo.m_eWeight )
++        switch( eWeight )
+         {
+             case weight::Thin:			nWeight = FC_WEIGHT_THIN;break;
+             case weight::UltraLight:	nWeight = FC_WEIGHT_ULTRALIGHT;break;
+@@ -624,10 +656,10 @@
+         }
+         rWrapper.FcPatternAddInteger( pPattern, FC_WEIGHT, nWeight );
+     }
+-    if( rInfo.m_eWidth != width::Unknown )
++    if( eWidth != width::Unknown )
+     {
+         int nWidth = FC_WIDTH_NORMAL;
+-        switch( rInfo.m_eWidth )
++        switch( eWidth )
+         {
+             case width::UltraCondensed:	nWidth = FC_WIDTH_ULTRACONDENSED;break;
+             case width::ExtraCondensed: nWidth = FC_WIDTH_EXTRACONDENSED;break;
+@@ -643,10 +675,10 @@
+         }
+         rWrapper.FcPatternAddInteger( pPattern, FC_WIDTH, nWidth );
+     }
+-    if( rInfo.m_ePitch != pitch::Unknown )
++    if( ePitch != pitch::Unknown )
+     {
+         int nSpacing = FC_PROPORTIONAL;
+-        switch( rInfo.m_ePitch )
++        switch( ePitch )
+         {
+             case pitch::Fixed:			nSpacing = FC_MONO;break;
+             case pitch::Variable:		nSpacing = FC_PROPORTIONAL;break;
+@@ -654,12 +686,122 @@
+                 break;
+         }
+         rWrapper.FcPatternAddInteger( pPattern, FC_SPACING, nSpacing );
++        if (nSpacing == FC_MONO)
++            rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)"monospace");
++    }
++#endif
++}
++
++String PrintFontManager::Substitute(const std::vector<String> &rNames, const std::vector<sal_Unicode> &rGlyphs,
++        const ByteString &rLangAttrib, italic::type eItalic, weight::type eWeight,
++        width::type eWidth, pitch::type ePitch) const
++{
++    String aName;
++#ifdef ENABLE_FONTCONFIG
++    FontCfgWrapper& rWrapper = FontCfgWrapper::get();
++    if( ! rWrapper.isValid() )
++        return aName;
++
++    FcFontSet*  pSet = NULL;
++    FcPattern*  pPattern = rWrapper.FcPatternCreate();
++
++    // Prefer scalable fonts
++    rWrapper.FcPatternAddBool( pPattern, FC_SCALABLE, 1 );
++
++    std::vector<String>::const_iterator aEnd = rNames.end();
++    for (std::vector<String>::const_iterator aIter = rNames.begin(); aIter != aEnd; ++aIter)
++    {
++	    OString maTargetName = OUStringToOString(*aIter, RTL_TEXTENCODING_UTF8);
++        rWrapper.FcPatternAddString(pPattern, FC_FAMILY, (FcChar8*)maTargetName.getStr());
++    }
++
++    if( rLangAttrib.Len() )
++        rWrapper.FcPatternAddString(pPattern, FC_LANG, (FcChar8*)rLangAttrib.GetBuffer());
++
++    // Add required Unicode characters, if any
++    FcCharSet *unicodes = NULL;
++    if (! rGlyphs.empty() )
++    {
++        unicodes = rWrapper.FcCharSetCreate();
++	    std::vector<sal_Unicode>::const_iterator aGlyphEnd = rGlyphs.end();
++	    for (std::vector<sal_Unicode>::const_iterator aGlyphIter = rGlyphs.begin(); 
++            aGlyphIter != aGlyphEnd; ++aGlyphIter)
++	    {
++            rWrapper.FcCharSetAddChar( unicodes, (FcChar32)*aGlyphIter );
++	    }
++        rWrapper.FcPatternAddCharSet( pPattern, FC_CHARSET, unicodes);
++    }
++
++    addtopattern(rWrapper, pPattern, eItalic, eWeight, eWidth, ePitch);
++
++    rWrapper.FcConfigSubstitute( NULL, pPattern, FcMatchPattern );
++    rWrapper.FcDefaultSubstitute( pPattern );
++    FcResult eResult = FcResultNoMatch;
++    FcFontSet *pFontSet = rWrapper.getFontSet();
++    FcPattern* pResult = rWrapper.FcFontSetMatch( NULL, &pFontSet, 1, pPattern, &eResult );
++    rWrapper.FcPatternDestroy( pPattern );
++
++    if( pResult )
++    {
++        pSet = rWrapper.FcFontSetCreate();
++        // info: destroying the pSet destroys pResult implicitly
++        // since pResult was "added" to pSet
++        rWrapper.FcFontSetAdd( pSet, pResult );
+     }
  
- // -----------------------------------------------------------------------
++    if( pSet )
++    {
++        if( pSet->nfont > 0 )
++        {
++            //extract the closest match
++            FcChar8* family = NULL;
++            FcResult eFileRes = rWrapper.FcPatternGetString( pSet->fonts[0], FC_FAMILY, 0, &family );
++            if( eFileRes == FcResultMatch )
++                aName = String( (sal_Char*)family, RTL_TEXTENCODING_UTF8 );
++        }
++    }
++    rWrapper.FcFontSetDestroy( pSet );
++#endif
++    return aName;
++}
++
++bool PrintFontManager::matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale )
++{
++#ifdef ENABLE_FONTCONFIG
++    FontCfgWrapper& rWrapper = FontCfgWrapper::get();
++    if( ! rWrapper.isValid() )
++        return false;
++
++    FcConfig* pConfig = rWrapper.getDefConfig();
++    FcPattern* pPattern = rWrapper.FcPatternCreate();
++
++    OString aLangAttrib;
++    // populate pattern with font characteristics
++    if( rLocale.Language.getLength() )
++    {
++        OUStringBuffer aLang(6);
++        aLang.append( rLocale.Language );
++        if( rLocale.Country.getLength() )
++        {
++            aLang.append( sal_Unicode('-') );
++            aLang.append( rLocale.Country );
++        }
++        aLangAttrib = OUStringToOString( aLang.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
++    }
++    if( aLangAttrib.getLength() )
++        rWrapper.FcPatternAddString( pPattern, FC_LANG, (FcChar8*)aLangAttrib.getStr() );
++
++    OString aFamily = OUStringToOString( rInfo.m_aFamilyName, RTL_TEXTENCODING_UTF8 );
++    if( aFamily.getLength() )
++        rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)aFamily.getStr() );
++
++    addtopattern(rWrapper, pPattern, rInfo.m_eItalic, rInfo.m_eWeight, rInfo.m_eWidth, rInfo.m_ePitch);
++
+     rWrapper.FcConfigSubstitute( pConfig, pPattern, FcMatchPattern );
+     rWrapper.FcDefaultSubstitute( pPattern );
+     FcResult eResult = FcResultNoMatch;
+-    FcPattern* pResult = rWrapper.FcFontMatch( pConfig, pPattern, &eResult );
++    FcFontSet *pFontSet = rWrapper.getFontSet();
++    FcPattern* pResult = rWrapper.FcFontSetMatch( pConfig, &pFontSet, 1, pPattern, &eResult );
+     bool bSuccess = false;
+     if( pResult )
+     {
+diff -ru psprint.preconfig/source/fontmanager/fontmanager.cxx psprint/source/fontmanager/fontmanager.cxx
+--- openoffice.org.orig/psprint/source/fontmanager/fontmanager.cxx	2005-09-12 13:41:08.000000000 +0100
++++ openoffice.org/psprint/source/fontmanager/fontmanager.cxx	2005-09-12 15:21:47.000000000 +0100
+@@ -1181,7 +1181,8 @@
+         m_nNextFontID( 1 ),
+         m_pAtoms( new MultiAtomProvider() ),
+         m_nNextDirAtom( 1 ),
+-        m_pFontCache( NULL )
++        m_pFontCache( NULL ),
++	m_bFontconfigSuccess(false)
+ {
+     for( unsigned int i = 0; i < sizeof( aAdobeCodes )/sizeof( aAdobeCodes[0] ); i++ )
+     {
+@@ -2135,7 +2136,7 @@
+ #endif
+ 
+     // first try fontconfig
+-    bool bFontconfigSuccess = initFontconfig();
++    m_bFontconfigSuccess = initFontconfig();
+ 
+     // part one - look for downloadable fonts
+     rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
+@@ -2157,7 +2158,7 @@
+     }
+ 
+     // don't search through many directories fontconfig already told us about
+-    if( ! bFontconfigSuccess )
++    if( ! m_bFontconfigSuccess )
+     {							
+         Display *pDisplay = (Display*)pInitDisplay;
+         
+@@ -2235,7 +2236,7 @@
+             }
+         }
+ #endif /* SOLARIS */
+-    } // ! bFontconfigSuccess
++    } // ! m_bFontconfigSuccess
+ 
+     // fill XLFD aliases from fonts.alias files
+     initFontsAlias();




More information about the fedora-cvs-commits mailing list