changeset 286:37a1d222b7f8

[gaim-migrate @ 296] Commited patches by Decklin and Flatass Ben. Thanks guys. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Wed, 31 May 2000 18:05:50 +0000
parents a8971e3704f6
children 8bbc269d5b8d
files src/aim.c src/gtkhtml.c
diffstat 2 files changed, 52 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/src/aim.c	Wed May 31 17:58:54 2000 +0000
+++ b/src/aim.c	Wed May 31 18:05:50 2000 +0000
@@ -331,7 +331,7 @@
 
 	/* Register opens the right URL */
 	gtk_signal_connect(GTK_OBJECT(reg), "clicked",
-			   GTK_SIGNAL_FUNC(open_url), "http://www.aol.com/aim");
+			   GTK_SIGNAL_FUNC(open_url), "http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no");
 	/* Enter in the username clears the password and sets
 	   the pointer in the password field */
 	gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "activate",
--- a/src/gtkhtml.c	Wed May 31 17:58:54 2000 +0000
+++ b/src/gtkhtml.c	Wed May 31 18:05:50 2000 +0000
@@ -471,97 +471,66 @@
 }
 
 
-
-
-GdkFont *getfont(char * font, int bold, int italic, int fixed, int size)
+int load_font_with_cache(const char *name, const char *weight, char slant,
+	int size, GdkFont **font_return)
 {
-	gchar font_name[1024] = "-*-";
-	GdkFont * my_font;
-	if (size > MAX_SIZE)
-		size = MAX_SIZE;
-	if (size < 1)
-		size = 1;
-	size--;
-
-	if(strlen(font))
-	{
-		strcat( font_name, font );
-	}
-	else
-	{
-		if( fixed )
-		{
-			strcat( font_name, "courier" );
-		}
-		else
-		{
-			strcat( font_name, "helvetica" );
-		}
-	}
-	strcat( font_name, "-" );
-
-	if(bold)
-	{
-		strcat( font_name, "bold");
-	}
-	else
-	{
-		strcat( font_name, "medium");
+	gchar font_spec[1024];
+
+	g_snprintf(font_spec, sizeof font_spec,
+		"-*-%s-%s-%c-normal-*-*-%d-*-*-*-*-iso8859-1",
+		name, weight, slant, size);
+
+	if((*font_return = g_datalist_id_get_data(&font_cache,
+				g_quark_from_string(font_spec)))) {
+		return TRUE;
+	} else if ((*font_return = gdk_font_load(font_spec))) {
+		g_datalist_id_set_data(&font_cache,
+			g_quark_from_string(font_spec), *font_return);
+		return TRUE;
+	} else {
+		return FALSE;
 	}
-	strcat( font_name, "-" );
-	/*
-	 * here is the deal, some fonts have oblique but not italics
-	 * other fonts have italics but not oblique
-	 * so we are going to try both
-	 */
-	if( italic == 1 )
-	{
-		strcat( font_name, "i");
-	}
-	else if( italic == 2 )
-	{
-		strcat( font_name, "o" );
-	}
-	else
-	{
-		strcat( font_name, "r");
-	}
-	strcat( font_name, "-*-*-*-");
-	{
-		char buff[256];
-		sprintf(buff, "%d-*-*-*-*-*-*", font_sizes[size]);
-		strcat( font_name, buff );
+}
+
+
+GdkFont *getfont(const char *font, int bold, int italic, int fixed, int size)
+{
+	GdkFont *my_font = NULL;
+	gchar *weight, slant;
+
+	if (!font || !strlen(font)) font = fixed ? "courier" : "helvetica";
+	weight = bold ? "bold" : "medium";
+	slant = italic ? 'i' : 'r';
+
+	if (size > MAX_SIZE) size = MAX_SIZE;
+	if (size < 1) size = 1;
+	size = font_sizes[size-1];
+	
+	/* try both 'i'talic and 'o'blique for italic fonts, and keep
+	 * increasing the size until we get one that works. */	
+
+	while (size < 720) {
+		if (load_font_with_cache(font, weight, slant, size, &my_font))
+			return my_font;
+		if (italic && load_font_with_cache(font, weight, 'o', size, &my_font))
+			return my_font;
+		size += 10;
 	}
 
-	g_strdown(font_name);
-		
-	if( (my_font = 
-	     g_datalist_id_get_data(&font_cache, 
-				    g_quark_from_string(font_name)) ) )	
-	{
+	/* since we couldn't get any size up to 72, fall back to the
+	 * default fonts. */
+
+	font = fixed ? "courier" : "helvetica";
+
+	if (load_font_with_cache(font, weight, slant, 120, &my_font))
 		return my_font;
+	else {
+		fprintf(stderr, "gaim: can't load default font\n");
+		exit(1);
 	}
-	my_font = gdk_font_load(font_name);
-	if( !my_font )
-	{
-		if( italic == 1 )
-		{
-			my_font = getfont(font, bold, 2, fixed, size+1 );
-		}
-		else
-		{
-			my_font = getfont("", bold, italic, fixed, size+1 );
-		}
-	}
-	g_datalist_id_set_data( &font_cache, 
-							g_quark_from_string(font_name),
-							my_font );
-	return my_font;
 }
 
 
-
-
 /* 'Borrowed' from ETerm */
 GdkWindow *get_desktop_window(GtkWidget * widget)
 {