--- ./psprint/inc/psprint/fontmanager.hxx.bak	2006-12-18 14:48:53.000000000 +0800
+++ ./psprint/inc/psprint/fontmanager.hxx	2006-12-18 14:49:17.000000000 +0800
@@ -756,6 +756,7 @@ public:
         const ByteString &rLangAttrib, italic::type eItalic, weight::type eWeight, 
         width::type eWidth, pitch::type ePitch) const;
     bool hasFontconfig() const { return m_bFontconfigSuccess; }
+    bool IsCJKFont( const String& rFontName );
 };
 
 } // namespace
--- ./psprint/source/fontmanager/fontconfig.cxx.bak	2006-12-18 14:50:14.000000000 +0800
+++ ./psprint/source/fontmanager/fontconfig.cxx	2006-12-18 14:51:48.000000000 +0800
@@ -126,6 +126,12 @@ class FontCfgWrapper
     FcBool                    (*m_pFcPatternAddCharSet)(FcPattern*,const char*,const FcCharSet*);
     FcBool			(*m_pFcPatternAddString)(FcPattern*,const char*,const FcChar8*);
 
+	FcLangSet*      (*m_pFcLangSetCreate)();
+	void            (*m_pFcLangSetDestroy)(FcLangSet*);
+	FcBool			(*m_pFcLangSetAdd)(FcLangSet*, const FcChar8*);
+	FcLangResult	(*m_pFcLangSetHasLang) (const FcLangSet*, const FcChar8*);
+	FcResult		(*m_pFcPatternGetLangSet)(const FcPattern*, const char*, int, FcLangSet **);
+
     oslGenericFunction loadSymbol( const char* );
 
     FontCfgWrapper();
@@ -227,6 +233,21 @@ public:
     { return m_pFcPatternAddBool( pPattern, pObject, nValue ); }
     FcBool FcPatternAddCharSet(FcPattern* pPattern,const char* pObject,const FcCharSet*pCharSet)
     { return m_pFcPatternAddCharSet(pPattern,pObject,pCharSet); }
+	
+	FcLangSet* FcLangSetCreate ()
+	{ return m_pFcLangSetCreate();}
+	
+	void FcLangSetDestroy (FcLangSet *pSet)
+	{ m_pFcLangSetDestroy(pSet); }
+	
+	FcBool FcLangSetAdd (FcLangSet *pSet, const FcChar8 *lang)
+	{ return m_pFcLangSetAdd( pSet, lang ); }
+
+	FcLangResult FcLangSetHasLang (const FcLangSet *pSet, const FcChar8 *lang)
+	{ return m_pFcLangSetHasLang( pSet, lang );}
+
+	FcResult FcPatternGetLangSet(const FcPattern *pPattern, const char *object, int n, FcLangSet **s)
+	{  return m_pFcPatternGetLangSet( pPattern, object, n, s ); }
 };
 
 oslGenericFunction FontCfgWrapper::loadSymbol( const char* pSymbol )
@@ -321,6 +342,17 @@ FontCfgWrapper::FontCfgWrapper()
     m_pFcPatternAddString = (FcBool(*)(FcPattern*,const char*,const FcChar8*))
         loadSymbol( "FcPatternAddString" );
 
+	m_pFcLangSetCreate = (FcLangSet*(*)())
+        loadSymbol( "FcLangSetCreate" );
+	m_pFcLangSetDestroy = (void(*)(FcLangSet*))
+        loadSymbol( "FcLangSetDestroy" );
+	m_pFcLangSetAdd = (FcBool(*)(FcLangSet*, const FcChar8*))
+        loadSymbol( "FcLangSetAdd" );
+	m_pFcLangSetHasLang = (FcLangResult(*)(const FcLangSet*, const FcChar8*))
+		 loadSymbol( "FcLangSetHasLang" );
+	m_pFcPatternGetLangSet = (FcResult(*)(const FcPattern*,const char*,int,FcLangSet**))
+        loadSymbol( "FcPatternGetLangSet" );
+
     if( ! (
             m_pFcInit						&&
             m_pFcConfigGetCurrent			&&
@@ -349,7 +381,12 @@ FontCfgWrapper::FontCfgWrapper()
             m_pFcPatternAddDouble                     &&
             m_pFcPatternAddCharSet			&&
             m_pFcPatternAddBool 			&&
-            m_pFcPatternAddString
+            m_pFcPatternAddString			&&
+			m_pFcLangSetCreate				&&
+			m_pFcLangSetDestroy				&&
+			m_pFcLangSetAdd					&&
+			m_pFcLangSetHasLang				&&
+			m_pFcPatternGetLangSet
             ) )
     {
         osl_unloadModule( (oslModule)m_pLib );
@@ -1024,3 +1061,57 @@ bool PrintFontManager::matchFont( FastPr
     return false;
 #endif
 }
+
+bool PrintFontManager::IsCJKFont( const String& rFontName )
+{
+#ifdef ENABLE_FONTCONFIG
+    FontCfgWrapper& rWrapper = FontCfgWrapper::get();
+    if( ! rWrapper.isValid() )
+        return false;	
+
+    FcConfig* pConfig = rWrapper.getDefConfig();
+    FcPattern* pPattern = rWrapper.FcPatternCreate();
+	
+	OString aFullName = OUStringToOString( rFontName, RTL_TEXTENCODING_UTF8 );
+	
+	rWrapper.FcPatternAddString( pPattern, FC_FAMILY, (FcChar8*)aFullName.getStr() );	
+
+    rWrapper.FcConfigSubstitute( pConfig, pPattern, FcMatchPattern );
+    rWrapper.FcDefaultSubstitute( pPattern );
+    FcResult eResult = FcResultNoMatch;
+    FcFontSet *pFontSet = rWrapper.getFontSet();
+    FcPattern* pResult = rWrapper.FcFontSetMatch( pConfig, &pFontSet, 1, pPattern, &eResult );
+    bool bSuccess = false;
+    if( pResult )
+    {
+		FcFontSet* pSet = rWrapper.FcFontSetCreate();
+        rWrapper.FcFontSetAdd( pSet, pResult );
+        if( pSet->nfont > 0 )
+        {
+            //extract the closest match
+			FcLangSet *pLangSet;
+            if (rWrapper.FcPatternGetLangSet(pSet->fonts[0], FC_LANG, 0, &pLangSet) == FcResultMatch)
+			{
+				if( rWrapper.FcLangSetHasLang(pLangSet, (FcChar8*)"zh-cn")!= FcLangDifferentLang
+					|| rWrapper.FcLangSetHasLang(pLangSet, (FcChar8*)"zh-hk")!= FcLangDifferentLang
+					|| rWrapper.FcLangSetHasLang(pLangSet, (FcChar8*)"zh-sg")!= FcLangDifferentLang
+					|| rWrapper.FcLangSetHasLang(pLangSet, (FcChar8*)"zh-tw")!= FcLangDifferentLang
+					|| rWrapper.FcLangSetHasLang(pLangSet, (FcChar8*)"ja")!= FcLangDifferentLang
+					|| rWrapper.FcLangSetHasLang(pLangSet, (FcChar8*)"ko")!= FcLangDifferentLang )
+				{
+					bSuccess = true;
+				}
+			}
+        }
+        // info: destroying the pSet destroys pResult implicitly
+        // since pResult was "added" to pSet
+        rWrapper.FcFontSetDestroy( pSet );
+    }
+    // cleanup
+    rWrapper.FcPatternDestroy( pPattern );
+
+    return bSuccess;
+#else
+    return true;	
+#endif
+}
--- ./svtools/inc/ctrlbox.hxx.bak	2006-12-18 14:56:43.000000000 +0800
+++ ./svtools/inc/ctrlbox.hxx	2006-12-18 14:56:56.000000000 +0800
@@ -384,6 +384,7 @@ private:
 	Image			maImageScalableFont;
 	BOOL			mbWYSIWYG;
 	BOOL			mbSymbols;
+	BOOL			mbOnlyListCJKFont;
 
 #ifdef _CTRLBOX_CXX
 	SVT_DLLPRIVATE void			ImplCalcUserItemSize();
--- ./svtools/source/control/ctrlbox.cxx.bak	2006-12-18 14:57:34.000000000 +0800
+++ ./svtools/source/control/ctrlbox.cxx	2006-12-19 10:45:37.000000000 +0800
@@ -61,6 +61,15 @@
 
 #include <vcl/i18nhelp.hxx>
 
+//#CJK Font#
+#ifdef UNX
+#ifndef _PSPRINT_FONTMANAGER_HXX_
+#include <psprint/fontmanager.hxx>
+#endif
+#endif
+
+#define LB_EAST_NAME 112
+
 #define IMGTEXTSPACE    2
 #define EXTRAFONTSIZE   5
 
@@ -622,6 +631,7 @@ FontNameBox::FontNameBox( Window* pParen
     mpFontList = NULL;
     mbWYSIWYG = FALSE;
     mbSymbols = FALSE;
+	mbOnlyListCJKFont = FALSE;
 }
 
 // -------------------------------------------------------------------
@@ -633,6 +643,11 @@ FontNameBox::FontNameBox( Window* pParen
     mpFontList = NULL;
     mbWYSIWYG = FALSE;
     mbSymbols = FALSE;
+	if( rResId.GetId() == LB_EAST_NAME )
+	{
+		mbOnlyListCJKFont = TRUE;
+	}
+	
 }
 
 // -------------------------------------------------------------------
@@ -696,6 +711,15 @@ void FontNameBox::Fill( const FontList* 
     for ( USHORT i = 0; i < nFontCount; i++ )
     {
         const FontInfo& rFontInfo = pList->GetFontName( i );
+		
+		#ifdef UNX
+		if( mbOnlyListCJKFont && (!::psp::PrintFontManager::get().IsCJKFont( rFontInfo.GetName() )))
+		{
+			//Only list CJK font
+			continue;
+		}
+		#endif
+		
         ULONG nIndex = InsertEntry( rFontInfo.GetName() );
         if ( nIndex != LISTBOX_ERROR )
         {
--- ./svtools/util/makefile.mk.bak	2006-12-18 15:01:01.000000000 +0800
+++ ./svtools/util/makefile.mk	2006-12-19 10:44:10.000000000 +0800
@@ -174,6 +174,10 @@ SHL1STDLIBS+= \
 		oleaut32.lib
 .ENDIF # WNT
 
+.IF "$(GUI)"=="UNX"
+SHL1STDLIBS+= -lpsp$(UPD)$(DLLPOSTFIX)
+.ENDIF # UNX
+
 SHL1OBJS= \
 	$(SLO)$/svtdata.obj
 
--- ./svx/source/items/textitem.cxx.bak	2006-12-18 15:02:32.000000000 +0800
+++ ./svx/source/items/textitem.cxx	2006-12-19 10:20:01.000000000 +0800
@@ -222,6 +222,13 @@
 #include <tools/tenccvt.hxx>
 #endif
 
+//#CJK Font#
+#ifdef UNX
+#ifndef _PSPRINT_FONTMANAGER_HXX_
+#include <psprint/fontmanager.hxx>
+#endif
+#endif
+
 #define STORE_UNICODE_MAGIC_MARKER  0xFE331188
 
 using namespace ::rtl;
@@ -3745,7 +3752,7 @@ void SvxScriptSetItem::PutItemForScriptT
 {
 	USHORT nLatin, nAsian, nComplex;
 	GetWhichIds( nLatin, nAsian, nComplex );
-
+	
 	SfxPoolItem* pCpy = rItem.Clone();
 	if( SCRIPTTYPE_LATIN & nScriptType )
 	{
@@ -3754,8 +3761,19 @@ void SvxScriptSetItem::PutItemForScriptT
 	}
 	if( SCRIPTTYPE_ASIAN & nScriptType )
 	{
-		pCpy->SetWhich( nAsian );
-		GetItemSet().Put( *pCpy );
+		//if the font supports cjk lang, apply it.
+		sal_Bool bCJKFont = sal_True;
+		#ifdef UNX
+		if ( rItem.ISA(SvxFontItem) )
+		{
+			bCJKFont =::psp::PrintFontManager::get().IsCJKFont( ((SvxFontItem&)rItem).GetFamilyName());
+		}
+		#endif
+		if( bCJKFont )
+		{
+			pCpy->SetWhich( nAsian );
+			GetItemSet().Put( *pCpy );
+		}
 	}
 	if( SCRIPTTYPE_COMPLEX & nScriptType )
 	{
--- ./svx/util/makefile.mk.bak	2006-12-18 15:03:49.000000000 +0800
+++ ./svx/util/makefile.mk	2006-12-19 10:18:20.000000000 +0800
@@ -128,6 +128,10 @@ SHL1STDLIBS= \
 SHL1STDLIBS+=$(SHELLLIB)
 .ENDIF # WNT
 
+.IF "$(GUI)"=="UNX"
+SHL1STDLIBS+=-lpsp$(UPD)$(DLLPOSTFIX)
+.ENDIF # UNX
+
 SHL1DEF=	$(MISC)$/$(SHL1TARGET).def
 DEF1NAME=	$(SHL1TARGET)
 DEFLIB1NAME=$(TARGET)
