On Thu, 2002-08-01 at 21:43, Joaqu�n Cuenca Abela wrote:
> btw, some days ago I posted another patch.  Can somebody please commit
> it?  if it works on STABLE (compiles) then it's also ok to commit it to
> STABLE (it's just a little speed up, and it's not dark magic or
> something)

sorry, my last patch was malformed.

here you have a good one.

Cheers,

-- 
Joaqu�n Cuenca Abela
[EMAIL PROTECTED]
diff -ru abi/src/af/xap/unix/xap_UnixFont.cpp abi3/src/af/xap/unix/xap_UnixFont.cpp
--- abi/src/af/xap/unix/xap_UnixFont.cpp	Wed Jul 24 10:08:19 2002
+++ abi3/src/af/xap/unix/xap_UnixFont.cpp	Thu Aug  1 20:35:23 2002
@@ -1267,13 +1267,9 @@
 #endif
 		UT_DEBUGMSG(("After print.\n"));
 
-		UT_DEBUGMSG(("Before open.\n"));
 		pXftFont = XftFontOpenPattern(GDK_DISPLAY(), result_fp);
-		UT_DEBUGMSG(("After open.\n"));
 		
-		UT_DEBUGMSG(("Before destroy.\n"));
 		// FcPatternDestroy(result_fp);
-		UT_DEBUGMSG(("After destroy.\n"));
 
 		// That means that we should should be 100% sure that,
 		// at this point, the font exists in the system
diff -ru abi/src/af/xap/unix/xap_UnixFontManager.cpp abi3/src/af/xap/unix/xap_UnixFontManager.cpp
--- abi/src/af/xap/unix/xap_UnixFontManager.cpp	Tue Jul 16 10:12:52 2002
+++ abi3/src/af/xap/unix/xap_UnixFontManager.cpp	Thu Aug  1 20:33:54 2002
@@ -39,6 +39,11 @@
 // TODO get this from some higher-level place
 #define FONTS_DIR_FILE	"/fonts.dir"
 
+#ifdef USE_XFT
+static FcFontSet* XAP_UnixFontManager::m_pFontSet;
+static FcConfig* XAP_UnixFontManager::m_pConfig;
+#endif
+
 #ifndef USE_XFT
 static char **	s_oldFontPath = NULL;
 static int		s_oldFontPathCount = 0;
@@ -136,6 +141,7 @@
 {
 #ifdef USE_XFT
 	m_pFontSet = FcConfigGetFonts(FcConfigGetCurrent(), FcSetSystem);
+	m_pConfig = FcInitLoadConfigAndFonts();
 //, FC_FAMILY, FC_STYLE, FC_SLANT, FC_WEIGHT, FC_SIZE, FC_FILE, 0);
 #endif
 }
@@ -695,7 +701,7 @@
 	return true;
 }
 
-static XAP_UnixFont* searchFont(const char* pszXftName)
+XAP_UnixFont* XAP_UnixFontManager::searchFont(const char* pszXftName)
 {
 	FcPattern* fp;
 	FcPattern* result_fp;
@@ -703,6 +709,10 @@
 
 	UT_DEBUGMSG(("searchFont [%s]\n", pszXftName));
 	fp = XftNameParse(pszXftName);
+
+	FcConfigSubstitute (m_pConfig, fp, FcMatchPattern);
+	result_fp = FcFontSetMatch (m_pConfig, &m_pFontSet, 1, fp, &result);
+
 	result_fp = XftFontMatch(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()), fp, &result);
 	UT_ASSERT(result_fp);
 	FcPatternDestroy(fp);
@@ -725,7 +735,7 @@
 {
 public:
 	FontHolder(XAP_UnixFont* pFont = NULL) : m_pFont(pFont) {}
-	~FontHolder() { free(m_pFont); }
+	~FontHolder() { delete m_pFont; }
 
 	void setFont(XAP_UnixFont* pFont) { delete m_pFont; m_pFont = pFont; }
 	XAP_UnixFont* getFont() { return m_pFont; }
diff -ru abi/src/af/xap/unix/xap_UnixFontManager.h abi3/src/af/xap/unix/xap_UnixFontManager.h
--- abi/src/af/xap/unix/xap_UnixFontManager.h	Thu Aug  1 21:57:12 2002
+++ abi3/src/af/xap/unix/xap_UnixFontManager.h	Thu Aug  1 20:26:12 2002
@@ -57,6 +57,8 @@
 									XAP_UnixFont::style s);
 
 #ifdef USE_XFT	
+	static XAP_UnixFont*	searchFont(const char* pszXftName);
+
 	static XAP_UnixFont*	findNearestFont(const char* pszFontFamily,
 											const char* pszFontStyle,
 											const char* pszFontVariant,
@@ -86,7 +88,8 @@
 #endif
 
 #ifdef USE_XFT
-	FcFontSet*				m_pFontSet;
+	static FcFontSet*		m_pFontSet;
+	static FcConfig*		m_pConfig;
 #endif
 };
 

Reply via email to