Index: inc/salgdi.h =================================================================== RCS file: /cvs/gsl/vcl/win/inc/salgdi.h,v --- inc/salgdi.h 14 Jun 2008 06:27:30 -0000 1.30.20.1 +++ inc/salgdi.h 4 Jul 2008 08:59:30 -0000 @@ -39,9 +39,16 @@ #include "boost/scoped_ptr.hpp" #include +#include +typedef std::hash_map IntMap; + + +#define USE_UNISCRIBE +#ifdef USE_UNISCRIBE +#include +#endif // USE_UNISCRIBE class ImplFontSelectData; -class ImplWinFontEntry; class ImplFontAttrCache; // ----------- @@ -52,10 +59,47 @@ #define PALRGB_TO_RGB(nPalRGB) ((nPalRGB)&0x00ffffff) // win32 platform specific options. Move them to the PMK file? -#define USE_UNISCRIBE + #define GCP_KERN_HACK #define GNG_VERT_HACK +// win32 specific physical font instance +class ImplWinFontEntry : public ImplFontEntry +{ +public: + ImplWinFontEntry( ImplFontSelectData& ); + ~ImplWinFontEntry(); + +private: + // TODO: also add HFONT??? Watch out for issues with too many active fonts... + +#ifdef GCP_KERN_HACK +public: + bool HasKernData() const; + void SetKernData( int, const KERNINGPAIR* ); + int GetKerning( sal_Unicode, sal_Unicode ) const; +private: + KERNINGPAIR* mpKerningPairs; + int mnKerningPairs; +#endif // GCP_KERN_HACK + +#ifdef USE_UNISCRIBE +public: + SCRIPT_CACHE& GetScriptCache() const + { return maScriptCache; } + int GetKashidaWidth( HDC ) const; +private: + mutable SCRIPT_CACHE maScriptCache; +#endif // USE_UNISCRIBE + +public: + int GetCachedGlyphWidth( int nCharCode ) const; + void CacheGlyphWidth( int nCharCode, int nCharWidth ); +private: + IntMap maWidthMap; +}; + + // win32 specific physically available font face class ImplWinFontData : public ImplFontData { Index: source/gdi/salgdi3.cxx =================================================================== RCS file: /cvs/gsl/vcl/win/source/gdi/salgdi3.cxx,v --- source/gdi/salgdi3.cxx 14 Jun 2008 06:27:30 -0000 1.95.14.1 +++ source/gdi/salgdi3.cxx 4 Jul 2008 08:31:20 -0000 @@ -115,40 +115,6 @@ // ======================================================================= // ----------------------------------------------------------------------- -// dynamic loading of usp library -// copied from winlayout.cxx - -static oslModule aUspModule = NULL; -static bool bUspEnabled = true; - -static HRESULT ((WINAPI *pScriptGetFontProperties)( HDC, SCRIPT_CACHE*, SCRIPT_FONTPROPERTIES* )); -static HRESULT ((WINAPI *pScriptFreeCache)( SCRIPT_CACHE* )); - -static bool InitUSP() -{ - rtl::OUString aLibraryName( RTL_CONSTASCII_USTRINGPARAM( "usp10" ) ); - aUspModule = osl_loadModule( aLibraryName.pData, SAL_LOADMODULE_DEFAULT ); - if( !aUspModule ) - return (bUspEnabled = false); - - - rtl::OUString queryFuncName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScriptGetFontProperties" ) ); - pScriptGetFontProperties = (HRESULT (WINAPI*)( HDC,SCRIPT_CACHE*,SCRIPT_FONTPROPERTIES*)) - osl_getSymbol( aUspModule, queryFuncName.pData ); - bUspEnabled &= (NULL != pScriptGetFontProperties); - - queryFuncName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScriptFreeCache" ) ); - pScriptFreeCache = (HRESULT (WINAPI*)(SCRIPT_CACHE*)) - osl_getSymbol( aUspModule, queryFuncName.pData ); - bUspEnabled &= (NULL != pScriptFreeCache); - - if( !bUspEnabled ) - { - osl_unloadModule( aUspModule ); - aUspModule = NULL; - } - return bUspEnabled; -} // TODO: also support temporary TTC font files typedef std::map< String, ImplDevFontAttributes > FontAttrMap; @@ -1375,7 +1341,7 @@ } DBG_ASSERT( pFont->mpFontData, "WinSalGraphics mpFontData==NULL"); - mpWinFontEntry[ nFallbackLevel ] = reinterpret_cast( pFont->mpFontEntry ); + mpWinFontEntry[ nFallbackLevel ] = static_cast( pFont->mpFontEntry ); mpWinFontData[ nFallbackLevel ] = static_cast( pFont->mpFontData ); HFONT hOldFont = 0; @@ -1509,22 +1475,9 @@ pMetric->mnDescent += pMetric->mnExtLeading; } - if( mpWinFontData[0] && mpWinFontData[0]->SupportsArabic() ) + if( mpWinFontData[0] && mpWinFontData[0]->SupportsArabic() && mpWinFontEntry[0] ) { - if (aUspModule || (bUspEnabled && InitUSP()) ) - { - //ScriptGetFontProperties - SCRIPT_FONTPROPERTIES aFontProperties; - SCRIPT_CACHE aScriptCache = NULL; // should use ScriptCache from ImplWinFontEntry - // but how do I get there - aFontProperties.cBytes = sizeof (aFontProperties); - HRESULT nRC = (*pScriptGetFontProperties)( mhDC, &aScriptCache, &aFontProperties ); - if( !nRC ) - { - pMetric->mnMinKashida = static_cast( mfFontScale * aFontProperties.iKashidaWidth); - } - (*pScriptFreeCache)( &aScriptCache ); - } + pMetric->mnMinKashida = static_cast( mfFontScale * mpWinFontEntry[0]->GetKashidaWidth( mhDC )); } } Index: source/gdi/winlayout.cxx =================================================================== RCS file: /cvs/gsl/vcl/win/source/gdi/winlayout.cxx,v --- source/gdi/winlayout.cxx 14 Jun 2008 06:27:30 -0000 1.113.6.1 +++ source/gdi/winlayout.cxx 4 Jul 2008 09:35:43 -0000 @@ -60,10 +60,10 @@ #include #endif // USE_UNISCRIBE -#include -typedef std::hash_map IntMap; -#include -typedef std::set IntSet; +//#include +//typedef std::hash_map IntMap; +//#include +//typedef std::set IntSet; #define DROPPED_OUTGLYPH 0xFFFF @@ -71,40 +71,7 @@ // ======================================================================= -// win32 specific physical font instance -class ImplWinFontEntry : public ImplFontEntry -{ -public: - ImplWinFontEntry( ImplFontSelectData& ); - ~ImplWinFontEntry(); - -private: - // TODO: also add HFONT??? Watch out for issues with too many active fonts... - -#ifdef GCP_KERN_HACK -public: - bool HasKernData() const; - void SetKernData( int, const KERNINGPAIR* ); - int GetKerning( sal_Unicode, sal_Unicode ) const; -private: - KERNINGPAIR* mpKerningPairs; - int mnKerningPairs; -#endif // GCP_KERN_HACK -#ifdef USE_UNISCRIBE -public: - SCRIPT_CACHE& GetScriptCache() const - { return maScriptCache; } -private: - mutable SCRIPT_CACHE maScriptCache; -#endif // USE_UNISCRIBE - -public: - int GetCachedGlyphWidth( int nCharCode ) const; - void CacheGlyphWidth( int nCharCode, int nCharWidth ); -private: - IntMap maWidthMap; -}; // ----------------------------------------------------------------------- @@ -1673,15 +1640,7 @@ } } - //ScriptGetFontProperties - SCRIPT_FONTPROPERTIES aFontProperties; - aFontProperties.cBytes = sizeof (aFontProperties); // don't forget to initialize - mnMinKashidaWidth = 0; - HRESULT nRC = (*pScriptGetFontProperties)( mhDC, &rScriptCache, &aFontProperties ); - if( !nRC ) - { - mnMinKashidaWidth = aFontProperties.iKashidaWidth; - } + mnMinKashidaWidth = mrWinFontEntry.GetKashidaWidth ( mhDC ); // scale layout metrics if needed if( mfFontScale != 1.0 ) @@ -2523,19 +2482,12 @@ nItemWidth += mpCharWidths[ i ]; nItemWidth = (int)((fStretch - 1.0) * nItemWidth + 0.5); - SCRIPT_FONTPROPERTIES aFontProperties; - aFontProperties.cBytes = sizeof (aFontProperties); // don't forget to initialize - int nMinKashida = 1; - HRESULT nRC = (*pScriptGetFontProperties)( mhDC, &rScriptCache, &aFontProperties ); - if( !nRC ) - nMinKashida = aFontProperties.iKashidaWidth; - - nRC = (*pScriptJustify) ( + HRESULT nRC = (*pScriptJustify) ( mpVisualAttrs + rVisualItem.mnMinGlyphPos, mpGlyphAdvances + rVisualItem.mnMinGlyphPos, rVisualItem.mnEndGlyphPos - rVisualItem.mnMinGlyphPos, nItemWidth, - nMinKashida, + mnMinKashidaWidth, mpJustifications + rVisualItem.mnMinGlyphPos ); rVisualItem.mnXOffset = nXOffset; @@ -2655,6 +2607,26 @@ return nKernAmount; } +// ----------------------------------------------------------------------- + +int ImplWinFontEntry::GetKashidaWidth( HDC hDC ) const +{ +#ifdef USE_UNISCRIBE + if (aUspModule || (bUspEnabled && InitUSP())) + { + SCRIPT_FONTPROPERTIES aFontProperties; + aFontProperties.cBytes = sizeof (aFontProperties); + SCRIPT_CACHE& rScriptCache = GetScriptCache(); + HRESULT nRC = (*pScriptGetFontProperties)( hDC, &rScriptCache, &aFontProperties ); + if( !nRC ) + return aFontProperties.iKashidaWidth; + } +#endif // USE_UNISCRIBE + return 0; +} + + + // ======================================================================= ImplFontData* ImplWinFontData::Clone() const