Re: pango fonts default aliases --> gnome fonts?



>>>>> On Thu, 30 Jan 2003 15:44:07 -0500,
>>>>> "MB" == Monty Brandenberg <mbranden meetingmaker com> wrote:

MB> Akira TAGOH wrote:
>> 
>> @@ -795,7 +797,14 @@
>> g_warning ("PS name is NULL, for \"%s\" using fallback", entry->file);
face-> psname = g_strdup ("Helvetica");
>> } else {
>> -               face->psname = g_strdup (psname);
>> +               for (n = 0; substitute_families[n]; n++) {
>> +                       if (!g_strcasecmp (entry->familyname, substitute_families[n])) {
>> +                               face->psname = g_strdup (substitute_psname[n]);
>> +                               break;
>> +                       }
>> +               }
>> +               if (!face->psname)
>> +                       face->psname = g_strdup (psname);

MB> One more possible problem...  Before, face->psname was always assigned
MB> the result of a g_strdup().  With the above code, it is conditional.
MB> If face->psname wasn't NULL-initialized, this final test will not
MB> succeed and a later free will operate on random data.  (No comment on
MB> what it means to reuse a GnomeFontFace structure.)

right. attached patch should works. if it's still set
something like unintended data to psname, it will means
current libgnomeprint has a memory leak.

Regards,
--
Akira TAGOH
Index: gnome-font-face.c
===================================================================
RCS file: /cvs/gnome/libgnomeprint/libgnomeprint/gnome-font-face.c,v
retrieving revision 1.67
diff -u -r1.67 gnome-font-face.c
--- gnome-font-face.c	14 Jan 2003 01:23:26 -0000	1.67
+++ gnome-font-face.c	31 Jan 2003 08:07:39 -0000
@@ -150,6 +150,7 @@
 	face->glyphs = NULL;
 	face->ft_face = NULL;
 	face->fonts = NULL;
+	face->psname = NULL;
 }
 
 static void
@@ -774,6 +775,8 @@
 	FT_CharMap appleRoman = 0;
 	FT_CharMap symbol = 0;
 	const guchar *psname;
+	static gchar *substitute_families[] = {"Sans", "Sans Serif", "Serif", "Monospace", NULL};
+	static gchar *substitute_psname[] = {"Sans", "SansSerif", "Serif", "Monospace", NULL};
 	int n;
 
 	if (!ft_library) {
@@ -795,7 +798,14 @@
 		g_warning ("PS name is NULL, for \"%s\" using fallback", entry->file);
 		face->psname = g_strdup ("Helvetica");
 	} else {
-		face->psname = g_strdup (psname);
+		for (n = 0; substitute_families[n]; n++) {
+			if (!g_strcasecmp (entry->familyname, substitute_families[n])) {
+				face->psname = g_strdup (substitute_psname[n]);
+				break;
+			}
+		}
+		if (!face->psname)
+			face->psname = g_strdup (psname);
 	}
 	
 	/* FIXME: scalability (Lauris) */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]