Commits

Anonymous committed 3caa54d Merge

CWS-TOOLING: integrate CWS graphite03_OOO330

  • Participants
  • Parent commits d5eb667, ffe2d84

Comments (0)

Files changed (11)

File graphite/graphite-2.3.1.patch

 +###CPPFLAGS= /Zc:wchar_t- /nologo /W4 /GR /EHsc /I "./src/font" /I "./src/painter" /I "./src/segment" /I "./src/textsource" /I "./src/generic" /I "./include/graphite" /I "../wrappers/win32" /D "GR_NAMESPACE" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "TRACING"  /Fp"$(INTDIR)\graphite.pch" /Fd"$(INTDIR)\\" /FD /c
 +### HDU: because for full binary compatibility with the rest of OOo all compile flags must match exactly
 +###       which is especially true for template-heavy C++ code with non-default config (e.g. _STLP_DEBUG enabled)
-+CPPFLAGS= $(CFLAGS4MSC) /nologo /W4 /I "./src/font" /I "./src/painter" /I "./src/segment" /I "./src/textsource" /I "./src/generic" /I "./include/graphite" /I "../wrappers/win32" /D "GR_NAMESPACE" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "TRACING"  /Fp"$(INTDIR)\graphite.pch" /Fd"$(INTDIR)\\" /FD /c
++CPPFLAGS= $(CFLAGS4MSC) /nologo /W4 /I "./src/font" /I "./src/painter" /I "./src/segment" /I "./src/textsource" /I "./src/generic" /I "./include/graphite" /I "../wrappers/win32" /D "GR_NAMESPACE" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "TRACING"  /Fp"$(INTDIR)\graphite.pch" /FD /c
 +
  # /Wp62
  
  
  BSC32=bscmake.exe
  BSC32_FLAGS=/nologo /o"$(OUTDIR)\\$(TARGET).bsc" 
-@@ -48,11 +52,7 @@
+@@ -24,21 +29,21 @@
+ SBREXT = .sbr
+ 
+ !IF "$(CFG)" == "DEBUG"
+-CPP_DEBUG=/D "DEBUG" /Gm /GR /ZI /Od /RTC1 /FR"$(INTDIR)\\" /$(MLIB)d
++CPP_DEBUG=/D "DEBUG" /Gm /GR /Od /RTC1 /FR"$(INTDIR)\\"
+ # CPP_DEBUG=/D "DEBUG" /Gm /GR /ZI /Od /RTC1 /FR"$(INTDIR)\\" /MDd
+ 
+ OUTDIR=.\debug
+ INTDIR=.\debug_temp
+-LINK_DEBUG= MSVCRTD.lib /debug /incremental:yes #/pdbtype:sept
++LINK_DEBUG= /debug 
+ 
+ all : lib lib_dll bsc
+ 
+ !ELSE
+-CPP_DEBUG=/D "NDEBUG" /O2 /$(MLIB)
++CPP_DEBUG=/D "NDEBUG" /O2
+ # CPP_DEBUG=/D "NDEBUG" /O2 /MD
+ OUTDIR=.\release
+ INTDIR=.\release_temp
+-LINK_DEBUG= MSVCRT.lib /incremental:no /NODEFAULTLIB:libc
++LINK_DEBUG= /incremental:no /NODEFAULTLIB:libc
+ 
+ all : lib lib_dll
+ 
+@@ -48,11 +53,7 @@
  CPP_DEBUG=/D "TRACING" $(CPP_DEBUG)
  !ENDIF
  
  
  clean :
      @- rd /s/q .\release_temp
-@@ -779,7 +779,7 @@
+@@ -779,7 +780,7 @@
  	@- $(CPP) $(CPPFLAGS) $(CPP_DEBUG) /Fo"$(INTDIR)\FileFont$(OBJEXT)" $?
  	
  "$(INTDIR)\FileFont_dll$(OBJEXT)" : "src/font/FileFont.cpp"
  	bool fSkipChunkStart, int cslotReprocess, bool fBackingUp)
  {
  	Assert(AssertValid());
-@@ -1863,7 +1872,7 @@
+@@ -1863,7 +1872,11 @@
  	Ensure that the chunk maps for a pair of streams match properly. The recipient is
  	the input stream.
  ----------------------------------------------------------------------------------------------*/
--void GrSlotStream::AssertChunkMapsValid(GrSlotStream * psstrmOut)
-+void GrSlotStream::AssertChunkMapsValid(GrSlotStream * /*psstrmOut*/)
++#ifdef _DEBUG
+ void GrSlotStream::AssertChunkMapsValid(GrSlotStream * psstrmOut)
++#else
++void GrSlotStream::AssertChunkMapsValid(GrSlotStream * )
++#endif
  {
  #ifdef _DEBUG
  	GrSlotStream * psstrmIn = this;
-@@ -1915,7 +1924,7 @@
+@@ -1915,7 +1924,11 @@
  	Ensure that corresponding items in the streams of a positioning pass have matching
  	stream indices. The recipient is the output stream.
  ----------------------------------------------------------------------------------------------*/
--void GrSlotStream::AssertStreamIndicesValid(GrSlotStream * psstrmIn)
-+void GrSlotStream::AssertStreamIndicesValid(GrSlotStream * /*psstrmIn*/)
++#ifdef _DEBUG
+ void GrSlotStream::AssertStreamIndicesValid(GrSlotStream * psstrmIn)
++#else
++void GrSlotStream::AssertStreamIndicesValid(GrSlotStream * )
++#endif
  {
  #ifdef _DEBUG
  	if (!GotIndexOffset())
-@@ -1939,7 +1948,7 @@
+@@ -1939,7 +1948,11 @@
  	in the output stream. (Currently the compiler ensures this by making it an error
  	to write rules that don't do this.)
  ----------------------------------------------------------------------------------------------*/
--void GrSlotStream::AssertAttachmentsInOutput(int islotMin, int islotLim)
-+void GrSlotStream::AssertAttachmentsInOutput(int /*islotMin*/, int /*islotLim*/)
++#ifdef _DEBUG
+ void GrSlotStream::AssertAttachmentsInOutput(int islotMin, int islotLim)
++#else
++void GrSlotStream::AssertAttachmentsInOutput(int , int )
++#endif
  {
  #ifdef _DEBUG
  	for (int islot = islotMin; islot < islotLim; islot++)
-@@ -2007,7 +2016,7 @@
+@@ -2007,7 +2016,11 @@
  	Record the number of slots in the stream that are previous to the official start of the
  	segment.
  ----------------------------------------------------------------------------------------------*/
--void GrSlotStream::CalcIndexOffset(GrTableManager * ptman)
-+void GrSlotStream::CalcIndexOffset(GrTableManager * /*ptman*/)
++#ifdef _DEBUG
+ void GrSlotStream::CalcIndexOffset(GrTableManager * ptman)
++#else
++void GrSlotStream::CalcIndexOffset(GrTableManager * )
++#endif
  {
  	if (GotIndexOffset())
  		return; // already figured it
  		*pclrBack = kclrTransparent;
 --- misc/silgraphite-2.3.1/wrappers/win32/WinFont.cpp	Thu Jan 29 10:33:19 2009
 +++ misc/build/silgraphite-2.3.1/wrappers/win32/WinFont.cpp	Sat Aug 22 19:36:36 2009
+@@ -70,6 +72,7 @@
+ 	// But don't store m_hfont, because we don't really "own" it; the client is
+ 	// responsible for releasing it.
+ 	m_hfont = 0;
++    m_pGlyphMetricMap = NULL;
+ 	memset(&m_fpropSet, 0, sizeof(m_fpropSet));
+ 
+ 	m_pbCmapTbl = NULL;
+@@ -196,6 +198,7 @@
+ 	m_hdc = 0;
+ 	m_hfont = 0;
+ 	m_hfontClient = 0;
++    m_pGlyphMetricMap = NULL;
+ 	memset(&m_fpropSet, 0, sizeof(FontProps));
+ 
+ 	m_pbCmapTbl = NULL;
+@@ -408,7 +410,7 @@
+ 					if (pPolyCurve->wType == TT_PRIM_QSPLINE &&
+ 						// test if this is the last curve
+ 						pPolyHdr->cb - (int)((byte *)(&pPolyCurve->apfx[j]) - (byte *)(pPolyHdr))
+-							== sizeof POINTFX &&
++							== sizeof (POINTFX) &&
+ 						// and the two points are identical
+ 						CompareFixed(pPolyCurve->apfx[j].x, pPolyHdr->pfxStart.x) &&
+ 						CompareFixed(pPolyCurve->apfx[j].y, pPolyHdr->pfxStart.y))
+@@ -457,6 +459,16 @@
+ ----------------------------------------------------------------------------------------------*/
+ void WinFont::getGlyphMetrics(gid16 chw, gr::Rect & boundingBox, gr::Point & advances)
+ {
++    if (m_pGlyphMetricMap)
++    {
++        GlyphMetricMap::iterator i = m_pGlyphMetricMap->find(chw);
++        if (i != m_pGlyphMetricMap->end())
++        {
++            boundingBox = i->second.first;
++            advances = i->second.second;
++            return;
++        }
++    }
+ 	GLYPHMETRICS gm;
+ 	const MAT2 mat2 = {{0,1}, {0,0}, {0,0}, {0,1}};
+ 	if (GDI_ERROR == ::GetGlyphOutline(m_hdc, chw, GGO_GLYPH_INDEX | GGO_METRICS,
+@@ -474,6 +476,10 @@
+ 	boundingBox.bottom = (float)gm.gmptGlyphOrigin.y - gm.gmBlackBoxY;
+ 	advances.x = gm.gmCellIncX;
+ 	advances.y = gm.gmCellIncY;
++    if (m_pGlyphMetricMap)
++    {
++        (*m_pGlyphMetricMap)[chw] = std::pair<gr::Rect,gr::Point>(boundingBox, advances);
++    }
+ }
+ 
+ /*----------------------------------------------------------------------------------------------
+@@ -618,7 +620,10 @@
+ 
+ 		static int cCreateFontCalls = 0;
+ 		static int cCreateFontZero = 0;
+-		HFONT hfont = g_fhc.GetFont(lf);
++        FontHandleCache::FontCacheValue cache = g_fhc.GetCache(lf);
++        HFONT hfont = cache.hfont;
++        m_pGlyphMetricMap = cache.pGlyphMetricMap;
++		//HFONT hfont = g_fhc.GetFont(lf);
+ 		//char ch1[200];
+ 		//if (hfont == 0)
+ 		//{
+@@ -731,7 +733,7 @@
+ 	@param lf LOGFONT value that describes the desired font
+ 	@return Font handle
+ ----------------------------------------------------------------------------------------------*/
+-HFONT WinFont::FontHandleCache::GetFont(LOGFONT & lf)
++WinFont::FontHandleCache::FontCacheValue WinFont::FontHandleCache::GetCache(LOGFONT & lf)
+ {
+ 	FontCacheValue fcv;
+ 	FontHandleHashMap::iterator itFound = m_hmlffcv.find(lf);
+@@ -752,11 +754,12 @@
+ 			THROW(kresFail);
+ 
+ 		fcv.nRefs = 1;
++        fcv.pGlyphMetricMap = new GlyphMetricMap();
+ 
+ 		m_hmlffcv.insert(std::pair<LOGFONT, FontCacheValue>(lf, fcv));
+ 	}
+ 
+-	return fcv.hfont;
++	return fcv;
+ }
+ 
+ /*----------------------------------------------------------------------------------------------
 @@ -767,7 +767,7 @@
  ----------------------------------------------------------------------------------------------*/
  void WinFont::FontHandleCache::DeleteFont(HFONT hfont)
  		return;
  
  	// find the font in the hash map
+@@ -782,6 +784,8 @@
+ 			{
+ 				// delete font
+ 				::DeleteObject(hfont);
++                if (fcv.pGlyphMetricMap)
++                    delete fcv.pGlyphMetricMap;
+ 				m_hmlffcv.erase(it);
+ 			}
+ 			else
+@@ -832,7 +832,8 @@
+ bool WinFont::LogFontHashFuncs::operator() (const WinFont::LogFontWrapper & key1,
+ 	const WinFont::LogFontWrapper & key2) const
+ {
+-	return (key1 == key2);
++    // return true if key1 should be ordered before key2
++    return (operator()(key1) < operator()(key2));
+ }
+ 
+ /*--------------------------------------------------------------------------------------
 --- misc/silgraphite-2.3.1/wrappers/win32/WinFont.h	Thu Jan 29 10:33:19 2009
 +++ misc/build/silgraphite-2.3.1/wrappers/win32/WinFont.h	Sat Aug 22 19:36:36 2009
-@@ -27,6 +27,10 @@
+@@ -27,7 +27,13 @@
  #include "GrClient.h"
  #include "Font.h"
++#include <map>
  
 +#ifdef _STLPORT_VERSION
 +namespace stdext = _STLP_STD;
 +
  namespace gr
  {
++typedef std::map<gid16, std::pair<gr::Rect, gr::Point> > GlyphMetricMap;
  
+ class FontFace;
+@@ -100,6 +110,7 @@
+ 	HFONT m_hfontClient;	// need to replace this HFONT into the DC when we are finished
+ 							// with it
+ 
++    GlyphMetricMap * m_pGlyphMetricMap;
+ 	// Debugging:
+ 	//OLECHAR m_rgchTemp[32];
+ 
+@@ -185,11 +196,13 @@
+ 	class FontHandleCache // hungarian: fhc
+ 	{
+ 	public:
+-		struct FontCacheValue
++        struct FontCacheValue
+ 		{
+ 			int nRefs;   // reference count
+ 			HFONT hfont; // font handle
+ 
++            GlyphMetricMap * pGlyphMetricMap; // glyph metrics
++
+ 			bool operator==(const FontCacheValue & val) const
+ 			{
+ 				return (hfont == val.hfont);
+@@ -199,7 +212,8 @@
+         FontHandleCache() : m_bValid(true) {};
+ 		~FontHandleCache();
+ 
+-		HFONT GetFont(LOGFONT & lf);
++		//HFONT GetFont(LOGFONT & lf);
++        FontCacheValue GetCache(LOGFONT & lf);
+ 		void DeleteFont(HFONT hfont);
+ 
+ 		typedef stdext::hash_map<LogFontWrapper, FontCacheValue, LogFontHashFuncs> FontHandleHashMap;
+--- misc/build/silgraphite-2.3.1/engine/test/RegressionTest/RtTextSrc.h~	2009-01-22 05:06:42.000000000 +0630
++++ misc/build/silgraphite-2.3.1/engine/test/RegressionTest/RtTextSrc.h	2010-04-30 23:14:49.000000000 +0630
+@@ -44,18 +44,18 @@
+ 		}
+ 	}
+ 
+-	virtual size_t getFontFeatures(toffset ich, FeatureSetting * prgfset)
++	virtual size_t getFontFeatures(toffset /*ich*/, FeatureSetting * prgfset)
+ 	{
+ 		// Note: size of prgfset buffer = gr::kMaxFeatures = 64
+ 		std::copy(m_fset, m_fset + MAXFEAT, prgfset);
+ 		return m_cFeats;
+ 	}
+ 
+-	virtual bool getRightToLeft(toffset ich)
++	virtual bool getRightToLeft(toffset /*ich*/)
+ 	{
+ 		return m_fRtl;
+ 	}
+-	virtual unsigned int getDirectionDepth(toffset ich)
++	virtual unsigned int getDirectionDepth(toffset /*ich*/)
+ 	{
+ 		return ((m_fRtl == 1) ? 1 : 0);
+ 	}
+
+--- misc/build/silgraphite-2.3.1/engine/test/RegressionTest/GrJustifier.cpp	2010-06-21 12:55:34.000000000 +0630
++++ misc/build/silgraphite-2.3.1/engine/test/RegressionTest/GrJustifier.cpp	2010-06-21 13:16:59.000000000 +0630
+@@ -16,8 +16,9 @@
+ //:>	Include files
+ //:>********************************************************************************************
+ //#include "main.h" // This is used by clients, so main.h is not available
+-
++#ifdef _MSC_VER
+ #pragma hdrstop
++#endif
+ // any other headers (not precompiled)
+ #include "GrClient.h"
+ #include "ITextSource.h"
+@@ -31,9 +32,6 @@
+ #include <string>
+ #endif
+ 
+-#undef THIS_FILE
+-DEFINE_THIS_FILE
+-
+ //:>********************************************************************************************
+ //:>	Global constants
+ //:>********************************************************************************************
+@@ -327,9 +325,9 @@
+ 					&dxStretchAchieved);
+ 				for (int iiiGlyph = 0; iiiGlyph < cStretchable; iiiGlyph++)
+ 				{
+-					iiGlyph = viiGlyphsRem[iiiGlyph];
+-					vdxStretchLeft[iiGlyph] = vdxStretchRem[iiiGlyph];
+-					vdxWidth[iiGlyph] = vdxWidthRem[iiiGlyph];
++					int ivGlyph = viiGlyphsRem[iiiGlyph];
++					vdxStretchLeft[ivGlyph] = vdxStretchRem[iiiGlyph];
++					vdxWidth[ivGlyph] = vdxWidthRem[iiiGlyph];
+ 				}
+ 			}
+ 			else
+@@ -366,12 +364,12 @@
+ 	{
+ #ifdef WIN32
+ 		wchar_t rgchw[20];
+-		std::fill_n(rgchw, 20, 0);
++		std::fill_n(rgchw, 20, L'\0');
+ 		_itow(dxStretchNeeded - dxStretchAchieved, rgchw, 10);
+ 		std::wstring strTmp(L"justification failed by ");
+ 		strTmp += rgchw;
+ 		strTmp += L" units (width needed = ";
+-		std::fill_n(rgchw, 10, 0);
++		std::fill_n(rgchw, 10, L'\0');
+ 		_itow(dxDesiredWidth, rgchw, 10);
+ 		strTmp += rgchw;
+ 		strTmp += L")\n";
+--- misc/build/silgraphite-2.3.1/engine/test/RegressionTest/GrJustifier.h	2009-01-22 05:06:42.000000000 +0630
++++ misc/build/silgraphite-2.3.1/engine/test/RegressionTest/GrJustifier.h	2010-06-21 13:16:49.000000000 +0630
+@@ -11,7 +11,9 @@
+ Description:
+ 	A default justification agent for Graphite.
+ -------------------------------------------------------------------------------*//*:End Ignore*/
++#ifdef _MSC_VER
+ #pragma once
++#endif
+ #ifndef GRJUSTIFIER_INCLUDED
+ #define GRJUSTIFIER_INCLUDED
+ 
+--- misc/build/silgraphite-2.3.1/engine/test/RegressionTest/SimpleTextSrc.h	2010-06-21 12:55:34.000000000 +0630
++++ misc/build/silgraphite-2.3.1/engine/test/RegressionTest/SimpleTextSrc.h	2010-06-21 13:18:12.000000000 +0630
+@@ -11,7 +11,9 @@
+ Description:
+ 	A simple text source that shows how to use this interface within Graphite.
+ -------------------------------------------------------------------------------*//*:End Ignore*/
++#ifdef _MSC_VER
+ #pragma once
++#endif
+ #ifndef GRTXTSRC_INCLUDED
+ #define GRTXTSRC_INCLUDED
+ 
+
+--- misc/build/silgraphite-2.3.1/engine/test/RegressionTest/SimpleTextSrc.cpp	2010-06-21 12:55:34.000000000 +0630
++++ misc/build/silgraphite-2.3.1/engine/test/RegressionTest/SimpleTextSrc.cpp	2010-06-21 13:18:24.000000000 +0630
+@@ -15,7 +15,9 @@
+ //:>********************************************************************************************
+ //:>	Include files
+ //:>********************************************************************************************
++#ifdef _MSC_VER
+ #pragma hdrstop
++#endif
+ // any other headers (not precompiled)
+ 
+ #include "GrClient.h"
+@@ -23,9 +25,6 @@
+ #include "ITextSource.h"
+ #include "SimpleTextSrc.h"
+ 
+-#undef THIS_FILE
+-DEFINE_THIS_FILE
+-
+ //:>********************************************************************************************
+ //:>	Initialization and destruction
+ //:>********************************************************************************************
+--- misc/build/silgraphite-2.3.1/engine/src/segment/MemoryUsage.cpp	2009-01-22 05:06:42.000000000 +0630
++++ misc/build/silgraphite-2.3.1/engine/src/segment/MemoryUsage.cpp	2010-06-21 13:36:36.000000000 +0630
+@@ -11,10 +11,10 @@
+ Description:
+     Calculates memory usage for the engine and segments.
+ ----------------------------------------------------------------------------------------------*/
+-
++#ifdef _MSC_VER
+ #pragma warning(disable: 4244)	// conversion from wchar_t to char
+ #pragma warning(disable: 4702)	// unreachable code
+-
++#endif
+ //:>********************************************************************************************
+ //:>	Include files
+ //:>********************************************************************************************
+@@ -54,8 +54,6 @@
+ #ifdef _MSC_VER
+ #pragma hdrstop
+ #endif
+-#undef THIS_FILE
+-DEFINE_THIS_FILE
+ 
+ //:End Ignore
+ 
+--- misc/build/silgraphite-2.3.1/engine/src/segment/GrSlotState.h	2010-06-23 19:52:56.429060400 +0700
++++ misc/build/silgraphite-2.3.1/engine/src/segment/GrSlotState.h	2010-05-25 11:51:15.195066300 +0700
+@@ -48,7 +48,7 @@
+ 	{
+ 	}
+ 
+-	~GrSlotAbstract()
++	virtual ~GrSlotAbstract()
+ 	{
+ 		// the table manager is responsible for destroying the contents of m_prgnVarLenBuf
+ 	}
+@@ -231,7 +231,7 @@
+ 		ZapCompositeMetrics();
+ 	}
+ 
+-	~GrSlotState()
++	virtual ~GrSlotState()
+ 	{
+ 	}
+ 
+--- misc/build/silgraphite-2.3.1/engine/src/segment/Segment.cpp.bak	2010-06-23 19:59:54.611660400 +0700
++++ misc/build/silgraphite-2.3.1/engine/src/segment/Segment.cpp	2010-06-23 21:30:16.335460400 +0700
+@@ -246,6 +246,8 @@
+ 
+ 	m_dxsVisibleWidth = -1;
+ 	m_dxsTotalWidth = -1;
++	m_ichwAssocsMin = 0;
++	m_ichwAssocsLim = 0;
+ 
+ //	m_psstrm = NULL;
+ 	m_prgslout = NULL;
+@@ -2988,9 +2988,10 @@
+ 	return kresOk;
+ }
+ 
+-
++#ifdef __GNUC__
+ // suppress GCC 4.3 warning for optimized min()/max() when called with (ich, ich+1) or similar
+ #pragma GCC diagnostic ignored "-Wstrict-overflow"
++#endif
+ 
+ /*----------------------------------------------------------------------------------------------
+ 	Merge the given characters into the same Uniscribe cluster. This means merging any
+--- misc/build/silgraphite-2.3.1/wrappers/win32/win32_dll.cpp.bak	2008-05-09 18:10:30.000000000 +0700
++++ misc/build/silgraphite-2.3.1/wrappers/win32/win32_dll.cpp	2010-05-10 15:46:54.291818000 +0700
+@@ -14,7 +14,7 @@
+ 	DllMain. This is the main DLL entry point for a non-MFC DLL. For an MFC DLL, DllMain is
+ 		in DllModul.cpp. Both DllMains call ModuleEntry::DllMain.
+ ----------------------------------------------------------------------------------------------*/
+-extern "C" BOOL WINAPI DllMain(HMODULE hmod, DWORD dwReason, PVOID pvReserved)
++extern "C" BOOL WINAPI DllMain(HMODULE hmod, DWORD dwReason, PVOID /*pvReserved*/)
+ {
+ 	bool fRet = true;
+ 

File graphite/makefile.mk

 
 # convert line-endings to avoid problems when patching
 CONVERTFILES=\
-	engine/makefile.vc8
+	engine/makefile.vc8 \
+	engine/test/RegressionTest/RtTextSrc.h
 
 #.IF "$(OS)"=="WNT" && "$(COM)"!="GCC"
 #CONFIGURE_DIR=win32
 BUILD_ACTION=nmake VERBOSE=1
 .IF "$(debug)"=="true"
 BUILD_FLAGS= "CFG=DEBUG"
+CFLAGSWITHPATH= $(CFLAGS:s!-Fd.!-Fd../../../../../!)
+.ELSE
+# Speed Optimization is really needed for Graphite
+CFLAGSWITHPATH= $(CFLAGS) /O2
 .ENDIF
 ### convert CFLAGS as cl.exe cannot handle OOO"s generic ones directly
 ### TODO: use "guw.exe" instead?
-ALLCFLAGS= $(CFLAGS) $(CFLAGSCXX) $(CFLAGSEXCEPTIONS) $(CDEFS)
+ALLCFLAGS= $(CFLAGSWITHPATH) $(CFLAGSCXX) $(CFLAGSEXCEPTIONS) $(CDEFS)
 JUSTASLASH= /
 CFLAGS2MSC= $(ALLCFLAGS:s/-Z/$(JUSTASLASH)Z/)
 CFLAGS4MSC= $(CFLAGS2MSC:s/ -/ $(JUSTASLASH)/)
-BUILD_FLAGS+= "MLIB=MD" "CFLAGS4MSC=$(CFLAGS4MSC)" /F makefile.vc$(VCNUM) dll
+BUILD_FLAGS+= "CFLAGS4MSC=$(CFLAGS4MSC)" /F makefile.vc$(VCNUM) lib_dll
 .ENDIF
 
 .IF "$(COM)"=="GCC"
 #OUT2LIB+=engine$/src$/.libs$/libgraphite*.dll
 .IF "$(debug)"=="true"
 OUT2BIN= \
-    engine$/debug$/*.dll \
+#    engine$/debug$/*.dll \
     engine$/debug$/*.pdb
 .ELSE
-OUT2BIN= \
-    engine$/release$/*.dll
+OUT2BIN=
+#    engine$/release$/*.dll
 #    engine$/release$/*.pdb
 .ENDIF
 .ELSE

File vcl/inc/vcl/graphite_adaptors.hxx

 //
 class VCL_DLLPUBLIC GraphiteFontAdaptor : public gr::Font
 {
-typedef std::map<const gr::gid16, std::pair<gr::Rect, gr::Point> > GlyphMetricMap;
-
+    typedef std::map<const gr::gid16, std::pair<gr::Rect, gr::Point> > GlyphMetricMap;
+    friend class GrFontHasher;
 public:
     static bool    IsGraphiteEnabledFont(ServerFont &) throw();
 

File vcl/inc/vcl/graphite_cache.hxx

 */
 class GraphiteSegmentCache
 {
+public:
   enum {
     // not really sure what good values are here,
     // bucket size should be >> cache size
-    SEG_BUCKET_SIZE = 4096,
-    SEG_CACHE_SIZE = 255
+    SEG_BUCKET_FACTOR = 4,
+    SEG_DEFAULT_CACHE_SIZE = 2047
   };
-public:
-  GraphiteSegmentCache()
-    : m_segMap(SEG_BUCKET_SIZE),
+  GraphiteSegmentCache(sal_uInt32 nSegCacheSize)
+    : m_segMap(nSegCacheSize * SEG_BUCKET_FACTOR),
+	m_nSegCacheSize(nSegCacheSize),
     m_oldestKey(NULL) {};
   ~GraphiteSegmentCache()
   {
 private:
   GraphiteSegMap m_segMap;
   GraphiteRopeMap m_ropeMap;
+  sal_uInt32 m_nSegCacheSize;
   const xub_Unicode * m_oldestKey;
   const xub_Unicode * m_prevKey;
 };
 class GraphiteCacheHandler
 {
 public:
-  GraphiteCacheHandler() : m_cacheMap(255) {};
+  GraphiteCacheHandler() : m_cacheMap(255)
+  {
+	const char * pEnvCache = getenv( "SAL_GRAPHITE_CACHE_SIZE" );
+	if (pEnvCache != NULL)
+	{
+		int envCacheSize = atoi(pEnvCache);
+		if (envCacheSize <= 0)
+			m_nSegCacheSize = GraphiteSegmentCache::SEG_DEFAULT_CACHE_SIZE;
+		else
+		{
+			m_nSegCacheSize = envCacheSize;
+		}
+	}
+	else
+	{
+		m_nSegCacheSize = GraphiteSegmentCache::SEG_DEFAULT_CACHE_SIZE;
+	}
+  };
   ~GraphiteCacheHandler()
   {
     GraphiteCacheMap::iterator i = m_cacheMap.begin();
     {
       return m_cacheMap.find(fontHash)->second;
     }
-    GraphiteSegmentCache *pCache = new GraphiteSegmentCache();
+    GraphiteSegmentCache *pCache = new GraphiteSegmentCache(m_nSegCacheSize);
     m_cacheMap[fontHash] = pCache;
     return pCache;
   }
 private:
   GraphiteCacheMap m_cacheMap;
+  sal_uInt32 m_nSegCacheSize;
 };
 
 #endif

File vcl/inc/vcl/graphite_layout.hxx

 class GrSegRecord;
 // SAL/VCL types
 class ServerFont;
+
+#ifdef WNT
+// The GraphiteWinFont is just a wrapper to enable GrFontHasher to be a friend
+// so that UniqueCacheInfo can be called.
+#include <graphite/WinFont.h>
+class GraphiteWinFont : public gr::WinFont
+{
+    friend class GrFontHasher;
+public:
+    GraphiteWinFont(HDC hdc) : gr::WinFont(hdc) {};
+    virtual ~GraphiteWinFont() {};
+};
+#endif
 // Graphite types
 namespace gr { class Segment; class GlyphIterator; }
 namespace grutils { class GrFeatureParser; }
         iterator_pair_t    neighbour_clusters(const_iterator) const;
     private:
         std::pair<float,float> appendCluster(gr::Segment & rSeg, ImplLayoutArgs & rArgs,
-            bool bRtl, int nFirstCharInCluster, int nNextChar,
+            bool bRtl, float fSegmentAdvance, int nFirstCharInCluster, int nNextChar,
             int nFirstGlyphInCluster, int nNextGlyph, float fScaling,
             std::vector<int> & rChar2Base, std::vector<int> & rGlyph2Char,
             std::vector<int> & rCharDxs, long & rDXOffset);

File vcl/source/glyphs/graphite_adaptors.cxx

             fItalic = false;
     }
 
-    // Get the font name.
+    // Get the font name, but prefix with file name hash in case
+    // there are 2 fonts on the system with the same face name
+    sal_Int32 nHashCode = font.GetFontFileName()->hashCode();
+    ::rtl::OUStringBuffer nHashFaceName;
+    nHashFaceName.append(nHashCode, 16);
     const sal_Unicode    * name = font.GetFontSelData().maName.GetBuffer();
-    const size_t          name_sz = std::min(sizeof szFaceName/sizeof(wchar_t)-1,
-                    size_t(font.GetFontSelData().maName.Len()));
+    nHashFaceName.append(name);
 
-    std::copy(name, name + name_sz, szFaceName);
+    const size_t name_sz = std::min(sizeof szFaceName/sizeof(wchar_t)-1,
+                    static_cast<size_t>(nHashFaceName.getLength()));
+
+    std::copy(nHashFaceName.getStr(), nHashFaceName.getStr() + name_sz, szFaceName);
     szFaceName[name_sz] = '\0';
 }
 
     mfEmUnits(static_cast<FreetypeServerFont &>(sfont).GetMetricsFT().y_ppem),
     mpFeatures(NULL)
 {
-    //std::wstring face_name(maFontProperties.szFaceName);
     const rtl::OString aLang = MsLangId::convertLanguageToIsoByteString( sfont.GetFontSelData().meLanguage );
-#ifdef DEBUG
-    printf("GraphiteFontAdaptor %lx\n", (long)this);
-#endif
     rtl::OString name = rtl::OUStringToOString(
         sfont.GetFontSelData().maTargetName, RTL_TEXTENCODING_UTF8 );
+#ifdef DEBUG
+    printf("GraphiteFontAdaptor %lx %s italic=%u bold=%u\n", (long)this, name.getStr(),
+           maFontProperties.fItalic, maFontProperties.fBold);
+#endif
     sal_Int32 nFeat = name.indexOf(grutils::GrFeatureParser::FEAT_PREFIX) + 1;
     if (nFeat > 0)
     {
 // Return the glyph's metrics in pixels.
 void GraphiteFontAdaptor::getGlyphMetrics(gr::gid16 nGlyphId, gr::Rect & aBounding, gr::Point & advances)
 {
-    // Graphite gets really confused if the glyphs have been transformed, so
-    // if orientation has been set we can't use the font's glyph cache
-    // unfortunately the font selection data, doesn't always have the orientation
-    // set, even if it was when the glyphs were cached, so we use our own cache.
+    // There used to be problems when orientation was set however, this no
+    // longer seems to be the case and the Glyph Metric cache in
+    // FreetypeServerFont is more efficient since it lasts between calls to VCL
+#if 1
+    const GlyphMetric & metric = mrFont.GetGlyphMetric(nGlyphId);
 
-//         const GlyphMetric & metric = mrFont.GetGlyphMetric(nGlyphId);
-//
-//         aBounding.right  = aBounding.left = metric.GetOffset().X();
-//         aBounding.bottom = aBounding.top  = -metric.GetOffset().Y();
-//         aBounding.right  += metric.GetSize().Width();
-//         aBounding.bottom -= metric.GetSize().Height();
-//
-//         advances.x = metric.GetDelta().X();
-//         advances.y = -metric.GetDelta().Y();
+    aBounding.right  = aBounding.left = metric.GetOffset().X();
+    aBounding.bottom = aBounding.top  = -metric.GetOffset().Y();
+    aBounding.right  += metric.GetSize().Width();
+    aBounding.bottom -= metric.GetSize().Height();
 
+    advances.x = metric.GetDelta().X();
+    advances.y = -metric.GetDelta().Y();
+
+#else
+    // The problem with the code below is that the cache only lasts
+    // as long as the life time of the GraphiteFontAdaptor, which
+    // is created once per call to X11SalGraphics::GetTextLayout
     GlyphMetricMap::const_iterator gm_itr = maGlyphMetricMap.find(nGlyphId);
     if (gm_itr != maGlyphMetricMap.end())
     {
         // Now add an entry to our metrics map.
         maGlyphMetricMap[nGlyphId] = std::make_pair(aBounding, advances);
     }
+#endif
 }
 
 #endif

File vcl/source/glyphs/graphite_cache.cxx

     : m_rope(rope), m_text(textSrc), m_seg(seg), m_nextKey(NULL),
     m_fontScale(0.0f), mbIsRtl(bIsRtl), m_lockCount(0)
 {
-	m_pStr = textSrc->getLayoutArgs().mpStr + seg->startCharacter();
-	m_startChar = seg->startCharacter();
+    m_pStr = textSrc->getLayoutArgs().mpStr + seg->startCharacter();
+    m_startChar = seg->startCharacter();
 }
 
 GrSegRecord::~GrSegRecord()
 {
-	clear();
+    clear();
 }
 
 void GrSegRecord::reuse(rtl::OUString * rope, TextSourceAdaptor * textSrc, gr::Segment * seg, bool bIsRtl)
     // when the next key is added, the record for the prevKey's m_nextKey field
     // is updated to the newest key so that m_oldestKey can be updated to the
     // next oldest key when the record for m_oldestKey is deleted
-    if (m_segMap.size() > SEG_CACHE_SIZE)
+    if (m_segMap.size() > m_nSegCacheSize)
     {
       GraphiteSegMap::iterator oldestPair = m_segMap.find(reinterpret_cast<long>(m_oldestKey));
       // oldest record may no longer exist if a buffer was changed

File vcl/source/glyphs/graphite_layout.cxx

 #include <svsys.h>
 #endif
 
+#ifdef UNX
+#include <vcl/graphite_adaptors.hxx>
+#endif
+
 #include <vcl/salgdi.hxx>
 
 #include <unicode/uchar.h>
     glyph_range_t iGlyphs = rSegment.glyphs();
     int nGlyphs = iGlyphs.second - iGlyphs.first;
     gr::GlyphIterator prevBase = iGlyphs.second;
-    float fMinX = rSegment.advanceWidth();
+    float fSegmentAdvance = rSegment.advanceWidth();
+    float fMinX = fSegmentAdvance;
     float fMaxX = 0.0f;
     rGlyph2Char.assign(nGlyphs, -1);
     long nDxOffset = 0;
                         nFirstGlyphInCluster != nGlyphIndex)
                     {
                         std::pair <float,float> aBounds =
-                            appendCluster(rSegment, rArgs, bRtl, nFirstCharInCluster,
+                            appendCluster(rSegment, rArgs, bRtl,
+                            fSegmentAdvance, nFirstCharInCluster,
                             nNextChar, nFirstGlyphInCluster, nGlyphIndex, fScaling,
                             rChar2Base, rGlyph2Char, rCharDxs, nDxOffset);
                         fMinX = std::min(aBounds.first, fMinX);
         nFirstGlyphInCluster != nGlyphIndex)
     {
         std::pair <float,float> aBounds =
-            appendCluster(rSegment, rArgs, bRtl, nFirstCharInCluster, nNextChar,
+            appendCluster(rSegment, rArgs, bRtl, fSegmentAdvance,
+                          nFirstCharInCluster, nNextChar,
                           nFirstGlyphInCluster, nGlyphIndex, fScaling,
                           rChar2Base, rGlyph2Char, rCharDxs, nDxOffset);
         fMinX = std::min(aBounds.first, fMinX);
     }
 }
 
-std::pair<float,float> GraphiteLayout::Glyphs::appendCluster(gr::Segment & rSeg,
-    ImplLayoutArgs & rArgs, bool bRtl, int nFirstCharInCluster, int nNextChar,
-    int nFirstGlyphInCluster, int nNextGlyph, float fScaling,
-    std::vector<int> & rChar2Base, std::vector<int> & rGlyph2Char,
-    std::vector<int> & rCharDxs, long & rDXOffset)
+std::pair<float,float> GraphiteLayout::Glyphs::appendCluster(gr::Segment& rSeg,
+    ImplLayoutArgs & rArgs, bool bRtl,float fSegmentAdvance,
+    int nFirstCharInCluster, int nNextChar, int nFirstGlyphInCluster,
+    int nNextGlyph, float fScaling, std::vector<int> & rChar2Base,
+    std::vector<int> & rGlyph2Char, std::vector<int> & rCharDxs, long & rDXOffset)
 {
     glyph_range_t iGlyphs = rSeg.glyphs();
     int nGlyphs = iGlyphs.second - iGlyphs.first;
         gr::GlyphInfo aGlyph = *(iGlyphs.first + j);
         if (j + nDelta >= nGlyphs || j + nDelta < 0) // at rhs ltr,rtl
         {
-            fNextOrigin = rSeg.advanceWidth();
-            nNextOrigin = round(rSeg.advanceWidth() * fScaling + rDXOffset);
-            aBounds.second = std::max(rSeg.advanceWidth(), aBounds.second);
+            fNextOrigin = fSegmentAdvance;
+            nNextOrigin = round(fSegmentAdvance * fScaling + rDXOffset);
+            aBounds.second = std::max(fSegmentAdvance, aBounds.second);
         }
         else
         {
     // If true, it can cause end of line spaces to be hidden e.g. Doulos SIL
     maLayout.setStartOfLine(false);
     maLayout.setEndOfLine(false);
-//    maLayout.setDumbFallback(false);
+    maLayout.setDumbFallback(true);
     // trailing ws doesn't seem to always take affect if end of line is true
     maLayout.setTrailingWs(gr::ktwshAll);
 #ifdef GRLAYOUT_DEBUG
     else delete pSegment;
 #else
     gr::Segment * pSegment = CreateSegment(rArgs);
+    if (!pSegment)
+        return false;
     bool success = LayoutGlyphs(rArgs, pSegment);
     delete pSegment;
 #endif
 #endif
         return hash;
     };
-
+protected:
+    virtual void UniqueCacheInfo(std::wstring & stuFace, bool & fBold, bool & fItalic)
+    {
+#ifdef WIN32
+        dynamic_cast<GraphiteWinFont&>(mrRealFont).UniqueCacheInfo(stuFace, fBold, fItalic);
+#else
+#ifdef UNX
+        dynamic_cast<GraphiteFontAdaptor&>(mrRealFont).UniqueCacheInfo(stuFace, fBold, fItalic);
+#else
+#error Unknown base type for gr::Font::UniqueCacheInfo
+#endif
+#endif
+    }
 private:
     gr::Font & mrRealFont;
 };
         }
         else
         {
+#ifdef GRLAYOUT_DEBUG
+            fprintf(grLog(), "Gr::LayoutText failed: ");
+            for (int i = mnMinCharPos; i < limit; i++)
+            {
+                fprintf(grLog(), "%04x ", rArgs.mpStr[i]);
+            }
+            fprintf(grLog(), "\n");
+#endif
             clear();
             return NULL;
         }
                 if (i > 0) pDXArray[i] -= mvCharDxs[i-1];
             }
 #ifdef GRLAYOUT_DEBUG
-            fprintf(grLog(),"%d,%d,%ld ", (int)i, (int)mvCharDxs[i], pDXArray[i]);
+            fprintf(grLog(),"%d,%d,%d ", (int)i, (int)mvCharDxs[i], pDXArray[i]);
 #endif
         }
         //std::adjacent_difference(mvCharDxs.begin(), mvCharDxs.end(), pDXArray);
 
 #ifdef GRLAYOUT_DEBUG
     for (size_t iDx = 0; iDx < mvCharDxs.size(); iDx++)
-         fprintf(grLog(),"%d,%d,%ld ", (int)iDx, (int)mvCharDxs[iDx], args.mpDXArray[iDx]);
+         fprintf(grLog(),"%d,%d,%d ", (int)iDx, (int)mvCharDxs[iDx], args.mpDXArray[iDx]);
     fprintf(grLog(),"ApplyDx\n");
 #endif
     bool bRtl = mnLayoutFlags & SAL_LAYOUT_BIDI_RTL;
             }
             long nDWidth = nNewClusterWidth - nOrigClusterWidth;
 #ifdef GRLAYOUT_DEBUG
-            fprintf(grLog(), "c%d last glyph %d/%d\n", i, nLastGlyph, mvGlyphs.size());
+            fprintf(grLog(), "c%lu last glyph %d/%lu\n", i, nLastGlyph, mvGlyphs.size());
 #endif
             assert((nLastGlyph > -1) && (nLastGlyph < (signed)mvGlyphs.size()));
             mvGlyphs[nLastGlyph].mnNewWidth += nDWidth;
     std::copy(args.mpDXArray, args.mpDXArray + nChars,
       mvCharDxs.begin() + (args.mnMinCharPos - mnMinCharPos));
 #ifdef GRLAYOUT_DEBUG
-    fprintf(grLog(),"ApplyDx %ld(%ld)\n", args.mpDXArray[nChars - 1], mnWidth);
+    fprintf(grLog(),"ApplyDx %d(%ld)\n", args.mpDXArray[nChars - 1], mnWidth);
 #endif
     mnWidth = args.mpDXArray[nChars - 1];
 }
         }
         nKashidaCount = 1 + (nGapWidth / nKashidaWidth);
 #ifdef GRLAYOUT_DEBUG
-        printf("inserting %d kashidas at %ld\n", nKashidaCount, (*i).mnGlyphIndex);
+        printf("inserting %d kashidas at %u\n", nKashidaCount, (*i).mnGlyphIndex);
 #endif
         GlyphItem glyphItem = *i;
         Point aPos(0, 0);
             pCaretXArray[i] = pCaretXArray[i+1] = 0;
         }
 #ifdef GRLAYOUT_DEBUG
-        fprintf(grLog(),"%d,%ld-%ld\t", nCharSlot, pCaretXArray[i], pCaretXArray[i+1]);
+        fprintf(grLog(),"%d,%d-%d\t", nCharSlot, pCaretXArray[i], pCaretXArray[i+1]);
 #endif
     }
 #ifdef GRLAYOUT_DEBUG

File vcl/source/glyphs/graphite_textsrc.hxx

         virtual ext_std::pair<gr::toffset, gr::toffset> propertyRange(gr::toffset ich);
         virtual size_t  getFontFeatures(gr::toffset ich, gr::FeatureSetting * prgfset);
         virtual bool    sameSegment(gr::toffset ich1, gr::toffset ich2);
+        virtual bool featureVariations() { return false; }
 
         operator ImplLayoutArgs & () throw();
         void setFeatures(const grutils::GrFeatureParser * pFeatures);

File vcl/unx/source/fontmanager/fontconfig.cxx

     fprintf( stderr, "FcConfigAppFontAddDir( \"%s\") => %d\n", pDirName, bDirOk );
 #endif
 
-    if( bDirOk )
+    if( !bDirOk )
+        return false;
+
+    // load dir-specific fc-config file too if available
+    const rtl::OString aConfFileName = rDirName + "/fc_local.conf";
+    FILE* pCfgFile = fopen( aConfFileName.getStr(), "rb" );
+    if( pCfgFile )
     {
-        const rtl::OString aConfFileName = rDirName + "/fc_local.conf";
+        fclose( pCfgFile);
         bool bCfgOk = rWrapper.FcConfigParseAndLoad( rWrapper.FcConfigGetCurrent(),
-                            (FcChar8*)aConfFileName.getStr(), FcTrue );
-        (void)bCfgOk; // silence compiler warning
-
-#if OSL_DEBUG_LEVEL > 1
-        fprintf( stderr, "FcConfigParseAndLoad( \"%s\") => %d\n", aConfFileName.getStr(), bCfgOk );
-#endif
+                        (FcChar8*)aConfFileName.getStr(), FcTrue );
+        if( !bCfgOk )
+            fprintf( stderr, "FcConfigParseAndLoad( \"%s\") => %d\n", aConfFileName.getStr(), bCfgOk );
     }
 
-    return bDirOk;
+    return true;
 }
 
 static void addtopattern(FontCfgWrapper& rWrapper, FcPattern *pPattern, 

File vcl/win/source/gdi/winlayout.cxx

 class GraphiteWinLayout : public WinLayout
 {
 private:
-    mutable gr::WinFont   mpFont;
+    mutable GraphiteWinFont mpFont;
     grutils::GrFeatureParser * mpFeatures;
     mutable GraphiteLayoutWinImpl maImpl;
 public: