Hi folks,

This patch removes libgdiplus dependency against Cairo
_cairo_toy_font_face_create API function. This API call is an internal
Cairo API call (not part of the public API). Also, on Cairo 1.2 is no
longer exported.

I have tested the patch with a few SWF apps and the SD font creation
samples and it seems to work fine.

I'll appreciate if you try it before I commit it.

Regards,

Jordi,
Index: font.c
===================================================================
--- font.c	(revision 60830)
+++ font.c	(working copy)
@@ -37,12 +37,7 @@
 static int ref_familySansSerif = 0;
 static int ref_familyMonospace = 0;
 
-extern cairo_font_face_t *
-_cairo_toy_font_face_create (const char *family, 
-			     cairo_font_slant_t   slant, 
-			     cairo_font_weight_t  weight);
 
-
 /* Family and collections font functions */
 
 void
@@ -558,7 +553,24 @@
 }
 
 /* Font functions */
+cairo_font_face_t *
+gdip_face_create (const char *family, 
+			cairo_font_slant_t   slant, 
+			cairo_font_weight_t  weight,
+			cairo_t** ct)
+{
+	cairo_surface_t *surface;
+	cairo_font_face_t *face;
 
+	surface = cairo_image_surface_create_for_data ((unsigned char *)NULL, CAIRO_FORMAT_ARGB32, 0, 0, 0);
+	*ct = cairo_create (surface);
+	cairo_select_font_face (*ct, (const char *) family, slant, weight);
+	face = cairo_get_font_face (*ct);
+	cairo_surface_destroy (surface);
+	return face;
+
+}
+
 GpStatus
 GdipCreateFont (GDIPCONST GpFontFamily* family, float emSize, GpFontStyle style, Unit unit,  GpFont **font)
 {
@@ -590,7 +602,7 @@
 	else
 		slant = CAIRO_FONT_SLANT_NORMAL;
 
-	cairofnt = _cairo_toy_font_face_create ((const char*) str, slant, weight);
+	cairofnt = gdip_face_create ((const char*) str, slant, weight, &result->ct);
 
 	if (cairofnt == NULL) {
 		GdipFree(result);
@@ -632,7 +644,8 @@
 	if (!font)
 		return InvalidParameter;
 
-	cairo_font_face_destroy (font->cairofnt);
+	cairo_destroy (font->ct);
+
 	GdipFree ((void *)font->face);
 	GdipFree ((void *)font);
 	return Ok;	       
@@ -753,7 +766,7 @@
 
 	memcpy(result->face, src_font->face, strlen((char *)src_font->face) + 1);
 
-	result->cairofnt = _cairo_toy_font_face_create ((const char*) src_font->face, slant, weight);
+	result->cairofnt = gdip_face_create ((const char*) src_font->face, slant, weight, &result->ct);
 
 	if (result->cairofnt == NULL) {
 		GdipFree(result);
@@ -841,7 +854,7 @@
 		result->face[LF_FACESIZE - 1] = '\0';
 	}
 
-	result->cairofnt = _cairo_toy_font_face_create ((const char *)result->face, slant, weight);
+	result->cairofnt = gdip_face_create ((const char *)result->face, slant, weight, &result->ct);
 	if (result->cairofnt == NULL) {
 		GdipFree(result);
 		return GenericError;
Index: gdip.h
===================================================================
--- gdip.h	(revision 60830)
+++ gdip.h	(working copy)
@@ -890,6 +890,7 @@
 	GpFontFamily	    *family;
 	float               emSize;
 	GpUnit              unit;
+	cairo_t*            ct;
 } GpFont;
 
 
_______________________________________________
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list

Reply via email to