--- psprint/inc/psprint/fontmanager.hxx.orig 2007-07-04 13:22:09.000000000 +0800 +++ psprint/inc/psprint/fontmanager.hxx 2007-07-04 18:38:21.000000000 +0800 @@ -761,6 +761,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 IsSupportCJK( const String& rFontName ); }; } // namespace --- psprint/source/fontmanager/fontconfig.cxx.orig 2007-07-04 13:22:09.000000000 +0800 +++ psprint/source/fontmanager/fontconfig.cxx 2007-07-04 13:49:37.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 ); @@ -1034,3 +1071,57 @@ bool PrintFontManager::matchFont( FastPr return false; #endif } + +bool PrintFontManager::IsSupportCJK( 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 +} --- vcl/inc/vcl/font.hxx.orig 2007-07-04 13:58:22.000000000 +0800 +++ vcl/inc/vcl/font.hxx 2007-07-05 14:12:03.000000000 +0800 @@ -156,6 +156,9 @@ public: friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Font& ); static Font identifyFont( const void* pBuffer, sal_uInt32 nLen ); + + // #i73003# + BOOL IsSupportCJK() const; }; #endif // _VCL_FONT_HXX --- vcl/source/gdi/font.cxx.orig 2007-07-04 14:00:22.000000000 +0800 +++ vcl/source/gdi/font.cxx 2007-07-05 14:11:42.000000000 +0800 @@ -61,7 +61,9 @@ #endif #include - +#ifndef _PSPRINT_FONTMANAGER_HXX_ +#include +#endif // ======================================================================= DBG_NAME( Font ) @@ -1069,6 +1071,17 @@ Font Font::identifyFont( const void* i_p return aResult; } +// #i73003# +BOOL Font::IsSupportCJK() const +{ + BOOL bRet = TRUE; + const String aFamilyName = GetName(); + #ifdef UNX + bRet = ::psp::PrintFontManager::get().IsSupportCJK(aFamilyName); + #endif + return bRet; +} + // the inlines from the font.hxx header are now instantiated for pImpl-ification // TODO: reformat const Color& Font::GetColor() const { return mpImplFont->maColor; } --- svtools/inc/ctrlbox.hxx.orig 2007-07-04 13:22:09.000000000 +0800 +++ svtools/inc/ctrlbox.hxx 2007-07-05 14:12:45.000000000 +0800 @@ -384,6 +384,7 @@ private: Image maImageScalableFont; BOOL mbWYSIWYG; BOOL mbSymbols; + BOOL mbOnlyListCJKFont; // #i73003# #ifdef _CTRLBOX_CXX SVT_DLLPRIVATE void ImplCalcUserItemSize(); --- svtools/source/control/ctrlbox.cxx.orig 2007-07-04 13:22:09.000000000 +0800 +++ svtools/source/control/ctrlbox.cxx 2007-07-05 14:14:01.000000000 +0800 @@ -61,6 +61,8 @@ #include +#define LB_EAST_NAME 112 + #define IMGTEXTSPACE 2 #define EXTRAFONTSIZE 5 @@ -622,6 +624,7 @@ FontNameBox::FontNameBox( Window* pParen mpFontList = NULL; mbWYSIWYG = FALSE; mbSymbols = FALSE; + mbOnlyListCJKFont = FALSE; } // ------------------------------------------------------------------- @@ -633,6 +636,11 @@ FontNameBox::FontNameBox( Window* pParen mpFontList = NULL; mbWYSIWYG = FALSE; mbSymbols = FALSE; + if( rResId.GetId() == LB_EAST_NAME ) + { + mbOnlyListCJKFont = TRUE; + } + } // ------------------------------------------------------------------- @@ -696,6 +704,14 @@ void FontNameBox::Fill( const FontList* for ( USHORT i = 0; i < nFontCount; i++ ) { const FontInfo& rFontInfo = pList->GetFontName( i ); + + // #i73003# + if( mbOnlyListCJKFont && (!rFontInfo.IsSupportCJK()) ) + { + //Only list CJK font + continue; + } + ULONG nIndex = InsertEntry( rFontInfo.GetName() ); if ( nIndex != LISTBOX_ERROR ) { --- svx/source/items/textitem.cxx.orig 2007-07-04 13:22:10.000000000 +0800 +++ svx/source/items/textitem.cxx 2007-07-05 14:14:31.000000000 +0800 @@ -3717,7 +3717,7 @@ { USHORT nLatin, nAsian, nComplex; GetWhichIds( nLatin, nAsian, nComplex ); - + SfxPoolItem* pCpy = rItem.Clone(); if( SCRIPTTYPE_LATIN & nScriptType ) { @@ -3726,8 +3726,19 @@ } if( SCRIPTTYPE_ASIAN & nScriptType ) { - pCpy->SetWhich( nAsian ); - GetItemSet().Put( *pCpy ); + // #i73003#, if the font supports cjk lang, apply it. + sal_Bool bCJKFont = sal_True; + if ( rItem.ISA(SvxFontItem) ) + { + Font aFont; + aFont.SetName(((SvxFontItem&)rItem).GetFamilyName()); + bCJKFont = aFont.IsSupportCJK(); + } + if( bCJKFont ) + { + pCpy->SetWhich( nAsian ); + GetItemSet().Put( *pCpy ); + } } if( SCRIPTTYPE_COMPLEX & nScriptType ) {